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

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

Issue 12545018: Move context-related callbacks into OutputSurface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: unit test Created 7 years, 8 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') | cc/trees/single_thread_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 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_impl.h" 5 #include "cc/trees/layer_tree_host_impl.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/hash_tables.h" 11 #include "base/hash_tables.h"
12 #include "cc/base/math_util.h" 12 #include "cc/base/math_util.h"
13 #include "cc/input/top_controls_manager.h" 13 #include "cc/input/top_controls_manager.h"
14 #include "cc/layers/delegated_renderer_layer_impl.h" 14 #include "cc/layers/delegated_renderer_layer_impl.h"
15 #include "cc/layers/heads_up_display_layer_impl.h" 15 #include "cc/layers/heads_up_display_layer_impl.h"
16 #include "cc/layers/io_surface_layer_impl.h" 16 #include "cc/layers/io_surface_layer_impl.h"
17 #include "cc/layers/layer_impl.h" 17 #include "cc/layers/layer_impl.h"
18 #include "cc/layers/quad_sink.h" 18 #include "cc/layers/quad_sink.h"
19 #include "cc/layers/render_surface_impl.h" 19 #include "cc/layers/render_surface_impl.h"
20 #include "cc/layers/scrollbar_geometry_fixed_thumb.h" 20 #include "cc/layers/scrollbar_geometry_fixed_thumb.h"
21 #include "cc/layers/scrollbar_layer_impl.h" 21 #include "cc/layers/scrollbar_layer_impl.h"
22 #include "cc/layers/solid_color_layer_impl.h" 22 #include "cc/layers/solid_color_layer_impl.h"
23 #include "cc/layers/texture_layer_impl.h" 23 #include "cc/layers/texture_layer_impl.h"
24 #include "cc/layers/tiled_layer_impl.h" 24 #include "cc/layers/tiled_layer_impl.h"
25 #include "cc/layers/video_layer_impl.h" 25 #include "cc/layers/video_layer_impl.h"
26 #include "cc/output/compositor_frame_ack.h"
26 #include "cc/output/compositor_frame_metadata.h" 27 #include "cc/output/compositor_frame_metadata.h"
27 #include "cc/output/gl_renderer.h" 28 #include "cc/output/gl_renderer.h"
28 #include "cc/quads/render_pass_draw_quad.h" 29 #include "cc/quads/render_pass_draw_quad.h"
29 #include "cc/quads/solid_color_draw_quad.h" 30 #include "cc/quads/solid_color_draw_quad.h"
30 #include "cc/quads/texture_draw_quad.h" 31 #include "cc/quads/texture_draw_quad.h"
31 #include "cc/quads/tile_draw_quad.h" 32 #include "cc/quads/tile_draw_quad.h"
32 #include "cc/resources/layer_tiling_data.h" 33 #include "cc/resources/layer_tiling_data.h"
33 #include "cc/test/animation_test_common.h" 34 #include "cc/test/animation_test_common.h"
34 #include "cc/test/fake_output_surface.h" 35 #include "cc/test/fake_output_surface.h"
35 #include "cc/test/fake_proxy.h" 36 #include "cc/test/fake_proxy.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 always_main_thread_blocked_(&proxy_), 68 always_main_thread_blocked_(&proxy_),
68 on_can_draw_state_changed_called_(false), 69 on_can_draw_state_changed_called_(false),
69 has_pending_tree_(false), 70 has_pending_tree_(false),
70 did_request_commit_(false), 71 did_request_commit_(false),
71 did_request_redraw_(false), 72 did_request_redraw_(false),
72 did_upload_visible_tile_(false), 73 did_upload_visible_tile_(false),
73 reduce_memory_result_(true) { 74 reduce_memory_result_(true) {
74 media::InitializeMediaLibraryForTesting(); 75 media::InitializeMediaLibraryForTesting();
75 } 76 }
76 77
78 virtual void OverrideSettings(LayerTreeSettings* settings) {}
79
77 virtual void SetUp() OVERRIDE { 80 virtual void SetUp() OVERRIDE {
78 LayerTreeSettings settings; 81 LayerTreeSettings settings;
79 settings.minimum_occlusion_tracking_size = gfx::Size(); 82 settings.minimum_occlusion_tracking_size = gfx::Size();
83 OverrideSettings(&settings);
80 84
81 host_impl_ = LayerTreeHostImpl::Create(settings, 85 host_impl_ = LayerTreeHostImpl::Create(settings,
82 this, 86 this,
83 &proxy_, 87 &proxy_,
84 &stats_instrumentation_); 88 &stats_instrumentation_);
85 host_impl_->InitializeRenderer(CreateOutputSurface()); 89 host_impl_->InitializeRenderer(CreateOutputSurface());
86 host_impl_->SetViewportSize(gfx::Size(10, 10)); 90 host_impl_->SetViewportSize(gfx::Size(10, 10));
87 } 91 }
88 92
89 virtual void TearDown() OVERRIDE {} 93 virtual void TearDown() OVERRIDE {}
(...skipping 4192 matching lines...) Expand 10 before | Expand all | Expand 10 after
4282 return textures_.count(id); 4286 return textures_.count(id);
4283 } 4287 }
4284 4288
4285 // RendererClient implementation. 4289 // RendererClient implementation.
4286 virtual gfx::Size DeviceViewportSize() const OVERRIDE { 4290 virtual gfx::Size DeviceViewportSize() const OVERRIDE {
4287 return viewport_size_; 4291 return viewport_size_;
4288 } 4292 }
4289 virtual const LayerTreeSettings& Settings() const OVERRIDE { 4293 virtual const LayerTreeSettings& Settings() const OVERRIDE {
4290 return settings_; 4294 return settings_;
4291 } 4295 }
4292 virtual void DidLoseOutputSurface() OVERRIDE {}
4293 virtual void OnSwapBuffersComplete() OVERRIDE {}
4294 virtual void SetFullRootLayerDamage() OVERRIDE {} 4296 virtual void SetFullRootLayerDamage() OVERRIDE {}
4295 virtual void SetManagedMemoryPolicy(const ManagedMemoryPolicy& policy) 4297 virtual void SetManagedMemoryPolicy(const ManagedMemoryPolicy& policy)
4296 OVERRIDE {} 4298 OVERRIDE {}
4297 virtual void EnforceManagedMemoryPolicy(const ManagedMemoryPolicy& policy) 4299 virtual void EnforceManagedMemoryPolicy(const ManagedMemoryPolicy& policy)
4298 OVERRIDE {} 4300 OVERRIDE {}
4299 virtual bool HasImplThread() const OVERRIDE { return false; } 4301 virtual bool HasImplThread() const OVERRIDE { return false; }
4300 virtual bool ShouldClearRootRenderPass() const OVERRIDE { return true; } 4302 virtual bool ShouldClearRootRenderPass() const OVERRIDE { return true; }
4301 virtual CompositorFrameMetadata MakeCompositorFrameMetadata() const 4303 virtual CompositorFrameMetadata MakeCompositorFrameMetadata() const
4302 OVERRIDE { return CompositorFrameMetadata(); } 4304 OVERRIDE { return CompositorFrameMetadata(); }
4303 virtual bool AllowPartialSwap() const OVERRIDE { 4305 virtual bool AllowPartialSwap() const OVERRIDE {
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after
5040 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 5042 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
5041 render_pass_quad->rect.ToString()); 5043 render_pass_quad->rect.ToString());
5042 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), 5044 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(),
5043 render_pass_quad->mask_uv_rect.ToString()); 5045 render_pass_quad->mask_uv_rect.ToString());
5044 5046
5045 host_impl_->DrawLayers(&frame, base::TimeTicks::Now()); 5047 host_impl_->DrawLayers(&frame, base::TimeTicks::Now());
5046 host_impl_->DidDrawAllLayers(frame); 5048 host_impl_->DidDrawAllLayers(frame);
5047 } 5049 }
5048 } 5050 }
5049 5051
5052 class CompositorFrameMetadataTest : public LayerTreeHostImplTest {
5053 public:
5054 CompositorFrameMetadataTest()
5055 : swap_buffers_complete_(0) {}
5056
5057 virtual void OverrideSettings(LayerTreeSettings* settings) OVERRIDE {
5058 settings->compositor_frame_message = true;
5059 }
5060 virtual void OnSwapBuffersCompleteOnImplThread() OVERRIDE {
5061 swap_buffers_complete_++;
5062 }
5063
5064 int swap_buffers_complete_;
5065 };
5066
5067 TEST_F(CompositorFrameMetadataTest, CompositorFrameAckCountsAsSwapComplete) {
5068 SetupRootLayerImpl(FakeLayerWithQuads::Create(host_impl_->active_tree(), 1));
5069 {
5070 LayerTreeHostImpl::FrameData frame;
5071 EXPECT_TRUE(host_impl_->PrepareToDraw(&frame, gfx::Rect()));
5072 host_impl_->DrawLayers(&frame, base::TimeTicks());
5073 host_impl_->DidDrawAllLayers(frame);
5074 }
5075 CompositorFrameAck ack;
5076 host_impl_->OnSendFrameToParentCompositorAck(ack);
5077 EXPECT_EQ(swap_buffers_complete_, 1);
5078 }
5079
5050 } // namespace 5080 } // namespace
5051 } // namespace cc 5081 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/single_thread_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698