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

Side by Side Diff: cc/DecorationLayerChromiumTest.cpp

Issue 10963056: [cc] Add window decoration layers (NinePatch) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: hacky rebase for Jerome to use 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/DecorationLayerChromium.cpp ('k') | cc/cc.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 "DecorationLayerChromium.h"
8
9 #include "CCLayerTreeHost.h"
10 #include "CCOcclusionTracker.h"
11 #include "CCOverdrawMetrics.h"
12 #include "CCRenderingStats.h"
13 #include "CCResourceProvider.h"
14 #include "CCSingleThreadProxy.h"
15 #include "CCTextureUpdateQueue.h"
16 #include "FakeCCGraphicsContext.h"
17 #include "FakeCCLayerTreeHostClient.h"
18 #include "SkBitmap.h"
19 #include "WebCompositorInitializer.h"
20 #include "testing/gmock/include/gmock/gmock.h"
21 #include "testing/gtest/include/gtest/gtest.h"
22
23 using namespace cc;
24 using ::testing::Mock;
25 using ::testing::_;
26 using ::testing::AtLeast;
27 using ::testing::AnyNumber;
28
29 namespace {
30
31 class MockCCLayerTreeHost : public CCLayerTreeHost {
32 public:
33 MockCCLayerTreeHost()
34 : CCLayerTreeHost(&m_fakeClient, CCLayerTreeSettings())
35 {
36 initialize();
37 }
38
39 private:
40 FakeCCLayerTreeHostClient m_fakeClient;
41 };
42
43
44 class DecorationLayerChromiumTest : public testing::Test {
45 public:
46 DecorationLayerChromiumTest()
47 : m_compositorInitializer(0)
48 {
49 }
50
51 protected:
52 virtual void SetUp()
53 {
54 m_layerTreeHost = adoptPtr(new MockCCLayerTreeHost);
55 }
56
57 virtual void TearDown()
58 {
59 Mock::VerifyAndClearExpectations(m_layerTreeHost.get());
60
61 m_layerTreeHost->setRootLayer(0);
62 m_layerTreeHost.clear();
63 }
64
65 OwnPtr<MockCCLayerTreeHost> m_layerTreeHost;
66 private:
67 WebKitTests::WebCompositorInitializer m_compositorInitializer;
68 };
69
70 TEST_F(DecorationLayerChromiumTest, triggerFullUploadOnceWhenChangingBitmap)
71 {
72 scoped_refptr<DecorationLayerChromium> testLayer = DecorationLayerChromium:: create();
73 ASSERT_TRUE(testLayer);
74 testLayer->setIsDrawable(true);
75 testLayer->setBounds(IntSize(100, 100));
76
77 m_layerTreeHost->setRootLayer(testLayer);
78 Mock::VerifyAndClearExpectations(m_layerTreeHost.get());
79 EXPECT_EQ(testLayer->layerTreeHost(), m_layerTreeHost.get());
80
81 m_layerTreeHost->initializeRendererIfNeeded();
82
83 CCPriorityCalculator calculator;
84 CCTextureUpdateQueue queue;
85 CCOcclusionTracker occlusionTracker(IntRect(), false);
86 CCRenderingStats stats;
87
88 // No bitmap set should not trigger any uploads.
89 testLayer->setTexturePriorities(calculator);
90 testLayer->update(queue, &occlusionTracker, stats);
91 EXPECT_EQ(queue.fullUploadSize(), 0);
92 EXPECT_EQ(queue.partialUploadSize(), 0);
93
94 // Setting a bitmap set should trigger a single full upload.
95 SkBitmap bitmap;
96 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 10, 10);
97 bitmap.allocPixels();
98 testLayer->setBitmap(bitmap, IntRect(5, 5, 1, 1));
99 testLayer->setTexturePriorities(calculator);
100 testLayer->update(queue, &occlusionTracker, stats);
101 EXPECT_EQ(queue.fullUploadSize(), 1);
102 EXPECT_EQ(queue.partialUploadSize(), 0);
103 TextureUploader::Parameters params = queue.takeFirstFullUpload();
104 EXPECT_TRUE(params.texture != NULL);
105
106 // Upload the texture.
107 m_layerTreeHost->contentsTextureManager()->setMaxMemoryLimitBytes(1024 * 102 4);
108 m_layerTreeHost->contentsTextureManager()->prioritizeTextures();
109
110 // Hack: Create a ResourceProvider here, because we cannot get to the one
111 // owned by the CCLayerTreeHostImpl.
112 CCProxy::setCurrentThreadIsImplThread(true);
113 CCProxy::setMainThreadBlocked(true);
114 scoped_ptr<CCGraphicsContext> context(WebKit::createFakeCCGraphicsContext()) ;
115 OwnPtr<CCResourceProvider> resourceProvider(CCResourceProvider::create(conte xt.get()));
116 params.texture->texture()->acquireBackingTexture(resourceProvider.get());
117 ASSERT_TRUE(params.texture->texture()->haveBackingTexture());
118 CCProxy::setCurrentThreadIsImplThread(false);
119 CCProxy::setMainThreadBlocked(false);
120
121 // Nothing changed, so no repeated upload.
122 testLayer->setTexturePriorities(calculator);
123 testLayer->update(queue, &occlusionTracker, stats);
124 EXPECT_EQ(queue.fullUploadSize(), 0);
125 EXPECT_EQ(queue.partialUploadSize(), 0);
126
127 {
128 DebugScopedSetImplThread implThread;
129 DebugScopedSetMainThreadBlocked mainThreadBlocked;
130 m_layerTreeHost->contentsTextureManager()->clearAllMemory(resourceProvid er.get());
131 }
132
133 // Reupload after eviction
134 testLayer->setTexturePriorities(calculator);
135 testLayer->update(queue, &occlusionTracker, stats);
136 EXPECT_EQ(queue.fullUploadSize(), 1);
137 EXPECT_EQ(queue.partialUploadSize(), 0);
138 }
139
140 } // anonymous namespace
OLDNEW
« no previous file with comments | « cc/DecorationLayerChromium.cpp ('k') | cc/cc.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698