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