OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/base/scoped_ptr_vector.h" | 5 #include "cc/base/scoped_ptr_vector.h" |
6 #include "cc/output/gl_renderer.h" | 6 #include "cc/output/gl_renderer.h" |
7 #include "cc/output/output_surface.h" | 7 #include "cc/output/output_surface.h" |
8 #include "cc/output/output_surface_client.h" | 8 #include "cc/output/output_surface_client.h" |
9 #include "cc/output/overlay_candidate_validator.h" | 9 #include "cc/output/overlay_candidate_validator.h" |
10 #include "cc/output/overlay_processor.h" | 10 #include "cc/output/overlay_processor.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 | 26 |
27 namespace cc { | 27 namespace cc { |
28 namespace { | 28 namespace { |
29 | 29 |
30 const gfx::Rect kOverlayRect(0, 0, 128, 128); | 30 const gfx::Rect kOverlayRect(0, 0, 128, 128); |
31 const gfx::Rect kOverlayTopLeftRect(0, 0, 64, 64); | 31 const gfx::Rect kOverlayTopLeftRect(0, 0, 64, 64); |
32 const gfx::Rect kOverlayBottomRightRect(64, 64, 64, 64); | 32 const gfx::Rect kOverlayBottomRightRect(64, 64, 64, 64); |
33 const gfx::PointF kUVTopLeft(0.1f, 0.2f); | 33 const gfx::PointF kUVTopLeft(0.1f, 0.2f); |
34 const gfx::PointF kUVBottomRight(1.0f, 1.0f); | 34 const gfx::PointF kUVBottomRight(1.0f, 1.0f); |
35 | 35 |
36 void MailboxReleased(unsigned sync_point, bool lost_resource) {} | 36 void MailboxReleased(unsigned sync_point, |
| 37 bool lost_resource, |
| 38 BlockingTaskRunner* main_thread_task_runner) { |
| 39 } |
37 | 40 |
38 class SingleOverlayValidator : public OverlayCandidateValidator { | 41 class SingleOverlayValidator : public OverlayCandidateValidator { |
39 public: | 42 public: |
40 virtual void CheckOverlaySupport(OverlayCandidateList* surfaces) OVERRIDE; | 43 virtual void CheckOverlaySupport(OverlayCandidateList* surfaces) OVERRIDE; |
41 }; | 44 }; |
42 | 45 |
43 void SingleOverlayValidator::CheckOverlaySupport( | 46 void SingleOverlayValidator::CheckOverlaySupport( |
44 OverlayCandidateList* surfaces) { | 47 OverlayCandidateList* surfaces) { |
45 ASSERT_EQ(2U, surfaces->size()); | 48 ASSERT_EQ(2U, surfaces->size()); |
46 | 49 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 shared_state->opacity = 1.f; | 123 shared_state->opacity = 1.f; |
121 return pass.Pass(); | 124 return pass.Pass(); |
122 } | 125 } |
123 | 126 |
124 ResourceProvider::ResourceId CreateResource( | 127 ResourceProvider::ResourceId CreateResource( |
125 ResourceProvider* resource_provider) { | 128 ResourceProvider* resource_provider) { |
126 unsigned sync_point = 0; | 129 unsigned sync_point = 0; |
127 TextureMailbox mailbox = | 130 TextureMailbox mailbox = |
128 TextureMailbox(gpu::Mailbox::Generate(), GL_TEXTURE_2D, sync_point); | 131 TextureMailbox(gpu::Mailbox::Generate(), GL_TEXTURE_2D, sync_point); |
129 mailbox.set_allow_overlay(true); | 132 mailbox.set_allow_overlay(true); |
130 scoped_ptr<SingleReleaseCallback> release_callback = | 133 scoped_ptr<SingleReleaseCallbackImpl> release_callback = |
131 SingleReleaseCallback::Create(base::Bind(&MailboxReleased)); | 134 SingleReleaseCallbackImpl::Create(base::Bind(&MailboxReleased)); |
132 | 135 |
133 return resource_provider->CreateResourceFromTextureMailbox( | 136 return resource_provider->CreateResourceFromTextureMailbox( |
134 mailbox, release_callback.Pass()); | 137 mailbox, release_callback.Pass()); |
135 } | 138 } |
136 | 139 |
137 TextureDrawQuad* CreateCandidateQuadAt(ResourceProvider* resource_provider, | 140 TextureDrawQuad* CreateCandidateQuadAt(ResourceProvider* resource_provider, |
138 const SharedQuadState* shared_quad_state, | 141 const SharedQuadState* shared_quad_state, |
139 RenderPass* render_pass, | 142 RenderPass* render_pass, |
140 const gfx::Rect& rect) { | 143 const gfx::Rect& rect) { |
141 ResourceProvider::ResourceId resource_id = CreateResource(resource_provider); | 144 ResourceProvider::ResourceId resource_id = CreateResource(resource_provider); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 scoped_refptr<TestContextProvider> provider = TestContextProvider::Create(); | 229 scoped_refptr<TestContextProvider> provider = TestContextProvider::Create(); |
227 OverlayOutputSurface output_surface(provider); | 230 OverlayOutputSurface output_surface(provider); |
228 FakeOutputSurfaceClient client; | 231 FakeOutputSurfaceClient client; |
229 EXPECT_TRUE(output_surface.BindToClient(&client)); | 232 EXPECT_TRUE(output_surface.BindToClient(&client)); |
230 output_surface.InitWithSingleOverlayValidator(); | 233 output_surface.InitWithSingleOverlayValidator(); |
231 EXPECT_TRUE(output_surface.overlay_candidate_validator() != NULL); | 234 EXPECT_TRUE(output_surface.overlay_candidate_validator() != NULL); |
232 | 235 |
233 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( | 236 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( |
234 new TestSharedBitmapManager()); | 237 new TestSharedBitmapManager()); |
235 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( | 238 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( |
236 &output_surface, shared_bitmap_manager.get(), 0, false, 1, false)); | 239 &output_surface, shared_bitmap_manager.get(), NULL, 0, false, 1, false)); |
237 | 240 |
238 scoped_ptr<DefaultOverlayProcessor> overlay_processor( | 241 scoped_ptr<DefaultOverlayProcessor> overlay_processor( |
239 new DefaultOverlayProcessor(&output_surface, resource_provider.get())); | 242 new DefaultOverlayProcessor(&output_surface, resource_provider.get())); |
240 overlay_processor->Initialize(); | 243 overlay_processor->Initialize(); |
241 EXPECT_GE(1U, overlay_processor->GetStrategyCount()); | 244 EXPECT_GE(1U, overlay_processor->GetStrategyCount()); |
242 } | 245 } |
243 | 246 |
244 class SingleOverlayOnTopTest : public testing::Test { | 247 class SingleOverlayOnTopTest : public testing::Test { |
245 protected: | 248 protected: |
246 virtual void SetUp() { | 249 virtual void SetUp() { |
247 provider_ = TestContextProvider::Create(); | 250 provider_ = TestContextProvider::Create(); |
248 output_surface_.reset(new OverlayOutputSurface(provider_)); | 251 output_surface_.reset(new OverlayOutputSurface(provider_)); |
249 EXPECT_TRUE(output_surface_->BindToClient(&client_)); | 252 EXPECT_TRUE(output_surface_->BindToClient(&client_)); |
250 output_surface_->InitWithSingleOverlayValidator(); | 253 output_surface_->InitWithSingleOverlayValidator(); |
251 EXPECT_TRUE(output_surface_->overlay_candidate_validator() != NULL); | 254 EXPECT_TRUE(output_surface_->overlay_candidate_validator() != NULL); |
252 | 255 |
253 shared_bitmap_manager_.reset(new TestSharedBitmapManager()); | 256 shared_bitmap_manager_.reset(new TestSharedBitmapManager()); |
254 resource_provider_ = ResourceProvider::Create( | 257 resource_provider_ = ResourceProvider::Create(output_surface_.get(), |
255 output_surface_.get(), shared_bitmap_manager_.get(), 0, false, 1, | 258 shared_bitmap_manager_.get(), |
256 false); | 259 NULL, |
| 260 0, |
| 261 false, |
| 262 1, |
| 263 false); |
257 | 264 |
258 overlay_processor_.reset(new SingleOverlayProcessor( | 265 overlay_processor_.reset(new SingleOverlayProcessor( |
259 output_surface_.get(), resource_provider_.get())); | 266 output_surface_.get(), resource_provider_.get())); |
260 overlay_processor_->Initialize(); | 267 overlay_processor_->Initialize(); |
261 } | 268 } |
262 | 269 |
263 scoped_refptr<TestContextProvider> provider_; | 270 scoped_refptr<TestContextProvider> provider_; |
264 scoped_ptr<OverlayOutputSurface> output_surface_; | 271 scoped_ptr<OverlayOutputSurface> output_surface_; |
265 FakeOutputSurfaceClient client_; | 272 FakeOutputSurfaceClient client_; |
266 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; | 273 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 const gfx::Rect& display_bounds, | 563 const gfx::Rect& display_bounds, |
557 const gfx::RectF& uv_rect)); | 564 const gfx::RectF& uv_rect)); |
558 }; | 565 }; |
559 | 566 |
560 class GLRendererWithOverlaysTest : public testing::Test { | 567 class GLRendererWithOverlaysTest : public testing::Test { |
561 protected: | 568 protected: |
562 GLRendererWithOverlaysTest() { | 569 GLRendererWithOverlaysTest() { |
563 provider_ = TestContextProvider::Create(); | 570 provider_ = TestContextProvider::Create(); |
564 output_surface_.reset(new OverlayOutputSurface(provider_)); | 571 output_surface_.reset(new OverlayOutputSurface(provider_)); |
565 CHECK(output_surface_->BindToClient(&output_surface_client_)); | 572 CHECK(output_surface_->BindToClient(&output_surface_client_)); |
566 resource_provider_ = | 573 resource_provider_ = ResourceProvider::Create( |
567 ResourceProvider::Create(output_surface_.get(), NULL, 0, false, 1, | 574 output_surface_.get(), NULL, NULL, 0, false, 1, false); |
568 false); | |
569 | 575 |
570 provider_->support()->SetScheduleOverlayPlaneCallback(base::Bind( | 576 provider_->support()->SetScheduleOverlayPlaneCallback(base::Bind( |
571 &MockOverlayScheduler::Schedule, base::Unretained(&scheduler_))); | 577 &MockOverlayScheduler::Schedule, base::Unretained(&scheduler_))); |
572 } | 578 } |
573 | 579 |
574 void Init(bool use_validator) { | 580 void Init(bool use_validator) { |
575 if (use_validator) | 581 if (use_validator) |
576 output_surface_->InitWithSingleOverlayValidator(); | 582 output_surface_->InitWithSingleOverlayValidator(); |
577 | 583 |
578 renderer_ = | 584 renderer_ = |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
774 renderer_->set_expect_overlays(false); | 780 renderer_->set_expect_overlays(false); |
775 renderer_->FinishDrawingFrame(&frame3); | 781 renderer_->FinishDrawingFrame(&frame3); |
776 EXPECT_TRUE(resource_provider_->InUseByConsumer(resource1)); | 782 EXPECT_TRUE(resource_provider_->InUseByConsumer(resource1)); |
777 SwapBuffers(); | 783 SwapBuffers(); |
778 EXPECT_FALSE(resource_provider_->InUseByConsumer(resource1)); | 784 EXPECT_FALSE(resource_provider_->InUseByConsumer(resource1)); |
779 Mock::VerifyAndClearExpectations(&scheduler_); | 785 Mock::VerifyAndClearExpectations(&scheduler_); |
780 } | 786 } |
781 | 787 |
782 } // namespace | 788 } // namespace |
783 } // namespace cc | 789 } // namespace cc |
OLD | NEW |