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

Side by Side Diff: cc/gl_renderer_unittest.cc

Issue 11183006: cc: Remove wtf includes from resource provider (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 8 years, 2 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 | « no previous file | cc/layer_tree_host_impl.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 "config.h" 5 #include "config.h"
6 #include "CCRendererGL.h" 6 #include "CCRendererGL.h"
7 7
8 #include "CCDrawQuad.h" 8 #include "CCDrawQuad.h"
9 #include "CCPrioritizedTextureManager.h" 9 #include "CCPrioritizedTextureManager.h"
10 #include "CCResourceProvider.h" 10 #include "CCResourceProvider.h"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 } 129 }
130 130
131 FrameCountingMemoryAllocationSettingContext* context() { return static_cast< FrameCountingMemoryAllocationSettingContext*>(m_context->context3D()); } 131 FrameCountingMemoryAllocationSettingContext* context() { return static_cast< FrameCountingMemoryAllocationSettingContext*>(m_context->context3D()); }
132 132
133 WebGraphicsMemoryAllocation m_suggestHaveBackbufferYes; 133 WebGraphicsMemoryAllocation m_suggestHaveBackbufferYes;
134 WebGraphicsMemoryAllocation m_suggestHaveBackbufferNo; 134 WebGraphicsMemoryAllocation m_suggestHaveBackbufferNo;
135 135
136 WebCompositorInitializer m_compositorInitializer; 136 WebCompositorInitializer m_compositorInitializer;
137 scoped_ptr<CCGraphicsContext> m_context; 137 scoped_ptr<CCGraphicsContext> m_context;
138 FakeCCRendererClient m_mockClient; 138 FakeCCRendererClient m_mockClient;
139 OwnPtr<CCResourceProvider> m_resourceProvider; 139 scoped_ptr<CCResourceProvider> m_resourceProvider;
140 FakeCCRendererGL m_renderer; 140 FakeCCRendererGL m_renderer;
141 CCScopedSettings m_scopedSettings; 141 CCScopedSettings m_scopedSettings;
142 }; 142 };
143 143
144 // Test CCRendererGL discardFramebuffer functionality: 144 // Test CCRendererGL discardFramebuffer functionality:
145 // Suggest recreating framebuffer when one already exists. 145 // Suggest recreating framebuffer when one already exists.
146 // Expected: it does nothing. 146 // Expected: it does nothing.
147 TEST_F(CCRendererGLTest, SuggestBackbufferYesWhenItAlreadyExistsShouldDoNothing) 147 TEST_F(CCRendererGLTest, SuggestBackbufferYesWhenItAlreadyExistsShouldDoNothing)
148 { 148 {
149 context()->setMemoryAllocation(m_suggestHaveBackbufferYes); 149 context()->setMemoryAllocation(m_suggestHaveBackbufferYes);
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 virtual void getVertexAttribiv(WGC3Duint index, WGC3Denum pname, WGC3Dint* v alue) { ADD_FAILURE(); } 291 virtual void getVertexAttribiv(WGC3Duint index, WGC3Denum pname, WGC3Dint* v alue) { ADD_FAILURE(); }
292 virtual WGC3Dsizeiptr getVertexAttribOffset(WGC3Duint index, WGC3Denum pname ) { ADD_FAILURE(); return 0; } 292 virtual WGC3Dsizeiptr getVertexAttribOffset(WGC3Duint index, WGC3Denum pname ) { ADD_FAILURE(); return 0; }
293 }; 293 };
294 294
295 // This test isn't using the same fixture as CCRendererGLTest, and you can't mix TEST() and TEST_F() with the same name, hence LRC2. 295 // This test isn't using the same fixture as CCRendererGLTest, and you can't mix TEST() and TEST_F() with the same name, hence LRC2.
296 TEST(CCRendererGLTest2, initializationDoesNotMakeSynchronousCalls) 296 TEST(CCRendererGLTest2, initializationDoesNotMakeSynchronousCalls)
297 { 297 {
298 CCScopedSettings scopedSettings; 298 CCScopedSettings scopedSettings;
299 FakeCCRendererClient mockClient; 299 FakeCCRendererClient mockClient;
300 scoped_ptr<CCGraphicsContext> context(FakeWebCompositorOutputSurface::create (adoptPtr(new ForbidSynchronousCallContext))); 300 scoped_ptr<CCGraphicsContext> context(FakeWebCompositorOutputSurface::create (adoptPtr(new ForbidSynchronousCallContext)));
301 OwnPtr<CCResourceProvider> resourceProvider(CCResourceProvider::create(conte xt.get())); 301 scoped_ptr<CCResourceProvider> resourceProvider(CCResourceProvider::create(c ontext.get()));
302 FakeCCRendererGL renderer(&mockClient, resourceProvider.get()); 302 FakeCCRendererGL renderer(&mockClient, resourceProvider.get());
303 303
304 EXPECT_TRUE(renderer.initialize()); 304 EXPECT_TRUE(renderer.initialize());
305 } 305 }
306 306
307 class LoseContextOnFirstGetContext : public FakeWebGraphicsContext3D { 307 class LoseContextOnFirstGetContext : public FakeWebGraphicsContext3D {
308 public: 308 public:
309 LoseContextOnFirstGetContext() 309 LoseContextOnFirstGetContext()
310 : m_contextLost(false) 310 : m_contextLost(false)
311 { 311 {
(...skipping 23 matching lines...) Expand all
335 335
336 private: 336 private:
337 bool m_contextLost; 337 bool m_contextLost;
338 }; 338 };
339 339
340 TEST(CCRendererGLTest2, initializationWithQuicklyLostContextDoesNotAssert) 340 TEST(CCRendererGLTest2, initializationWithQuicklyLostContextDoesNotAssert)
341 { 341 {
342 CCScopedSettings scopedSettings; 342 CCScopedSettings scopedSettings;
343 FakeCCRendererClient mockClient; 343 FakeCCRendererClient mockClient;
344 scoped_ptr<CCGraphicsContext> context(FakeWebCompositorOutputSurface::create (adoptPtr(new LoseContextOnFirstGetContext))); 344 scoped_ptr<CCGraphicsContext> context(FakeWebCompositorOutputSurface::create (adoptPtr(new LoseContextOnFirstGetContext)));
345 OwnPtr<CCResourceProvider> resourceProvider(CCResourceProvider::create(conte xt.get())); 345 scoped_ptr<CCResourceProvider> resourceProvider(CCResourceProvider::create(c ontext.get()));
346 FakeCCRendererGL renderer(&mockClient, resourceProvider.get()); 346 FakeCCRendererGL renderer(&mockClient, resourceProvider.get());
347 347
348 renderer.initialize(); 348 renderer.initialize();
349 } 349 }
350 350
351 class ContextThatDoesNotSupportMemoryManagmentExtensions : public FakeWebGraphic sContext3D { 351 class ContextThatDoesNotSupportMemoryManagmentExtensions : public FakeWebGraphic sContext3D {
352 public: 352 public:
353 ContextThatDoesNotSupportMemoryManagmentExtensions() { } 353 ContextThatDoesNotSupportMemoryManagmentExtensions() { }
354 354
355 // WebGraphicsContext3D methods. 355 // WebGraphicsContext3D methods.
356 356
357 // This method would normally do a glSwapBuffers under the hood. 357 // This method would normally do a glSwapBuffers under the hood.
358 virtual void prepareTexture() { } 358 virtual void prepareTexture() { }
359 virtual void setMemoryAllocationChangedCallbackCHROMIUM(WebGraphicsMemoryAll ocationChangedCallbackCHROMIUM* callback) { } 359 virtual void setMemoryAllocationChangedCallbackCHROMIUM(WebGraphicsMemoryAll ocationChangedCallbackCHROMIUM* callback) { }
360 virtual WebString getString(WebKit::WGC3Denum name) { return WebString(); } 360 virtual WebString getString(WebKit::WGC3Denum name) { return WebString(); }
361 }; 361 };
362 362
363 TEST(CCRendererGLTest2, initializationWithoutGpuMemoryManagerExtensionSupportSho uldDefaultToNonZeroAllocation) 363 TEST(CCRendererGLTest2, initializationWithoutGpuMemoryManagerExtensionSupportSho uldDefaultToNonZeroAllocation)
364 { 364 {
365 FakeCCRendererClient mockClient; 365 FakeCCRendererClient mockClient;
366 scoped_ptr<CCGraphicsContext> context(FakeWebCompositorOutputSurface::create (adoptPtr(new ContextThatDoesNotSupportMemoryManagmentExtensions))); 366 scoped_ptr<CCGraphicsContext> context(FakeWebCompositorOutputSurface::create (adoptPtr(new ContextThatDoesNotSupportMemoryManagmentExtensions)));
367 OwnPtr<CCResourceProvider> resourceProvider(CCResourceProvider::create(conte xt.get())); 367 scoped_ptr<CCResourceProvider> resourceProvider(CCResourceProvider::create(c ontext.get()));
368 FakeCCRendererGL renderer(&mockClient, resourceProvider.get()); 368 FakeCCRendererGL renderer(&mockClient, resourceProvider.get());
369 369
370 renderer.initialize(); 370 renderer.initialize();
371 371
372 EXPECT_GT(mockClient.memoryAllocationLimitBytes(), 0ul); 372 EXPECT_GT(mockClient.memoryAllocationLimitBytes(), 0ul);
373 } 373 }
374 374
375 class ClearCountingContext : public FakeWebGraphicsContext3D { 375 class ClearCountingContext : public FakeWebGraphicsContext3D {
376 public: 376 public:
377 ClearCountingContext() : m_clear(0) { } 377 ClearCountingContext() : m_clear(0) { }
378 378
379 virtual void clear(WGC3Dbitfield) 379 virtual void clear(WGC3Dbitfield)
380 { 380 {
381 m_clear++; 381 m_clear++;
382 } 382 }
383 383
384 int clearCount() const { return m_clear; } 384 int clearCount() const { return m_clear; }
385 385
386 private: 386 private:
387 int m_clear; 387 int m_clear;
388 }; 388 };
389 389
390 TEST(CCRendererGLTest2, opaqueBackground) 390 TEST(CCRendererGLTest2, opaqueBackground)
391 { 391 {
392 FakeCCRendererClient mockClient; 392 FakeCCRendererClient mockClient;
393 scoped_ptr<CCGraphicsContext> ccContext(FakeWebCompositorOutputSurface::crea te(adoptPtr(new ClearCountingContext))); 393 scoped_ptr<CCGraphicsContext> ccContext(FakeWebCompositorOutputSurface::crea te(adoptPtr(new ClearCountingContext)));
394 ClearCountingContext* context = static_cast<ClearCountingContext*>(ccContext ->context3D()); 394 ClearCountingContext* context = static_cast<ClearCountingContext*>(ccContext ->context3D());
395 OwnPtr<CCResourceProvider> resourceProvider(CCResourceProvider::create(ccCon text.get())); 395 scoped_ptr<CCResourceProvider> resourceProvider(CCResourceProvider::create(c cContext.get()));
396 FakeCCRendererGL renderer(&mockClient, resourceProvider.get()); 396 FakeCCRendererGL renderer(&mockClient, resourceProvider.get());
397 397
398 mockClient.rootRenderPass()->setHasTransparentBackground(false); 398 mockClient.rootRenderPass()->setHasTransparentBackground(false);
399 399
400 EXPECT_TRUE(renderer.initialize()); 400 EXPECT_TRUE(renderer.initialize());
401 401
402 renderer.drawFrame(mockClient.renderPassesInDrawOrder(), mockClient.renderPa sses()); 402 renderer.drawFrame(mockClient.renderPassesInDrawOrder(), mockClient.renderPa sses());
403 403
404 // On DEBUG builds, render passes with opaque background clear to blue to 404 // On DEBUG builds, render passes with opaque background clear to blue to
405 // easily see regions that were not drawn on the screen. 405 // easily see regions that were not drawn on the screen.
406 #if defined(NDEBUG) 406 #if defined(NDEBUG)
407 EXPECT_EQ(0, context->clearCount()); 407 EXPECT_EQ(0, context->clearCount());
408 #else 408 #else
409 EXPECT_EQ(1, context->clearCount()); 409 EXPECT_EQ(1, context->clearCount());
410 #endif 410 #endif
411 } 411 }
412 412
413 TEST(CCRendererGLTest2, transparentBackground) 413 TEST(CCRendererGLTest2, transparentBackground)
414 { 414 {
415 FakeCCRendererClient mockClient; 415 FakeCCRendererClient mockClient;
416 scoped_ptr<CCGraphicsContext> ccContext(FakeWebCompositorOutputSurface::crea te(adoptPtr(new ClearCountingContext))); 416 scoped_ptr<CCGraphicsContext> ccContext(FakeWebCompositorOutputSurface::crea te(adoptPtr(new ClearCountingContext)));
417 ClearCountingContext* context = static_cast<ClearCountingContext*>(ccContext ->context3D()); 417 ClearCountingContext* context = static_cast<ClearCountingContext*>(ccContext ->context3D());
418 OwnPtr<CCResourceProvider> resourceProvider(CCResourceProvider::create(ccCon text.get())); 418 scoped_ptr<CCResourceProvider> resourceProvider(CCResourceProvider::create(c cContext.get()));
419 FakeCCRendererGL renderer(&mockClient, resourceProvider.get()); 419 FakeCCRendererGL renderer(&mockClient, resourceProvider.get());
420 420
421 mockClient.rootRenderPass()->setHasTransparentBackground(true); 421 mockClient.rootRenderPass()->setHasTransparentBackground(true);
422 422
423 EXPECT_TRUE(renderer.initialize()); 423 EXPECT_TRUE(renderer.initialize());
424 424
425 renderer.drawFrame(mockClient.renderPassesInDrawOrder(), mockClient.renderPa sses()); 425 renderer.drawFrame(mockClient.renderPassesInDrawOrder(), mockClient.renderPa sses());
426 426
427 EXPECT_EQ(1, context->clearCount()); 427 EXPECT_EQ(1, context->clearCount());
428 } 428 }
OLDNEW
« no previous file with comments | « no previous file | cc/layer_tree_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698