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.
Patch by Ian Vollick <vollick@chromium.org> on 2012-06-30
Reviewed by Adrienne Walker.
Source/Platform:
* chromium/public/WebContentLayerClient.h:
(WebKit):
(WebContentLayerClient):
Source/WebCore:
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:
Source/WebKit/chromium:
* 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:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@121628
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2012-06-30 Ian Vollick <vollick@chromium.org>
+
+ [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 <tpayne@chromium.org>
Remove type from screenColorProfile API
namespace WebKit {
struct WebRect;
+struct WebFloatRect;
class WebContentLayerClient {
public:
// 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() { }
+2012-06-30 Ian Vollick <vollick@chromium.org>
+
+ [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 <skyul@company100.net>
Unreviewed. Remove unused declaration.
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;
}
namespace WebCore {
-class ContentLayerPainter : public LayerPainterChromium {
- WTF_MAKE_NONCOPYABLE(ContentLayerPainter);
-public:
- static PassOwnPtr<ContentLayerPainter> create(ContentLayerDelegate* delegate)
- {
- return adoptPtr(new ContentLayerPainter(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)
- {
- }
-
- ContentLayerDelegate* m_delegate;
-};
+ContentLayerPainter::ContentLayerPainter(ContentLayerDelegate* delegate)
+ : m_delegate(delegate)
+{
+}
+
+PassOwnPtr<ContentLayerPainter> ContentLayerPainter::create(ContentLayerDelegate* delegate)
+{
+ return adoptPtr(new ContentLayerPainter(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)
{
#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:
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
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);
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;
#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 {
{
}
-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);
// 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());
}
}
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;
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);
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);
+2012-06-30 Ian Vollick <vollick@chromium.org>
+
+ [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 <jsbell@chromium.org>
IndexedDB: Keep direction on IDBCursor to avoid calls to back end
'tests/CCTimerTest.cpp',
'tests/ClipboardChromiumTest.cpp',
'tests/CompositorFakeWebGraphicsContext3D.h',
+ 'tests/ContentLayerChromiumTest.cpp',
'tests/DateTimeFormatTest.cpp',
'tests/DecimalTest.cpp',
'tests/DragImageTest.cpp',
#include "WebContentLayerImpl.h"
#include "platform/WebContentLayerClient.h"
+#include "platform/WebFloatRect.h"
#include "platform/WebRect.h"
#include "GraphicsContext.h"
#include "platform/WebCanvas.h"
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;
}
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;
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)
{
}
- 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);
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() { }
};
--- /dev/null
+/*
+ * 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
class MockLayerPainterChromium : public LayerPainterChromium {
public:
- virtual void paint(SkCanvas*, const IntRect&, IntRect&) { }
+ virtual void paint(SkCanvas*, const IntRect&, FloatRect&) OVERRIDE { }
};
#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 {
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)
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)
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)
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)
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)
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
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;
}
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 {