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

Side by Side Diff: cc/output/overlay_unittest.cc

Issue 485043003: cc: Use correct message loop proxy in BlockingTaskRunner (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Help gn deal with it. Created 6 years, 3 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
OLDNEW
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
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(
37 unsigned sync_point,
38 bool lost_resource,
39 scoped_refptr<BlockingTaskRunner> main_thread_task_runner) {
40 }
37 41
38 class SingleOverlayValidator : public OverlayCandidateValidator { 42 class SingleOverlayValidator : public OverlayCandidateValidator {
39 public: 43 public:
40 virtual void CheckOverlaySupport(OverlayCandidateList* surfaces) OVERRIDE; 44 virtual void CheckOverlaySupport(OverlayCandidateList* surfaces) OVERRIDE;
41 }; 45 };
42 46
43 void SingleOverlayValidator::CheckOverlaySupport( 47 void SingleOverlayValidator::CheckOverlaySupport(
44 OverlayCandidateList* surfaces) { 48 OverlayCandidateList* surfaces) {
45 ASSERT_EQ(2U, surfaces->size()); 49 ASSERT_EQ(2U, surfaces->size());
46 50
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 shared_state->opacity = 1.f; 124 shared_state->opacity = 1.f;
121 return pass.Pass(); 125 return pass.Pass();
122 } 126 }
123 127
124 ResourceProvider::ResourceId CreateResource( 128 ResourceProvider::ResourceId CreateResource(
125 ResourceProvider* resource_provider) { 129 ResourceProvider* resource_provider) {
126 unsigned sync_point = 0; 130 unsigned sync_point = 0;
127 TextureMailbox mailbox = 131 TextureMailbox mailbox =
128 TextureMailbox(gpu::Mailbox::Generate(), GL_TEXTURE_2D, sync_point); 132 TextureMailbox(gpu::Mailbox::Generate(), GL_TEXTURE_2D, sync_point);
129 mailbox.set_allow_overlay(true); 133 mailbox.set_allow_overlay(true);
130 scoped_ptr<SingleReleaseCallback> release_callback = 134 scoped_ptr<SingleReleaseCallbackImpl> release_callback =
131 SingleReleaseCallback::Create(base::Bind(&MailboxReleased)); 135 SingleReleaseCallbackImpl::Create(base::Bind(&MailboxReleased));
132 136
133 return resource_provider->CreateResourceFromTextureMailbox( 137 return resource_provider->CreateResourceFromTextureMailbox(
134 mailbox, release_callback.Pass()); 138 mailbox, release_callback.Pass());
135 } 139 }
136 140
137 TextureDrawQuad* CreateCandidateQuadAt(ResourceProvider* resource_provider, 141 TextureDrawQuad* CreateCandidateQuadAt(ResourceProvider* resource_provider,
138 const SharedQuadState* shared_quad_state, 142 const SharedQuadState* shared_quad_state,
139 RenderPass* render_pass, 143 RenderPass* render_pass,
140 const gfx::Rect& rect) { 144 const gfx::Rect& rect) {
141 ResourceProvider::ResourceId resource_id = CreateResource(resource_provider); 145 ResourceProvider::ResourceId resource_id = CreateResource(resource_provider);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 scoped_refptr<TestContextProvider> provider = TestContextProvider::Create(); 230 scoped_refptr<TestContextProvider> provider = TestContextProvider::Create();
227 OverlayOutputSurface output_surface(provider); 231 OverlayOutputSurface output_surface(provider);
228 FakeOutputSurfaceClient client; 232 FakeOutputSurfaceClient client;
229 EXPECT_TRUE(output_surface.BindToClient(&client)); 233 EXPECT_TRUE(output_surface.BindToClient(&client));
230 output_surface.InitWithSingleOverlayValidator(); 234 output_surface.InitWithSingleOverlayValidator();
231 EXPECT_TRUE(output_surface.overlay_candidate_validator() != NULL); 235 EXPECT_TRUE(output_surface.overlay_candidate_validator() != NULL);
232 236
233 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( 237 scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
234 new TestSharedBitmapManager()); 238 new TestSharedBitmapManager());
235 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create( 239 scoped_ptr<ResourceProvider> resource_provider(ResourceProvider::Create(
236 &output_surface, shared_bitmap_manager.get(), 0, false, 1, false)); 240 &output_surface, shared_bitmap_manager.get(), NULL, 0, false, 1, false));
237 241
238 scoped_ptr<DefaultOverlayProcessor> overlay_processor( 242 scoped_ptr<DefaultOverlayProcessor> overlay_processor(
239 new DefaultOverlayProcessor(&output_surface, resource_provider.get())); 243 new DefaultOverlayProcessor(&output_surface, resource_provider.get()));
240 overlay_processor->Initialize(); 244 overlay_processor->Initialize();
241 EXPECT_GE(1U, overlay_processor->GetStrategyCount()); 245 EXPECT_GE(1U, overlay_processor->GetStrategyCount());
242 } 246 }
243 247
244 class SingleOverlayOnTopTest : public testing::Test { 248 class SingleOverlayOnTopTest : public testing::Test {
245 protected: 249 protected:
246 virtual void SetUp() { 250 virtual void SetUp() {
247 provider_ = TestContextProvider::Create(); 251 provider_ = TestContextProvider::Create();
248 output_surface_.reset(new OverlayOutputSurface(provider_)); 252 output_surface_.reset(new OverlayOutputSurface(provider_));
249 EXPECT_TRUE(output_surface_->BindToClient(&client_)); 253 EXPECT_TRUE(output_surface_->BindToClient(&client_));
250 output_surface_->InitWithSingleOverlayValidator(); 254 output_surface_->InitWithSingleOverlayValidator();
251 EXPECT_TRUE(output_surface_->overlay_candidate_validator() != NULL); 255 EXPECT_TRUE(output_surface_->overlay_candidate_validator() != NULL);
252 256
253 shared_bitmap_manager_.reset(new TestSharedBitmapManager()); 257 shared_bitmap_manager_.reset(new TestSharedBitmapManager());
254 resource_provider_ = ResourceProvider::Create( 258 resource_provider_ = ResourceProvider::Create(output_surface_.get(),
255 output_surface_.get(), shared_bitmap_manager_.get(), 0, false, 1, 259 shared_bitmap_manager_.get(),
256 false); 260 NULL,
261 0,
262 false,
263 1,
264 false);
257 265
258 overlay_processor_.reset(new SingleOverlayProcessor( 266 overlay_processor_.reset(new SingleOverlayProcessor(
259 output_surface_.get(), resource_provider_.get())); 267 output_surface_.get(), resource_provider_.get()));
260 overlay_processor_->Initialize(); 268 overlay_processor_->Initialize();
261 } 269 }
262 270
263 scoped_refptr<TestContextProvider> provider_; 271 scoped_refptr<TestContextProvider> provider_;
264 scoped_ptr<OverlayOutputSurface> output_surface_; 272 scoped_ptr<OverlayOutputSurface> output_surface_;
265 FakeOutputSurfaceClient client_; 273 FakeOutputSurfaceClient client_;
266 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; 274 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_;
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 const gfx::Rect& display_bounds, 564 const gfx::Rect& display_bounds,
557 const gfx::RectF& uv_rect)); 565 const gfx::RectF& uv_rect));
558 }; 566 };
559 567
560 class GLRendererWithOverlaysTest : public testing::Test { 568 class GLRendererWithOverlaysTest : public testing::Test {
561 protected: 569 protected:
562 GLRendererWithOverlaysTest() { 570 GLRendererWithOverlaysTest() {
563 provider_ = TestContextProvider::Create(); 571 provider_ = TestContextProvider::Create();
564 output_surface_.reset(new OverlayOutputSurface(provider_)); 572 output_surface_.reset(new OverlayOutputSurface(provider_));
565 CHECK(output_surface_->BindToClient(&output_surface_client_)); 573 CHECK(output_surface_->BindToClient(&output_surface_client_));
566 resource_provider_ = 574 resource_provider_ = ResourceProvider::Create(
567 ResourceProvider::Create(output_surface_.get(), NULL, 0, false, 1, 575 output_surface_.get(), NULL, NULL, 0, false, 1, false);
568 false);
569 576
570 provider_->support()->SetScheduleOverlayPlaneCallback(base::Bind( 577 provider_->support()->SetScheduleOverlayPlaneCallback(base::Bind(
571 &MockOverlayScheduler::Schedule, base::Unretained(&scheduler_))); 578 &MockOverlayScheduler::Schedule, base::Unretained(&scheduler_)));
572 } 579 }
573 580
574 void Init(bool use_validator) { 581 void Init(bool use_validator) {
575 if (use_validator) 582 if (use_validator)
576 output_surface_->InitWithSingleOverlayValidator(); 583 output_surface_->InitWithSingleOverlayValidator();
577 584
578 renderer_ = 585 renderer_ =
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 renderer_->set_expect_overlays(false); 781 renderer_->set_expect_overlays(false);
775 renderer_->FinishDrawingFrame(&frame3); 782 renderer_->FinishDrawingFrame(&frame3);
776 EXPECT_TRUE(resource_provider_->InUseByConsumer(resource1)); 783 EXPECT_TRUE(resource_provider_->InUseByConsumer(resource1));
777 SwapBuffers(); 784 SwapBuffers();
778 EXPECT_FALSE(resource_provider_->InUseByConsumer(resource1)); 785 EXPECT_FALSE(resource_provider_->InUseByConsumer(resource1));
779 Mock::VerifyAndClearExpectations(&scheduler_); 786 Mock::VerifyAndClearExpectations(&scheduler_);
780 } 787 }
781 788
782 } // namespace 789 } // namespace
783 } // namespace cc 790 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698