Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(127)

Side by Side Diff: cc/content_layer_unittest.cc

Issue 11144023: cc: Store tiles, painters, tiling data in scoped_ptr (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/content_layer.cc ('k') | cc/frame_buffer_skpicture_canvas_layer_texture_updater.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "ContentLayerChromium.h" 7 #include "ContentLayerChromium.h"
8 8
9 #include "BitmapCanvasLayerTextureUpdater.h" 9 #include "BitmapCanvasLayerTextureUpdater.h"
10 #include "CCGeometryTestUtils.h" 10 #include "CCGeometryTestUtils.h"
11 #include "CCRenderingStats.h" 11 #include "CCRenderingStats.h"
12 #include "ContentLayerChromiumClient.h" 12 #include "ContentLayerChromiumClient.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 #include <wtf/OwnPtr.h>
18 #include <wtf/RefPtr.h>
19 17
20 using namespace cc; 18 using namespace cc;
21 using namespace WebKit; 19 using namespace WebKit;
22 20
23 namespace { 21 namespace {
24 22
25 class MockContentLayerChromiumClient : public ContentLayerChromiumClient { 23 class MockContentLayerChromiumClient : public ContentLayerChromiumClient {
26 public: 24 public:
27 explicit MockContentLayerChromiumClient(IntRect opaqueLayerRect) 25 explicit MockContentLayerChromiumClient(IntRect opaqueLayerRect)
28 : m_opaqueLayerRect(opaqueLayerRect) 26 : m_opaqueLayerRect(opaqueLayerRect)
29 { 27 {
30 } 28 }
31 29
32 virtual void paintContents(SkCanvas*, const IntRect&, FloatRect& opaque) OVE RRIDE 30 virtual void paintContents(SkCanvas*, const IntRect&, FloatRect& opaque) OVE RRIDE
33 { 31 {
34 opaque = FloatRect(m_opaqueLayerRect); 32 opaque = FloatRect(m_opaqueLayerRect);
35 } 33 }
36 34
37 private: 35 private:
38 IntRect m_opaqueLayerRect; 36 IntRect m_opaqueLayerRect;
39 }; 37 };
40 38
41 TEST(ContentLayerChromiumTest, ContentLayerPainterWithDeviceScale) 39 TEST(ContentLayerChromiumTest, ContentLayerPainterWithDeviceScale)
42 { 40 {
43 float contentsScale = 2; 41 float contentsScale = 2;
44 IntRect contentRect(10, 10, 100, 100); 42 IntRect contentRect(10, 10, 100, 100);
45 IntRect opaqueRectInLayerSpace(5, 5, 20, 20); 43 IntRect opaqueRectInLayerSpace(5, 5, 20, 20);
46 IntRect opaqueRectInContentSpace = opaqueRectInLayerSpace; 44 IntRect opaqueRectInContentSpace = opaqueRectInLayerSpace;
47 opaqueRectInContentSpace.scale(contentsScale); 45 opaqueRectInContentSpace.scale(contentsScale);
48 OwnPtr<SkCanvas> canvas = adoptPtr(skia::CreateBitmapCanvas(contentRect.widt h(), contentRect.height(), false));
49 MockContentLayerChromiumClient client(opaqueRectInLayerSpace); 46 MockContentLayerChromiumClient client(opaqueRectInLayerSpace);
50 RefPtr<BitmapCanvasLayerTextureUpdater> updater = BitmapCanvasLayerTextureUp dater::create(ContentLayerPainter::create(&client)); 47 RefPtr<BitmapCanvasLayerTextureUpdater> updater = BitmapCanvasLayerTextureUp dater::create(ContentLayerPainter::create(&client).PassAs<LayerPainterChromium>( ));
51 48
52 IntRect resultingOpaqueRect; 49 IntRect resultingOpaqueRect;
53 CCRenderingStats stats; 50 CCRenderingStats stats;
54 updater->prepareToUpdate(contentRect, IntSize(256, 256), contentsScale, cont entsScale, resultingOpaqueRect, stats); 51 updater->prepareToUpdate(contentRect, IntSize(256, 256), contentsScale, cont entsScale, resultingOpaqueRect, stats);
55 52
56 EXPECT_RECT_EQ(opaqueRectInContentSpace, resultingOpaqueRect); 53 EXPECT_RECT_EQ(opaqueRectInContentSpace, resultingOpaqueRect);
57 } 54 }
58 55
59 } // namespace 56 } // namespace
OLDNEW
« no previous file with comments | « cc/content_layer.cc ('k') | cc/frame_buffer_skpicture_canvas_layer_texture_updater.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698