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

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

Issue 15435003: cc: Add CopyAsBitmapRequest class to hold the readback callback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nolint Created 7 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_impl.cc ('k') | no next file » | 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/trees/layer_tree_host.h" 5 #include "cc/trees/layer_tree_host.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/synchronization/lock.h" 9 #include "base/synchronization/lock.h"
10 #include "cc/animation/timing_function.h" 10 #include "cc/animation/timing_function.h"
11 #include "cc/debug/frame_rate_counter.h" 11 #include "cc/debug/frame_rate_counter.h"
12 #include "cc/layers/content_layer.h" 12 #include "cc/layers/content_layer.h"
13 #include "cc/layers/content_layer_client.h" 13 #include "cc/layers/content_layer_client.h"
14 #include "cc/layers/io_surface_layer.h" 14 #include "cc/layers/io_surface_layer.h"
15 #include "cc/layers/layer_impl.h" 15 #include "cc/layers/layer_impl.h"
16 #include "cc/layers/picture_layer.h" 16 #include "cc/layers/picture_layer.h"
17 #include "cc/layers/scrollbar_layer.h" 17 #include "cc/layers/scrollbar_layer.h"
18 #include "cc/output/copy_output_request.h"
18 #include "cc/output/output_surface.h" 19 #include "cc/output/output_surface.h"
19 #include "cc/resources/prioritized_resource.h" 20 #include "cc/resources/prioritized_resource.h"
20 #include "cc/resources/prioritized_resource_manager.h" 21 #include "cc/resources/prioritized_resource_manager.h"
21 #include "cc/resources/resource_update_queue.h" 22 #include "cc/resources/resource_update_queue.h"
22 #include "cc/scheduler/frame_rate_controller.h" 23 #include "cc/scheduler/frame_rate_controller.h"
23 #include "cc/test/fake_content_layer.h" 24 #include "cc/test/fake_content_layer.h"
24 #include "cc/test/fake_content_layer_client.h" 25 #include "cc/test/fake_content_layer_client.h"
25 #include "cc/test/fake_layer_tree_host_client.h" 26 #include "cc/test/fake_layer_tree_host_client.h"
26 #include "cc/test/fake_output_surface.h" 27 #include "cc/test/fake_output_surface.h"
27 #include "cc/test/fake_proxy.h" 28 #include "cc/test/fake_proxy.h"
(...skipping 2590 matching lines...) Expand 10 before | Expand all | Expand 10 after
2618 FROM_HERE, 2619 FROM_HERE,
2619 base::Bind( 2620 base::Bind(
2620 &LayerTreeHostTestAsyncReadback::NextStep, 2621 &LayerTreeHostTestAsyncReadback::NextStep,
2621 base::Unretained(this))); 2622 base::Unretained(this)));
2622 } 2623 }
2623 2624
2624 void NextStep() { 2625 void NextStep() {
2625 int frame = layer_tree_host()->commit_number(); 2626 int frame = layer_tree_host()->commit_number();
2626 switch (frame) { 2627 switch (frame) {
2627 case 1: 2628 case 1:
2628 child->RequestCopyAsBitmap(base::Bind( 2629 child->RequestCopyOfOutput(CopyOutputRequest::CreateBitmapRequest(
2629 &LayerTreeHostTestAsyncReadback::BitmapCallback, 2630 base::Bind(&LayerTreeHostTestAsyncReadback::BitmapCallback,
2630 base::Unretained(this))); 2631 base::Unretained(this))));
2631 EXPECT_EQ(0u, callbacks_.size()); 2632 EXPECT_EQ(0u, callbacks_.size());
2632 break; 2633 break;
2633 case 2: 2634 case 2:
2634 if (callbacks_.size() < 1u) { 2635 if (callbacks_.size() < 1u) {
2635 WaitForCallback(); 2636 WaitForCallback();
2636 return; 2637 return;
2637 } 2638 }
2638 EXPECT_EQ(1u, callbacks_.size()); 2639 EXPECT_EQ(1u, callbacks_.size());
2639 EXPECT_EQ(gfx::Size(10, 10).ToString(), callbacks_[0].ToString()); 2640 EXPECT_EQ(gfx::Size(10, 10).ToString(), callbacks_[0].ToString());
2640 2641
2641 child->RequestCopyAsBitmap(base::Bind( 2642 child->RequestCopyOfOutput(CopyOutputRequest::CreateBitmapRequest(
2642 &LayerTreeHostTestAsyncReadback::BitmapCallback, 2643 base::Bind(&LayerTreeHostTestAsyncReadback::BitmapCallback,
2643 base::Unretained(this))); 2644 base::Unretained(this))));
2644 root->RequestCopyAsBitmap(base::Bind( 2645 root->RequestCopyOfOutput(CopyOutputRequest::CreateBitmapRequest(
2645 &LayerTreeHostTestAsyncReadback::BitmapCallback, 2646 base::Bind(&LayerTreeHostTestAsyncReadback::BitmapCallback,
2646 base::Unretained(this))); 2647 base::Unretained(this))));
2647 child->RequestCopyAsBitmap(base::Bind( 2648 child->RequestCopyOfOutput(CopyOutputRequest::CreateBitmapRequest(
2648 &LayerTreeHostTestAsyncReadback::BitmapCallback, 2649 base::Bind(&LayerTreeHostTestAsyncReadback::BitmapCallback,
2649 base::Unretained(this))); 2650 base::Unretained(this))));
2650 EXPECT_EQ(1u, callbacks_.size()); 2651 EXPECT_EQ(1u, callbacks_.size());
2651 break; 2652 break;
2652 case 3: 2653 case 3:
2653 if (callbacks_.size() < 4u) { 2654 if (callbacks_.size() < 4u) {
2654 WaitForCallback(); 2655 WaitForCallback();
2655 return; 2656 return;
2656 } 2657 }
2657 EXPECT_EQ(4u, callbacks_.size()); 2658 EXPECT_EQ(4u, callbacks_.size());
2658 // The child was copied to a bitmap and passed back twice. 2659 // The child was copied to a bitmap and passed back twice.
2659 EXPECT_EQ(gfx::Size(10, 10).ToString(), callbacks_[1].ToString()); 2660 EXPECT_EQ(gfx::Size(10, 10).ToString(), callbacks_[1].ToString());
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
2744 2745
2745 virtual void BeginTest() OVERRIDE { 2746 virtual void BeginTest() OVERRIDE {
2746 callback_count_ = 0; 2747 callback_count_ = 0;
2747 PostSetNeedsCommitToMainThread(); 2748 PostSetNeedsCommitToMainThread();
2748 } 2749 }
2749 2750
2750 virtual void DidCommit() OVERRIDE { 2751 virtual void DidCommit() OVERRIDE {
2751 int frame = layer_tree_host()->commit_number(); 2752 int frame = layer_tree_host()->commit_number();
2752 switch (frame) { 2753 switch (frame) {
2753 case 1: 2754 case 1:
2754 main_destroyed_->RequestCopyAsBitmap(base::Bind( 2755 main_destroyed_->RequestCopyOfOutput(
2755 &LayerTreeHostTestAsyncReadbackLayerDestroyed::BitmapCallback, 2756 CopyOutputRequest::CreateBitmapRequest(base::Bind(
2756 base::Unretained(this))); 2757 &LayerTreeHostTestAsyncReadbackLayerDestroyed::BitmapCallback,
2757 impl_destroyed_->RequestCopyAsBitmap(base::Bind( 2758 base::Unretained(this))));
2758 &LayerTreeHostTestAsyncReadbackLayerDestroyed::BitmapCallback, 2759 impl_destroyed_->RequestCopyOfOutput(
2759 base::Unretained(this))); 2760 CopyOutputRequest::CreateBitmapRequest(base::Bind(
2761 &LayerTreeHostTestAsyncReadbackLayerDestroyed::BitmapCallback,
2762 base::Unretained(this))));
2760 EXPECT_EQ(0, callback_count_); 2763 EXPECT_EQ(0, callback_count_);
2761 2764
2762 // Destroy the main thread layer right away. 2765 // Destroy the main thread layer right away.
2763 main_destroyed_->RemoveFromParent(); 2766 main_destroyed_->RemoveFromParent();
2764 main_destroyed_ = NULL; 2767 main_destroyed_ = NULL;
2765 2768
2766 // Should callback with a NULL bitmap. 2769 // Should callback with a NULL bitmap.
2767 EXPECT_EQ(1, callback_count_); 2770 EXPECT_EQ(1, callback_count_);
2768 2771
2769 // Prevent drawing so we can't make a copy of the impl_destroyed layer. 2772 // Prevent drawing so we can't make a copy of the impl_destroyed layer.
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
2884 TEST_F(LayerTreeHostTestNumFramesPending, DelegatingRenderer) { 2887 TEST_F(LayerTreeHostTestNumFramesPending, DelegatingRenderer) {
2885 RunTest(true, true, true); 2888 RunTest(true, true, true);
2886 } 2889 }
2887 2890
2888 TEST_F(LayerTreeHostTestNumFramesPending, GLRenderer) { 2891 TEST_F(LayerTreeHostTestNumFramesPending, GLRenderer) {
2889 RunTest(true, false, true); 2892 RunTest(true, false, true);
2890 } 2893 }
2891 2894
2892 } // namespace 2895 } // namespace
2893 } // namespace cc 2896 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698