Diff
Modified: trunk/Source/Platform/ChangeLog (121627 => 121628)
--- trunk/Source/Platform/ChangeLog 2012-06-30 12:09:15 UTC (rev 121627)
+++ trunk/Source/Platform/ChangeLog 2012-06-30 15:55:54 UTC (rev 121628)
@@ -1,3 +1,20 @@
+2012-06-30 Ian Vollick <[email protected]>
+
+ [chromium] CanvasLayerTextureUpdater needs to convert opaque rects back to content space.
+ https://bugs.webkit.org/show_bug.cgi?id=90092
+
+ The CanvasLayerTextureUpdater currently receives its opaque rects in
+ layer space, but is expected to return them in content space and does
+ not convert them. This patch adds this conversion. To avoid numerical
+ errors, this patch also switches to using float rects to store opaque
+ rects where appropriate.
+
+ Reviewed by Adrienne Walker.
+
+ * chromium/public/WebContentLayerClient.h:
+ (WebKit):
+ (WebContentLayerClient):
+
2012-06-29 Tony Payne <[email protected]>
Remove type from screenColorProfile API
Modified: trunk/Source/Platform/chromium/public/WebContentLayerClient.h (121627 => 121628)
--- trunk/Source/Platform/chromium/public/WebContentLayerClient.h 2012-06-30 12:09:15 UTC (rev 121627)
+++ trunk/Source/Platform/chromium/public/WebContentLayerClient.h 2012-06-30 15:55:54 UTC (rev 121628)
@@ -30,6 +30,7 @@
namespace WebKit {
struct WebRect;
+struct WebFloatRect;
class WebContentLayerClient {
public:
@@ -41,7 +42,8 @@
// the implementation knows are opaque. This information can be used for various
// optimizations.
#define WEBCONTENTLAYERCLIENT_HAS_OPAQUE 1
- virtual void paintContents(WebCanvas*, const WebRect& clip, WebRect& opaque) = 0;
+#define WEBCONTENTLAYERCLIENT_FLOAT_OPAQUE_RECT 1
+ virtual void paintContents(WebCanvas*, const WebRect& clip, WebFloatRect& opaque) = 0;
protected:
virtual ~WebContentLayerClient() { }
Modified: trunk/Source/WebCore/ChangeLog (121627 => 121628)
--- trunk/Source/WebCore/ChangeLog 2012-06-30 12:09:15 UTC (rev 121627)
+++ trunk/Source/WebCore/ChangeLog 2012-06-30 15:55:54 UTC (rev 121628)
@@ -1,3 +1,41 @@
+2012-06-30 Ian Vollick <[email protected]>
+
+ [chromium] CanvasLayerTextureUpdater needs to convert opaque rects back to content space.
+ https://bugs.webkit.org/show_bug.cgi?id=90092
+
+ The CanvasLayerTextureUpdater currently receives its opaque rects in
+ layer space, but is expected to return them in content space and does
+ not convert them. This patch adds this conversion. To avoid numerical
+ errors, this patch also switches to using float rects to store opaque
+ rects where appropriate.
+
+ Reviewed by Adrienne Walker.
+
+ Unit test: ContentLayerTest.ContentLayerPainterWithDeviceScale
+
+ * platform/graphics/chromium/CanvasLayerTextureUpdater.cpp:
+ (WebCore::CanvasLayerTextureUpdater::paintContents):
+ * platform/graphics/chromium/ContentLayerChromium.cpp:
+ (WebCore::ContentLayerPainter::ContentLayerPainter):
+ (WebCore::ContentLayerPainter::create):
+ (WebCore::ContentLayerPainter::paint):
+ * platform/graphics/chromium/ContentLayerChromium.h:
+ (WebCore):
+ (ContentLayerDelegate):
+ (ContentLayerPainter):
+ * platform/graphics/chromium/LayerPainterChromium.h:
+ (WebCore):
+ (LayerPainterChromium):
+ * platform/graphics/chromium/LinkHighlight.cpp:
+ (WebCore::LinkHighlight::paintContents):
+ * platform/graphics/chromium/LinkHighlight.h:
+ (LinkHighlight):
+ * platform/graphics/chromium/OpaqueRectTrackingContentLayerDelegate.cpp:
+ (WebCore::OpaqueRectTrackingContentLayerDelegate::paintContents):
+ * platform/graphics/chromium/OpaqueRectTrackingContentLayerDelegate.h:
+ (OpaqueRectTrackingContentLayerDelegate):
+ * platform/graphics/chromium/ScrollbarLayerChromium.cpp:
+
2012-06-30 Kwang Yul Seo <[email protected]>
Unreviewed. Remove unused declaration.
Modified: trunk/Source/WebCore/platform/graphics/chromium/CanvasLayerTextureUpdater.cpp (121627 => 121628)
--- trunk/Source/WebCore/platform/graphics/chromium/CanvasLayerTextureUpdater.cpp 2012-06-30 12:09:15 UTC (rev 121627)
+++ trunk/Source/WebCore/platform/graphics/chromium/CanvasLayerTextureUpdater.cpp 2012-06-30 15:55:54 UTC (rev 121628)
@@ -55,25 +55,29 @@
canvas->save();
canvas->translate(WebCoreFloatToSkScalar(-contentRect.x()), WebCoreFloatToSkScalar(-contentRect.y()));
- IntRect scaledContentRect = contentRect;
+ IntRect layerRect = contentRect;
if (contentsWidthScale != 1 || contentsHeightScale != 1) {
canvas->scale(WebCoreFloatToSkScalar(contentsWidthScale), WebCoreFloatToSkScalar(contentsHeightScale));
FloatRect rect = contentRect;
rect.scale(1 / contentsWidthScale, 1 / contentsHeightScale);
- scaledContentRect = enclosingIntRect(rect);
+ layerRect = enclosingIntRect(rect);
}
SkPaint paint;
paint.setAntiAlias(false);
paint.setXfermodeMode(SkXfermode::kClear_Mode);
- canvas->drawRect(scaledContentRect, paint);
- canvas->clipRect(scaledContentRect);
+ canvas->drawRect(layerRect, paint);
+ canvas->clipRect(layerRect);
- m_painter->paint(canvas, scaledContentRect, resultingOpaqueRect);
+ FloatRect opaqueLayerRect;
+ m_painter->paint(canvas, layerRect, opaqueLayerRect);
canvas->restore();
+ opaqueLayerRect.scale(contentsWidthScale, contentsHeightScale);
+ resultingOpaqueRect = enclosedIntRect(opaqueLayerRect);
+
m_contentRect = contentRect;
}
Modified: trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp (121627 => 121628)
--- trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp 2012-06-30 12:09:15 UTC (rev 121627)
+++ trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp 2012-06-30 15:55:54 UTC (rev 121628)
@@ -45,31 +45,25 @@
namespace WebCore {
-class ContentLayerPainter : public LayerPainterChromium {
- WTF_MAKE_NONCOPYABLE(ContentLayerPainter);
-public:
- static PassOwnPtr<ContentLayerPainter> create(ContentLayerDelegate* delegate)
- {
- return adoptPtr(new ContentLayerPainter(delegate));
- }
+ContentLayerPainter::ContentLayerPainter(ContentLayerDelegate* delegate)
+ : m_delegate(delegate)
+{
+}
- virtual void paint(SkCanvas* canvas, const IntRect& contentRect, IntRect& opaque)
- {
- double paintStart = currentTime();
- m_delegate->paintContents(canvas, contentRect, opaque);
- double paintEnd = currentTime();
- double pixelsPerSec = (contentRect.width() * contentRect.height()) / (paintEnd - paintStart);
- WebKit::Platform::current()->histogramCustomCounts("Renderer4.AccelContentPaintDurationMS", (paintEnd - paintStart) * 1000, 0, 120, 30);
- WebKit::Platform::current()->histogramCustomCounts("Renderer4.AccelContentPaintMegapixPerSecond", pixelsPerSec / 1000000, 10, 210, 30);
- }
-private:
- explicit ContentLayerPainter(ContentLayerDelegate* delegate)
- : m_delegate(delegate)
- {
- }
+PassOwnPtr<ContentLayerPainter> ContentLayerPainter::create(ContentLayerDelegate* delegate)
+{
+ return adoptPtr(new ContentLayerPainter(delegate));
+}
- ContentLayerDelegate* m_delegate;
-};
+void ContentLayerPainter::paint(SkCanvas* canvas, const IntRect& contentRect, FloatRect& opaque)
+{
+ double paintStart = currentTime();
+ m_delegate->paintContents(canvas, contentRect, opaque);
+ double paintEnd = currentTime();
+ double pixelsPerSec = (contentRect.width() * contentRect.height()) / (paintEnd - paintStart);
+ WebKit::Platform::current()->histogramCustomCounts("Renderer4.AccelContentPaintDurationMS", (paintEnd - paintStart) * 1000, 0, 120, 30);
+ WebKit::Platform::current()->histogramCustomCounts("Renderer4.AccelContentPaintMegapixPerSecond", pixelsPerSec / 1000000, 10, 210, 30);
+}
PassRefPtr<ContentLayerChromium> ContentLayerChromium::create(ContentLayerDelegate* delegate)
{
Modified: trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.h (121627 => 121628)
--- trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.h 2012-06-30 12:09:15 UTC (rev 121627)
+++ trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.h 2012-06-30 15:55:54 UTC (rev 121628)
@@ -34,23 +34,38 @@
#if USE(ACCELERATED_COMPOSITING)
+#include "LayerPainterChromium.h"
#include "TiledLayerChromium.h"
class SkCanvas;
namespace WebCore {
+class FloatRect;
class IntRect;
class LayerTextureUpdater;
class ContentLayerDelegate {
public:
- virtual void paintContents(SkCanvas*, const IntRect& clip, IntRect& opaque) = 0;
+ virtual void paintContents(SkCanvas*, const IntRect& clip, FloatRect& opaque) = 0;
protected:
virtual ~ContentLayerDelegate() { }
};
+class ContentLayerPainter : public LayerPainterChromium {
+ WTF_MAKE_NONCOPYABLE(ContentLayerPainter);
+public:
+ static PassOwnPtr<ContentLayerPainter> create(ContentLayerDelegate*);
+
+ virtual void paint(SkCanvas*, const IntRect& contentRect, FloatRect& opaque) OVERRIDE;
+
+private:
+ explicit ContentLayerPainter(ContentLayerDelegate*);
+
+ ContentLayerDelegate* m_delegate;
+};
+
// A layer that renders its contents into an SkCanvas.
class ContentLayerChromium : public TiledLayerChromium {
public:
Modified: trunk/Source/WebCore/platform/graphics/chromium/LayerPainterChromium.h (121627 => 121628)
--- trunk/Source/WebCore/platform/graphics/chromium/LayerPainterChromium.h 2012-06-30 12:09:15 UTC (rev 121627)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerPainterChromium.h 2012-06-30 15:55:54 UTC (rev 121628)
@@ -33,12 +33,13 @@
namespace WebCore {
+class FloatRect;
class IntRect;
class LayerPainterChromium {
public:
virtual ~LayerPainterChromium() { }
- virtual void paint(SkCanvas*, const IntRect& contentRect, IntRect& opaque) = 0;
+ virtual void paint(SkCanvas*, const IntRect& contentRect, FloatRect& opaque) = 0;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/chromium/LinkHighlight.cpp (121627 => 121628)
--- trunk/Source/WebCore/platform/graphics/chromium/LinkHighlight.cpp 2012-06-30 12:09:15 UTC (rev 121627)
+++ trunk/Source/WebCore/platform/graphics/chromium/LinkHighlight.cpp 2012-06-30 15:55:54 UTC (rev 121628)
@@ -92,7 +92,7 @@
return m_contentLayer.get();
}
-void LinkHighlight::paintContents(SkCanvas* canvas, const IntRect&, IntRect&)
+void LinkHighlight::paintContents(SkCanvas* canvas, const IntRect&, FloatRect&)
{
PlatformContextSkia platformContext(canvas);
GraphicsContext gc(&platformContext);
Modified: trunk/Source/WebCore/platform/graphics/chromium/LinkHighlight.h (121627 => 121628)
--- trunk/Source/WebCore/platform/graphics/chromium/LinkHighlight.h 2012-06-30 12:09:15 UTC (rev 121627)
+++ trunk/Source/WebCore/platform/graphics/chromium/LinkHighlight.h 2012-06-30 15:55:54 UTC (rev 121628)
@@ -45,7 +45,7 @@
ContentLayerChromium* contentLayer();
// ContentLayerDelegate implementation.
- virtual void paintContents(SkCanvas*, const IntRect& clipRect, IntRect& opaque) OVERRIDE;
+ virtual void paintContents(SkCanvas*, const IntRect& clipRect, FloatRect& opaque) OVERRIDE;
// CCLayerAnimationDelegate implementation.
virtual void notifyAnimationStarted(double time) OVERRIDE;
Modified: trunk/Source/WebCore/platform/graphics/chromium/OpaqueRectTrackingContentLayerDelegate.cpp (121627 => 121628)
--- trunk/Source/WebCore/platform/graphics/chromium/OpaqueRectTrackingContentLayerDelegate.cpp 2012-06-30 12:09:15 UTC (rev 121627)
+++ trunk/Source/WebCore/platform/graphics/chromium/OpaqueRectTrackingContentLayerDelegate.cpp 2012-06-30 15:55:54 UTC (rev 121628)
@@ -31,8 +31,10 @@
#include "GraphicsContext.h"
#include "IntRect.h"
#include "PlatformContextSkia.h"
+#include <public/WebFloatRect.h>
#include <public/WebRect.h>
+using WebKit::WebFloatRect;
using WebKit::WebRect;
namespace WebCore {
@@ -47,7 +49,7 @@
{
}
-void OpaqueRectTrackingContentLayerDelegate::paintContents(SkCanvas* canvas, const WebRect& clip, WebRect& opaque)
+void OpaqueRectTrackingContentLayerDelegate::paintContents(SkCanvas* canvas, const WebRect& clip, WebFloatRect& opaque)
{
PlatformContextSkia platformContext(canvas);
platformContext.setTrackOpaqueRegion(!m_opaque);
@@ -62,8 +64,7 @@
// Transform tracked opaque paints back to our layer's content space.
ASSERT(canvasToContentTransform.isInvertible());
ASSERT(canvasToContentTransform.preservesAxisAlignment());
- FloatRect opaqueCanvasRect = platformContext.opaqueRegion().asRect();
- opaque = enclosedIntRect(canvasToContentTransform.mapRect(opaqueCanvasRect));
+ opaque = canvasToContentTransform.mapRect(platformContext.opaqueRegion().asRect());
}
}
Modified: trunk/Source/WebCore/platform/graphics/chromium/OpaqueRectTrackingContentLayerDelegate.h (121627 => 121628)
--- trunk/Source/WebCore/platform/graphics/chromium/OpaqueRectTrackingContentLayerDelegate.h 2012-06-30 12:09:15 UTC (rev 121627)
+++ trunk/Source/WebCore/platform/graphics/chromium/OpaqueRectTrackingContentLayerDelegate.h 2012-06-30 15:55:54 UTC (rev 121628)
@@ -55,7 +55,7 @@
void setOpaque(bool opaque) { m_opaque = opaque; }
// WebKit::WebContentLayerClient implementation.
- virtual void paintContents(SkCanvas*, const WebKit::WebRect& clip, WebKit::WebRect& opaque) OVERRIDE;
+ virtual void paintContents(SkCanvas*, const WebKit::WebRect& clip, WebKit::WebFloatRect& opaque) OVERRIDE;
private:
GraphicsContextPainter* m_painter;
Modified: trunk/Source/WebCore/platform/graphics/chromium/ScrollbarLayerChromium.cpp (121627 => 121628)
--- trunk/Source/WebCore/platform/graphics/chromium/ScrollbarLayerChromium.cpp 2012-06-30 12:09:15 UTC (rev 121627)
+++ trunk/Source/WebCore/platform/graphics/chromium/ScrollbarLayerChromium.cpp 2012-06-30 15:55:54 UTC (rev 121628)
@@ -116,7 +116,7 @@
return adoptPtr(new ScrollbarBackgroundPainter(scrollbar, theme, trackPart));
}
- virtual void paint(SkCanvas* canvas, const IntRect& contentRect, IntRect&) OVERRIDE
+ virtual void paint(SkCanvas* canvas, const IntRect& contentRect, FloatRect&) OVERRIDE
{
PlatformContextSkia platformContext(canvas);
platformContext.setDrawingToImageBuffer(true);
@@ -169,7 +169,7 @@
return adoptPtr(new ScrollbarThumbPainter(scrollbar, theme));
}
- virtual void paint(SkCanvas* canvas, const IntRect& contentRect, IntRect& opaque) OVERRIDE
+ virtual void paint(SkCanvas* canvas, const IntRect& contentRect, FloatRect& opaque) OVERRIDE
{
PlatformContextSkia platformContext(canvas);
platformContext.setDrawingToImageBuffer(true);
Modified: trunk/Source/WebKit/chromium/ChangeLog (121627 => 121628)
--- trunk/Source/WebKit/chromium/ChangeLog 2012-06-30 12:09:15 UTC (rev 121627)
+++ trunk/Source/WebKit/chromium/ChangeLog 2012-06-30 15:55:54 UTC (rev 121628)
@@ -1,3 +1,39 @@
+2012-06-30 Ian Vollick <[email protected]>
+
+ [chromium] CanvasLayerTextureUpdater needs to convert opaque rects back to content space.
+ https://bugs.webkit.org/show_bug.cgi?id=90092
+
+ The CanvasLayerTextureUpdater currently receives its opaque rects in
+ layer space, but is expected to return them in content space and does
+ not convert them. This patch adds this conversion. To avoid numerical
+ errors, this patch also switches to using float rects to store opaque
+ rects where appropriate.
+
+ Reviewed by Adrienne Walker.
+
+ * WebKit.gypi:
+ * src/WebContentLayerImpl.cpp:
+ (WebKit::WebContentLayerImpl::paintContents):
+ * src/WebContentLayerImpl.h:
+ (WebContentLayerImpl):
+ * tests/CCLayerTreeHostCommonTest.cpp:
+ * tests/CCLayerTreeHostTest.cpp:
+ (WTF::TestOpacityChangeLayerDelegate::paintContents):
+ (WTF::MockContentLayerDelegate::paintContents):
+ * tests/ContentLayerChromiumTest.cpp: Added.
+ (WebKit):
+ (OpaqueRectDrawingGraphicsContextPainter):
+ (WebKit::OpaqueRectDrawingGraphicsContextPainter::OpaqueRectDrawingGraphicsContextPainter):
+ (WebKit::OpaqueRectDrawingGraphicsContextPainter::~OpaqueRectDrawingGraphicsContextPainter):
+ (MockContentLayerDelegate):
+ (WebKit::MockContentLayerDelegate::MockContentLayerDelegate):
+ (WebKit::TEST):
+ * tests/LayerChromiumTest.cpp:
+ * tests/OpaqueRectTrackingContentLayerDelegateTest.cpp:
+ (WebCore::TEST_F):
+ * tests/TiledLayerChromiumTest.cpp:
+ * tests/WebLayerTest.cpp:
+
2012-06-29 Joshua Bell <[email protected]>
IndexedDB: Keep direction on IDBCursor to avoid calls to back end
Modified: trunk/Source/WebKit/chromium/WebKit.gypi (121627 => 121628)
--- trunk/Source/WebKit/chromium/WebKit.gypi 2012-06-30 12:09:15 UTC (rev 121627)
+++ trunk/Source/WebKit/chromium/WebKit.gypi 2012-06-30 15:55:54 UTC (rev 121628)
@@ -97,6 +97,7 @@
'tests/CCTimerTest.cpp',
'tests/ClipboardChromiumTest.cpp',
'tests/CompositorFakeWebGraphicsContext3D.h',
+ 'tests/ContentLayerChromiumTest.cpp',
'tests/DateTimeFormatTest.cpp',
'tests/DecimalTest.cpp',
'tests/DragImageTest.cpp',
Modified: trunk/Source/WebKit/chromium/src/WebContentLayerImpl.cpp (121627 => 121628)
--- trunk/Source/WebKit/chromium/src/WebContentLayerImpl.cpp 2012-06-30 12:09:15 UTC (rev 121627)
+++ trunk/Source/WebKit/chromium/src/WebContentLayerImpl.cpp 2012-06-30 15:55:54 UTC (rev 121628)
@@ -27,6 +27,7 @@
#include "WebContentLayerImpl.h"
#include "platform/WebContentLayerClient.h"
+#include "platform/WebFloatRect.h"
#include "platform/WebRect.h"
#include "GraphicsContext.h"
#include "platform/WebCanvas.h"
@@ -53,11 +54,11 @@
clearDelegate();
}
-void WebContentLayerImpl::paintContents(SkCanvas* canvas, const IntRect& clip, IntRect& opaque)
+void WebContentLayerImpl::paintContents(SkCanvas* canvas, const IntRect& clip, FloatRect& opaque)
{
if (!m_contentClient)
return;
- WebRect webOpaque;
+ WebFloatRect webOpaque;
m_contentClient->paintContents(canvas, WebRect(clip), webOpaque);
opaque = webOpaque;
}
Modified: trunk/Source/WebKit/chromium/src/WebContentLayerImpl.h (121627 => 121628)
--- trunk/Source/WebKit/chromium/src/WebContentLayerImpl.h 2012-06-30 12:09:15 UTC (rev 121627)
+++ trunk/Source/WebKit/chromium/src/WebContentLayerImpl.h 2012-06-30 15:55:54 UTC (rev 121628)
@@ -41,7 +41,7 @@
virtual ~WebContentLayerImpl();
// ContentLayerDelegate implementation.
- virtual void paintContents(SkCanvas*, const WebCore::IntRect& clip, WebCore::IntRect& opaque);
+ virtual void paintContents(SkCanvas*, const WebCore::IntRect& clip, WebCore::FloatRect& opaque) OVERRIDE;
WebContentLayerClient* m_contentClient;
bool m_drawsContent;
Modified: trunk/Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp (121627 => 121628)
--- trunk/Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp 2012-06-30 12:09:15 UTC (rev 121627)
+++ trunk/Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp 2012-06-30 15:55:54 UTC (rev 121628)
@@ -3667,7 +3667,7 @@
public:
MockContentLayerDelegate() { }
virtual ~MockContentLayerDelegate() { }
- virtual void paintContents(SkCanvas*, const IntRect& clip, IntRect& opaque) { }
+ virtual void paintContents(SkCanvas*, const IntRect& clip, FloatRect& opaque) OVERRIDE { }
};
PassRefPtr<ContentLayerChromium> createDrawableContentLayerChromium(ContentLayerDelegate* delegate)
Modified: trunk/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp (121627 => 121628)
--- trunk/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp 2012-06-30 12:09:15 UTC (rev 121627)
+++ trunk/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp 2012-06-30 15:55:54 UTC (rev 121628)
@@ -1142,7 +1142,7 @@
{
}
- virtual void paintContents(SkCanvas*, const IntRect&, IntRect&)
+ virtual void paintContents(SkCanvas*, const IntRect&, FloatRect&) OVERRIDE
{
// Set layer opacity to 0.
m_test->layerTreeHost()->rootLayer()->setOpacity(0);
@@ -1236,7 +1236,7 @@
public:
bool drawsContent() const { return true; }
MOCK_CONST_METHOD0(preserves3D, bool());
- void paintContents(SkCanvas*, const IntRect&, IntRect&) { }
+ void paintContents(SkCanvas*, const IntRect&, FloatRect&) OVERRIDE { }
void notifySyncRequired() { }
};
Added: trunk/Source/WebKit/chromium/tests/ContentLayerChromiumTest.cpp (0 => 121628)
--- trunk/Source/WebKit/chromium/tests/ContentLayerChromiumTest.cpp (rev 0)
+++ trunk/Source/WebKit/chromium/tests/ContentLayerChromiumTest.cpp 2012-06-30 15:55:54 UTC (rev 121628)
@@ -0,0 +1,110 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#include "ContentLayerChromium.h"
+
+#include "BitmapCanvasLayerTextureUpdater.h"
+#include "CCLayerTreeTestCommon.h"
+#include "GraphicsContext.h"
+#include "OpaqueRectTrackingContentLayerDelegate.h"
+#include "skia/ext/platform_canvas.h"
+
+#include <gtest/gtest.h>
+#include <public/WebFloatRect.h>
+#include <public/WebRect.h>
+#include <wtf/OwnPtr.h>
+#include <wtf/RefPtr.h>
+
+using namespace WebCore;
+using namespace WebKit;
+
+namespace {
+
+class OpaqueRectDrawingGraphicsContextPainter : public GraphicsContextPainter {
+public:
+ explicit OpaqueRectDrawingGraphicsContextPainter(const IntRect& opaqueRect, const IntRect& contentRect)
+ : m_opaqueRect(opaqueRect)
+ , m_contentRect(contentRect)
+ {
+ }
+
+ virtual ~OpaqueRectDrawingGraphicsContextPainter()
+ {
+ }
+
+ virtual void paint(GraphicsContext& context, const IntRect& clip) OVERRIDE
+ {
+ Color alpha(0, 0, 0, 0);
+ context.fillRect(m_contentRect, alpha, ColorSpaceDeviceRGB);
+
+ Color white(255, 255, 255, 255);
+ context.fillRect(m_opaqueRect, white, ColorSpaceDeviceRGB);
+ }
+
+private:
+ IntRect m_opaqueRect;
+ IntRect m_contentRect;
+};
+
+class MockContentLayerDelegate : public ContentLayerDelegate {
+public:
+ explicit MockContentLayerDelegate(OpaqueRectTrackingContentLayerDelegate* client)
+ : m_client(client)
+ {
+ }
+
+ virtual void paintContents(SkCanvas* canvas, const IntRect& clip, FloatRect& opaque) OVERRIDE
+ {
+ WebFloatRect resultingOpaqueRect(opaque.x(), opaque.y(), opaque.width(), opaque.height());
+ WebRect webClipRect(clip.x(), clip.y(), clip.width(), clip.height());
+ m_client->paintContents(canvas, webClipRect, resultingOpaqueRect);
+ opaque = FloatRect(resultingOpaqueRect.x, resultingOpaqueRect.y, resultingOpaqueRect.width, resultingOpaqueRect.height);
+ }
+
+private:
+ OpaqueRectTrackingContentLayerDelegate* m_client;
+};
+
+TEST(ContentLayerChromiumTest, ContentLayerPainterWithDeviceScale)
+{
+ float contentsScale = 2;
+ IntRect contentRect(10, 10, 100, 100);
+ IntRect opaqueRectInLayerSpace(5, 5, 20, 20);
+ IntRect opaqueRectInContentSpace = opaqueRectInLayerSpace;
+ opaqueRectInContentSpace.scale(contentsScale);
+ OwnPtr<SkCanvas> canvas = adoptPtr(skia::CreateBitmapCanvas(contentRect.width(), contentRect.height(), false));
+ OpaqueRectDrawingGraphicsContextPainter painter(opaqueRectInLayerSpace, contentRect);
+ OpaqueRectTrackingContentLayerDelegate opaqueRectTrackingContentLayerDelegate(&painter);
+ MockContentLayerDelegate delegate(&opaqueRectTrackingContentLayerDelegate);
+ RefPtr<BitmapCanvasLayerTextureUpdater> updater = BitmapCanvasLayerTextureUpdater::create(ContentLayerPainter::create(&delegate), false);
+
+ IntRect resultingOpaqueRect;
+ updater->prepareToUpdate(contentRect, IntSize(256, 256), contentsScale, contentsScale, resultingOpaqueRect);
+
+ EXPECT_INT_RECT_EQ(opaqueRectInContentSpace, resultingOpaqueRect);
+}
+
+} // namespace
Modified: trunk/Source/WebKit/chromium/tests/LayerChromiumTest.cpp (121627 => 121628)
--- trunk/Source/WebKit/chromium/tests/LayerChromiumTest.cpp 2012-06-30 12:09:15 UTC (rev 121627)
+++ trunk/Source/WebKit/chromium/tests/LayerChromiumTest.cpp 2012-06-30 15:55:54 UTC (rev 121628)
@@ -70,7 +70,7 @@
class MockLayerPainterChromium : public LayerPainterChromium {
public:
- virtual void paint(SkCanvas*, const IntRect&, IntRect&) { }
+ virtual void paint(SkCanvas*, const IntRect&, FloatRect&) OVERRIDE { }
};
Modified: trunk/Source/WebKit/chromium/tests/OpaqueRectTrackingContentLayerDelegateTest.cpp (121627 => 121628)
--- trunk/Source/WebKit/chromium/tests/OpaqueRectTrackingContentLayerDelegateTest.cpp 2012-06-30 12:09:15 UTC (rev 121627)
+++ trunk/Source/WebKit/chromium/tests/OpaqueRectTrackingContentLayerDelegateTest.cpp 2012-06-30 15:55:54 UTC (rev 121628)
@@ -30,11 +30,13 @@
#include "GraphicsContext.h"
#include "IntRect.h"
#include "skia/ext/platform_canvas.h"
+#include <public/WebFloatRect.h>
#include <public/WebRect.h>
#include <gtest/gtest.h>
using WebKit::WebRect;
+using WebKit::WebFloatRect;
using namespace WebCore;
namespace {
@@ -125,9 +127,9 @@
OpaqueRectTrackingContentLayerDelegate delegate(&painter);
- WebRect opaqueRect;
+ WebFloatRect opaqueRect;
delegate.paintContents(skCanvas(), canvasRect(), opaqueRect);
- EXPECT_EQ_RECT(WebRect(0, 0, 400, 400), opaqueRect);
+ EXPECT_EQ_RECT(WebFloatRect(0, 0, 400, 400), opaqueRect);
}
TEST_F(OpaqueRectTrackingContentLayerDelegateTest, testOpaqueRectNotPresentAfterNonOpaquePaint)
@@ -136,9 +138,9 @@
TestLayerPainterChromium painter(fillAlpha);
OpaqueRectTrackingContentLayerDelegate delegate(&painter);
- WebRect opaqueRect;
+ WebFloatRect opaqueRect;
delegate.paintContents(skCanvas(), canvasRect(), opaqueRect);
- EXPECT_EQ_RECT(WebRect(0, 0, 0, 0), opaqueRect);
+ EXPECT_EQ_RECT(WebFloatRect(0, 0, 0, 0), opaqueRect);
}
TEST_F(OpaqueRectTrackingContentLayerDelegateTest, testOpaqueRectNotPresentForOpaqueLayerWithOpaquePaint)
@@ -149,9 +151,9 @@
delegate.setOpaque(true);
- WebRect opaqueRect;
+ WebFloatRect opaqueRect;
delegate.paintContents(skCanvas(), canvasRect(), opaqueRect);
- EXPECT_EQ_RECT(WebRect(0, 0, 0, 0), opaqueRect);
+ EXPECT_EQ_RECT(WebFloatRect(0, 0, 0, 0), opaqueRect);
}
TEST_F(OpaqueRectTrackingContentLayerDelegateTest, testOpaqueRectNotPresentForOpaqueLayerWithNonOpaquePaint)
@@ -162,9 +164,9 @@
delegate.setOpaque(true);
- WebRect opaqueRect;
+ WebFloatRect opaqueRect;
delegate.paintContents(skCanvas(), canvasRect(), opaqueRect);
- EXPECT_EQ_RECT(WebRect(0, 0, 0, 0), opaqueRect);
+ EXPECT_EQ_RECT(WebFloatRect(0, 0, 0, 0), opaqueRect);
}
TEST_F(OpaqueRectTrackingContentLayerDelegateTest, testPartialOpaqueRectNoTransform)
@@ -174,9 +176,9 @@
TestLayerPainterChromium painter(fillPartial);
OpaqueRectTrackingContentLayerDelegate delegate(&painter);
- WebRect opaqueRect;
+ WebFloatRect opaqueRect;
delegate.paintContents(skCanvas(), canvasRect(), opaqueRect);
- EXPECT_EQ_RECT(WebRect(partialRect.x(), partialRect.y(), partialRect.width(), partialRect.height()), opaqueRect);
+ EXPECT_EQ_RECT(WebFloatRect(partialRect.x(), partialRect.y(), partialRect.width(), partialRect.height()), opaqueRect);
}
TEST_F(OpaqueRectTrackingContentLayerDelegateTest, testPartialOpaqueRectTranslation)
@@ -186,10 +188,10 @@
TestLayerPainterChromium painter(fillPartial);
OpaqueRectTrackingContentLayerDelegate delegate(&painter);
- WebRect opaqueRect;
+ WebFloatRect opaqueRect;
WebRect contentRect(11, 12, 389, 388);
delegate.paintContents(skCanvas(), contentRect, opaqueRect);
- EXPECT_EQ_RECT(WebRect(partialRect.x(), partialRect.y(), partialRect.width(), partialRect.height()), opaqueRect);
+ EXPECT_EQ_RECT(WebFloatRect(partialRect.x(), partialRect.y(), partialRect.width(), partialRect.height()), opaqueRect);
}
} // namespace
Modified: trunk/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp (121627 => 121628)
--- trunk/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp 2012-06-30 12:09:15 UTC (rev 121627)
+++ trunk/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp 2012-06-30 15:55:54 UTC (rev 121628)
@@ -1505,7 +1505,7 @@
public:
static PassOwnPtr<TrackingLayerPainter> create() { return adoptPtr(new TrackingLayerPainter()); }
- virtual void paint(SkCanvas*, const IntRect& contentRect, IntRect&)
+ virtual void paint(SkCanvas*, const IntRect& contentRect, FloatRect&) OVERRIDE
{
m_paintedRect = contentRect;
}
Modified: trunk/Source/WebKit/chromium/tests/WebLayerTest.cpp (121627 => 121628)
--- trunk/Source/WebKit/chromium/tests/WebLayerTest.cpp 2012-06-30 12:09:15 UTC (rev 121627)
+++ trunk/Source/WebKit/chromium/tests/WebLayerTest.cpp 2012-06-30 15:55:54 UTC (rev 121628)
@@ -65,7 +65,7 @@
class MockWebContentLayerClient : public WebContentLayerClient {
public:
- MOCK_METHOD3(paintContents, void(WebCanvas*, const WebRect& clip, WebRect& opaque));
+ MOCK_METHOD3(paintContents, void(WebCanvas*, const WebRect& clip, WebFloatRect& opaque));
};
class WebLayerTest : public Test {