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

Side by Side Diff: cc/trees/layer_tree_host_unittest_damage.cc

Issue 279013002: Remove CompositeAndReadback from LayerTreeHost(Impl) and the Proxys. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rm-cnr-lth-proxy-renderer: rebase-on-drawresult Created 6 years, 7 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/trees/layer_tree_host_unittest_context.cc ('k') | cc/trees/proxy.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 "cc/trees/layer_tree_host.h" 5 #include "cc/trees/layer_tree_host.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/message_loop/message_loop_proxy.h" 10 #include "base/message_loop/message_loop_proxy.h"
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 FakeContentLayerClient client_; 233 FakeContentLayerClient client_;
234 scoped_refptr<FakeContentLayer> content_; 234 scoped_refptr<FakeContentLayer> content_;
235 int expect_swap_and_succeed_; 235 int expect_swap_and_succeed_;
236 int did_swaps_; 236 int did_swaps_;
237 int did_swap_and_succeed_; 237 int did_swap_and_succeed_;
238 }; 238 };
239 239
240 SINGLE_AND_MULTI_THREAD_NOIMPL_TEST_F( 240 SINGLE_AND_MULTI_THREAD_NOIMPL_TEST_F(
241 LayerTreeHostDamageTestNoDamageDoesNotSwap); 241 LayerTreeHostDamageTestNoDamageDoesNotSwap);
242 242
243 class LayerTreeHostDamageTestNoDamageReadbackDoesDraw
244 : public LayerTreeHostDamageTest {
245 virtual void BeginTest() OVERRIDE {
246 PostSetNeedsCommitToMainThread();
247 }
248
249 virtual void SetupTree() OVERRIDE {
250 scoped_refptr<FakeContentLayer> root = FakeContentLayer::Create(&client_);
251 root->SetBounds(gfx::Size(10, 10));
252
253 // Most of the layer isn't visible.
254 content_ = FakeContentLayer::Create(&client_);
255 content_->SetBounds(gfx::Size(100, 100));
256 root->AddChild(content_);
257
258 layer_tree_host()->SetRootLayer(root);
259 LayerTreeHostDamageTest::SetupTree();
260 }
261
262 virtual DrawResult PrepareToDrawOnThread(
263 LayerTreeHostImpl* host_impl,
264 LayerTreeHostImpl::FrameData* frame_data,
265 DrawResult draw_result) OVERRIDE {
266 EXPECT_EQ(DRAW_SUCCESS, draw_result);
267
268 int source_frame = host_impl->active_tree()->source_frame_number();
269 switch (source_frame) {
270 case 0:
271 // The first frame draws and clears any damage.
272 break;
273 case 1: {
274 // The second frame is a readback, we should have damage in the readback
275 // rect, but not swap.
276 RenderSurfaceImpl* root_surface =
277 host_impl->active_tree()->root_layer()->render_surface();
278 gfx::RectF root_damage =
279 root_surface->damage_tracker()->current_damage_rect();
280 root_damage.Intersect(root_surface->content_rect());
281 EXPECT_TRUE(root_damage.Contains(gfx::Rect(3, 3, 1, 1)));
282 break;
283 }
284 case 2:
285 // CompositeAndReadback causes a follow-up commit.
286 break;
287 case 3:
288 NOTREACHED();
289 break;
290 }
291 return draw_result;
292 }
293
294 virtual void DidCommitAndDrawFrame() OVERRIDE {
295 int next_frame = layer_tree_host()->source_frame_number();
296 switch (next_frame) {
297 case 1: {
298 char pixels[4];
299 layer_tree_host()->CompositeAndReadback(static_cast<void*>(&pixels),
300 gfx::Rect(3, 3, 1, 1));
301 EndTest();
302 break;
303 }
304 }
305 }
306
307 virtual void AfterTest() OVERRIDE {}
308
309 FakeContentLayerClient client_;
310 scoped_refptr<FakeContentLayer> content_;
311 };
312
313 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDamageTestNoDamageReadbackDoesDraw);
314
315 class LayerTreeHostDamageTestForcedFullDamage : public LayerTreeHostDamageTest { 243 class LayerTreeHostDamageTestForcedFullDamage : public LayerTreeHostDamageTest {
316 virtual void BeginTest() OVERRIDE { 244 virtual void BeginTest() OVERRIDE {
317 PostSetNeedsCommitToMainThread(); 245 PostSetNeedsCommitToMainThread();
318 } 246 }
319 247
320 virtual void SetupTree() OVERRIDE { 248 virtual void SetupTree() OVERRIDE {
321 root_ = FakeContentLayer::Create(&client_); 249 root_ = FakeContentLayer::Create(&client_);
322 child_ = FakeContentLayer::Create(&client_); 250 child_ = FakeContentLayer::Create(&client_);
323 251
324 root_->SetBounds(gfx::Size(500, 500)); 252 root_->SetBounds(gfx::Size(500, 500));
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 FakeContentLayerClient client_; 637 FakeContentLayerClient client_;
710 int swap_count_; 638 int swap_count_;
711 int prepare_to_draw_count_; 639 int prepare_to_draw_count_;
712 int update_visible_tile_count_; 640 int update_visible_tile_count_;
713 }; 641 };
714 642
715 MULTI_THREAD_TEST_F(LayerTreeHostDamageTestVisibleTilesStillTriggerDraws); 643 MULTI_THREAD_TEST_F(LayerTreeHostDamageTestVisibleTilesStillTriggerDraws);
716 644
717 } // namespace 645 } // namespace
718 } // namespace cc 646 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_unittest_context.cc ('k') | cc/trees/proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698