OLD | NEW |
| (Empty) |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "config.h" | |
6 | |
7 #include "ContentLayerChromium.h" | |
8 | |
9 #include "BitmapCanvasLayerTextureUpdater.h" | |
10 #include "CCGeometryTestUtils.h" | |
11 #include "CCRenderingStats.h" | |
12 #include "ContentLayerChromiumClient.h" | |
13 #include "skia/ext/platform_canvas.h" | |
14 #include "testing/gtest/include/gtest/gtest.h" | |
15 #include <public/WebFloatRect.h> | |
16 #include <public/WebRect.h> | |
17 #include <wtf/OwnPtr.h> | |
18 #include <wtf/RefPtr.h> | |
19 | |
20 using namespace cc; | |
21 using namespace WebKit; | |
22 | |
23 namespace { | |
24 | |
25 class MockContentLayerChromiumClient : public ContentLayerChromiumClient { | |
26 public: | |
27 explicit MockContentLayerChromiumClient(IntRect opaqueLayerRect) | |
28 : m_opaqueLayerRect(opaqueLayerRect) | |
29 { | |
30 } | |
31 | |
32 virtual void paintContents(SkCanvas*, const IntRect&, FloatRect& opaque) OVE
RRIDE | |
33 { | |
34 opaque = FloatRect(m_opaqueLayerRect); | |
35 } | |
36 | |
37 private: | |
38 IntRect m_opaqueLayerRect; | |
39 }; | |
40 | |
41 TEST(ContentLayerChromiumTest, ContentLayerPainterWithDeviceScale) | |
42 { | |
43 float contentsScale = 2; | |
44 IntRect contentRect(10, 10, 100, 100); | |
45 IntRect opaqueRectInLayerSpace(5, 5, 20, 20); | |
46 IntRect opaqueRectInContentSpace = opaqueRectInLayerSpace; | |
47 opaqueRectInContentSpace.scale(contentsScale); | |
48 OwnPtr<SkCanvas> canvas = adoptPtr(skia::CreateBitmapCanvas(contentRect.widt
h(), contentRect.height(), false)); | |
49 MockContentLayerChromiumClient client(opaqueRectInLayerSpace); | |
50 RefPtr<BitmapCanvasLayerTextureUpdater> updater = BitmapCanvasLayerTextureUp
dater::create(ContentLayerPainter::create(&client)); | |
51 | |
52 IntRect resultingOpaqueRect; | |
53 CCRenderingStats stats; | |
54 updater->prepareToUpdate(contentRect, IntSize(256, 256), contentsScale, cont
entsScale, resultingOpaqueRect, stats); | |
55 | |
56 EXPECT_RECT_EQ(opaqueRectInContentSpace, resultingOpaqueRect); | |
57 } | |
58 | |
59 } // namespace | |
OLD | NEW |