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

Side by Side Diff: cc/layers/tiled_layer_unittest.cc

Issue 812543002: Update from https://crrev.com/308331 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « cc/layers/tiled_layer_impl.cc ('k') | cc/output/delegating_renderer_unittest.cc » ('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 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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 "cc/layers/tiled_layer.h" 5 #include "cc/layers/tiled_layer.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 27 matching lines...) Expand all
38 38
39 void SetRenderTarget(Layer* render_target) { 39 void SetRenderTarget(Layer* render_target) {
40 stack_.back().target = render_target; 40 stack_.back().target = render_target;
41 } 41 }
42 42
43 void SetOcclusion(const SimpleEnclosedRegion& occlusion) { 43 void SetOcclusion(const SimpleEnclosedRegion& occlusion) {
44 stack_.back().occlusion_from_inside_target = occlusion; 44 stack_.back().occlusion_from_inside_target = occlusion;
45 } 45 }
46 }; 46 };
47 47
48 class SynchronousOutputSurfaceLayerTreeHost : public LayerTreeHost { 48 class SynchronousOutputSurfaceClient : public FakeLayerTreeHostClient {
49 public: 49 public:
50 static scoped_ptr<SynchronousOutputSurfaceLayerTreeHost> Create( 50 SynchronousOutputSurfaceClient()
51 LayerTreeHostClient* client, 51 : FakeLayerTreeHostClient(FakeLayerTreeHostClient::DIRECT_3D) {}
52 SharedBitmapManager* manager,
53 const LayerTreeSettings& settings,
54 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) {
55 return make_scoped_ptr(new SynchronousOutputSurfaceLayerTreeHost(
56 client, manager, settings, impl_task_runner));
57 }
58
59 ~SynchronousOutputSurfaceLayerTreeHost() override {}
60 52
61 bool EnsureOutputSurfaceCreated() { 53 bool EnsureOutputSurfaceCreated() {
62 base::MessageLoop::current()->PostDelayedTask( 54 base::MessageLoop::current()->PostDelayedTask(
63 FROM_HERE, 55 FROM_HERE,
64 run_loop_.QuitClosure(), 56 run_loop_.QuitClosure(),
65 base::TimeDelta::FromSeconds(5)); 57 base::TimeDelta::FromSeconds(5));
66 run_loop_.Run(); 58 run_loop_.Run();
67 return output_surface_created_; 59 return output_surface_created_;
68 } 60 }
69 61
70 void OnCreateAndInitializeOutputSurfaceAttempted(bool success) override { 62 void DidInitializeOutputSurface() override {
71 LayerTreeHost::OnCreateAndInitializeOutputSurfaceAttempted(success); 63 FakeLayerTreeHostClient::DidInitializeOutputSurface();
72 output_surface_created_ = success; 64 output_surface_created_ = true;
65 run_loop_.Quit();
66 }
67
68 void DidFailToInitializeOutputSurface() override {
69 FakeLayerTreeHostClient::DidFailToInitializeOutputSurface();
70 output_surface_created_ = false;
73 run_loop_.Quit(); 71 run_loop_.Quit();
74 } 72 }
75 73
76 private: 74 private:
77 SynchronousOutputSurfaceLayerTreeHost(
78 LayerTreeHostClient* client,
79 SharedBitmapManager* manager,
80 const LayerTreeSettings& settings,
81 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner)
82 : LayerTreeHost(client, manager, NULL, settings),
83 output_surface_created_(false) {
84 LayerTreeHost::InitializeThreaded(base::MessageLoopProxy::current(),
85 impl_task_runner,
86 nullptr);
87 }
88
89 bool output_surface_created_; 75 bool output_surface_created_;
90 base::RunLoop run_loop_; 76 base::RunLoop run_loop_;
91 }; 77 };
92 78
93 class TiledLayerTest : public testing::Test { 79 class TiledLayerTest : public testing::Test {
94 public: 80 public:
95 TiledLayerTest() 81 TiledLayerTest()
96 : proxy_(nullptr), 82 : proxy_(nullptr),
97 output_surface_(FakeOutputSurface::Create3d()), 83 output_surface_(FakeOutputSurface::Create3d()),
98 queue_(make_scoped_ptr(new ResourceUpdateQueue)), 84 queue_(make_scoped_ptr(new ResourceUpdateQueue)),
99 impl_thread_("ImplThread"), 85 impl_thread_("ImplThread"),
100 fake_layer_tree_host_client_(FakeLayerTreeHostClient::DIRECT_3D),
101 occlusion_(nullptr) { 86 occlusion_(nullptr) {
102 settings_.max_partial_texture_updates = std::numeric_limits<size_t>::max(); 87 settings_.max_partial_texture_updates = std::numeric_limits<size_t>::max();
103 settings_.layer_transforms_should_scale_layer_contents = true; 88 settings_.layer_transforms_should_scale_layer_contents = true;
104 } 89 }
105 90
106 void SetUp() override { 91 void SetUp() override {
107 impl_thread_.Start(); 92 impl_thread_.Start();
108 shared_bitmap_manager_.reset(new TestSharedBitmapManager()); 93 shared_bitmap_manager_.reset(new TestSharedBitmapManager());
109 layer_tree_host_ = SynchronousOutputSurfaceLayerTreeHost::Create( 94 layer_tree_host_ = LayerTreeHost::CreateThreaded(
110 &fake_layer_tree_host_client_, 95 &synchonous_output_surface_client_, shared_bitmap_manager_.get(),
111 shared_bitmap_manager_.get(), 96 nullptr, settings_, base::MessageLoopProxy::current(),
112 settings_, 97 impl_thread_.message_loop_proxy(), nullptr);
113 impl_thread_.message_loop_proxy()); 98 synchonous_output_surface_client_.SetLayerTreeHost(layer_tree_host_.get());
114 fake_layer_tree_host_client_.SetLayerTreeHost(layer_tree_host_.get());
115 proxy_ = layer_tree_host_->proxy(); 99 proxy_ = layer_tree_host_->proxy();
116 resource_manager_ = PrioritizedResourceManager::Create(proxy_); 100 resource_manager_ = PrioritizedResourceManager::Create(proxy_);
117 layer_tree_host_->SetLayerTreeHostClientReady(); 101 layer_tree_host_->SetLayerTreeHostClientReady();
118 CHECK(layer_tree_host_->EnsureOutputSurfaceCreated()); 102 CHECK(synchonous_output_surface_client_.EnsureOutputSurfaceCreated());
103
119 layer_tree_host_->SetRootLayer(Layer::Create()); 104 layer_tree_host_->SetRootLayer(Layer::Create());
120 105
121 CHECK(output_surface_->BindToClient(&output_surface_client_)); 106 CHECK(output_surface_->BindToClient(&output_surface_client_));
122 107
123 DebugScopedSetImplThreadAndMainThreadBlocked 108 DebugScopedSetImplThreadAndMainThreadBlocked
124 impl_thread_and_main_thread_blocked(proxy_); 109 impl_thread_and_main_thread_blocked(proxy_);
125 resource_provider_ = ResourceProvider::Create(output_surface_.get(), 110 resource_provider_ = ResourceProvider::Create(output_surface_.get(),
126 shared_bitmap_manager_.get(), 111 shared_bitmap_manager_.get(),
127 nullptr, 112 nullptr,
128 nullptr, 113 nullptr,
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 public: 231 public:
247 Proxy* proxy_; 232 Proxy* proxy_;
248 LayerTreeSettings settings_; 233 LayerTreeSettings settings_;
249 FakeOutputSurfaceClient output_surface_client_; 234 FakeOutputSurfaceClient output_surface_client_;
250 scoped_ptr<OutputSurface> output_surface_; 235 scoped_ptr<OutputSurface> output_surface_;
251 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; 236 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_;
252 scoped_ptr<ResourceProvider> resource_provider_; 237 scoped_ptr<ResourceProvider> resource_provider_;
253 scoped_ptr<ResourceUpdateQueue> queue_; 238 scoped_ptr<ResourceUpdateQueue> queue_;
254 PriorityCalculator priority_calculator_; 239 PriorityCalculator priority_calculator_;
255 base::Thread impl_thread_; 240 base::Thread impl_thread_;
256 FakeLayerTreeHostClient fake_layer_tree_host_client_; 241 SynchronousOutputSurfaceClient synchonous_output_surface_client_;
257 scoped_ptr<SynchronousOutputSurfaceLayerTreeHost> layer_tree_host_; 242 scoped_ptr<LayerTreeHost> layer_tree_host_;
258 scoped_ptr<FakeLayerTreeHostImpl> host_impl_; 243 scoped_ptr<FakeLayerTreeHostImpl> host_impl_;
259 scoped_ptr<PrioritizedResourceManager> resource_manager_; 244 scoped_ptr<PrioritizedResourceManager> resource_manager_;
260 TestOcclusionTracker* occlusion_; 245 TestOcclusionTracker* occlusion_;
261 }; 246 };
262 247
263 TEST_F(TiledLayerTest, PushDirtyTiles) { 248 TEST_F(TiledLayerTest, PushDirtyTiles) {
264 layer_tree_host_->SetViewportSize(gfx::Size(1000, 1000)); 249 layer_tree_host_->SetViewportSize(gfx::Size(1000, 1000));
265 250
266 scoped_refptr<FakeTiledLayer> layer = 251 scoped_refptr<FakeTiledLayer> layer =
267 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); 252 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get()));
(...skipping 1492 matching lines...) Expand 10 before | Expand all | Expand 10 after
1760 1745
1761 // Rounding leads to an extra pixel. 1746 // Rounding leads to an extra pixel.
1762 gfx::Rect expanded_layer_rect(layer_rect); 1747 gfx::Rect expanded_layer_rect(layer_rect);
1763 expanded_layer_rect.set_height(32); 1748 expanded_layer_rect.set_height(32);
1764 EXPECT_EQ(expanded_layer_rect, 1749 EXPECT_EQ(expanded_layer_rect,
1765 layer->tracking_layer_painter()->PaintedRect()); 1750 layer->tracking_layer_painter()->PaintedRect());
1766 } 1751 }
1767 1752
1768 } // namespace 1753 } // namespace
1769 } // namespace cc 1754 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/tiled_layer_impl.cc ('k') | cc/output/delegating_renderer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698