| 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 "cc/bitmap_content_layer_updater.h" | 9 #include "cc/bitmap_content_layer_updater.h" |
| 10 #include "cc/content_layer_client.h" | 10 #include "cc/content_layer_client.h" |
| 11 #include "cc/rendering_stats.h" | 11 #include "cc/rendering_stats.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 "ui/gfx/rect_conversions.h" |
| 15 #include <public/WebFloatRect.h> | 16 #include <public/WebFloatRect.h> |
| 16 #include <public/WebRect.h> | 17 #include <public/WebRect.h> |
| 17 | 18 |
| 18 using namespace cc; | 19 using namespace cc; |
| 19 using namespace WebKit; | 20 using namespace WebKit; |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 class MockContentLayerClient : public ContentLayerClient { | 24 class MockContentLayerClient : public ContentLayerClient { |
| 24 public: | 25 public: |
| 25 explicit MockContentLayerClient(IntRect opaqueLayerRect) | 26 explicit MockContentLayerClient(gfx::Rect opaqueLayerRect) |
| 26 : m_opaqueLayerRect(opaqueLayerRect) | 27 : m_opaqueLayerRect(opaqueLayerRect) |
| 27 { | 28 { |
| 28 } | 29 } |
| 29 | 30 |
| 30 virtual void paintContents(SkCanvas*, const IntRect&, FloatRect& opaque) OVE
RRIDE | 31 virtual void paintContents(SkCanvas*, const gfx::Rect&, gfx::RectF& opaque)
OVERRIDE |
| 31 { | 32 { |
| 32 opaque = FloatRect(m_opaqueLayerRect); | 33 opaque = gfx::RectF(m_opaqueLayerRect); |
| 33 } | 34 } |
| 34 | 35 |
| 35 private: | 36 private: |
| 36 IntRect m_opaqueLayerRect; | 37 gfx::Rect m_opaqueLayerRect; |
| 37 }; | 38 }; |
| 38 | 39 |
| 39 TEST(ContentLayerTest, ContentLayerPainterWithDeviceScale) | 40 TEST(ContentLayerTest, ContentLayerPainterWithDeviceScale) |
| 40 { | 41 { |
| 41 float contentsScale = 2; | 42 float contentsScale = 2; |
| 42 IntRect contentRect(10, 10, 100, 100); | 43 gfx::Rect contentRect(10, 10, 100, 100); |
| 43 IntRect opaqueRectInLayerSpace(5, 5, 20, 20); | 44 gfx::Rect opaqueRectInLayerSpace(5, 5, 20, 20); |
| 44 IntRect opaqueRectInContentSpace = opaqueRectInLayerSpace; | 45 gfx::RectF opaqueRectInContentSpace = gfx::ScaleRect(opaqueRectInLayerSpace,
contentsScale, contentsScale); |
| 45 opaqueRectInContentSpace.scale(contentsScale); | |
| 46 MockContentLayerClient client(opaqueRectInLayerSpace); | 46 MockContentLayerClient client(opaqueRectInLayerSpace); |
| 47 scoped_refptr<BitmapContentLayerUpdater> updater = BitmapContentLayerUpdater
::create(ContentLayerPainter::create(&client).PassAs<LayerPainter>()); | 47 scoped_refptr<BitmapContentLayerUpdater> updater = BitmapContentLayerUpdater
::create(ContentLayerPainter::create(&client).PassAs<LayerPainter>()); |
| 48 | 48 |
| 49 IntRect resultingOpaqueRect; | 49 gfx::Rect resultingOpaqueRect; |
| 50 RenderingStats stats; | 50 RenderingStats stats; |
| 51 updater->prepareToUpdate(contentRect, IntSize(256, 256), contentsScale, cont
entsScale, resultingOpaqueRect, stats); | 51 updater->prepareToUpdate(contentRect, gfx::Size(256, 256), contentsScale, co
ntentsScale, resultingOpaqueRect, stats); |
| 52 | 52 |
| 53 EXPECT_RECT_EQ(opaqueRectInContentSpace, resultingOpaqueRect); | 53 EXPECT_RECT_EQ(gfx::ToEnclosingRect(opaqueRectInContentSpace), resultingOpaq
ueRect); |
| 54 } | 54 } |
| 55 | 55 |
| 56 } // namespace | 56 } // namespace |
| OLD | NEW |