OLD | NEW |
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 25 matching lines...) Expand all Loading... |
36 { | 36 { |
37 if (name == GraphicsContext3D::EXTENSIONS) | 37 if (name == GraphicsContext3D::EXTENSIONS) |
38 return WebString("GL_CHROMIUM_set_visibility GL_CHROMIUM_gpu_memory_
manager GL_CHROMIUM_discard_framebuffer"); | 38 return WebString("GL_CHROMIUM_set_visibility GL_CHROMIUM_gpu_memory_
manager GL_CHROMIUM_discard_framebuffer"); |
39 return WebString(); | 39 return WebString(); |
40 } | 40 } |
41 | 41 |
42 // Methods added for test. | 42 // Methods added for test. |
43 int frameCount() { return m_frame; } | 43 int frameCount() { return m_frame; } |
44 void setMemoryAllocation(WebGraphicsMemoryAllocation allocation) | 44 void setMemoryAllocation(WebGraphicsMemoryAllocation allocation) |
45 { | 45 { |
46 ASSERT(CCProxy::isImplThread()); | 46 DCHECK(CCProxy::isImplThread()); |
47 // In single threaded mode we expect this callback on main thread. | 47 // In single threaded mode we expect this callback on main thread. |
48 DebugScopedSetMainThread main; | 48 DebugScopedSetMainThread main; |
49 m_memoryAllocationChangedCallback->onMemoryAllocationChanged(allocation)
; | 49 m_memoryAllocationChangedCallback->onMemoryAllocationChanged(allocation)
; |
50 } | 50 } |
51 | 51 |
52 private: | 52 private: |
53 int m_frame; | 53 int m_frame; |
54 WebGraphicsMemoryAllocationChangedCallbackCHROMIUM* m_memoryAllocationChange
dCallback; | 54 WebGraphicsMemoryAllocationChangedCallbackCHROMIUM* m_memoryAllocationChange
dCallback; |
55 }; | 55 }; |
56 | 56 |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 { | 244 { |
245 if (pname == GraphicsContext3D::MAX_TEXTURE_SIZE) | 245 if (pname == GraphicsContext3D::MAX_TEXTURE_SIZE) |
246 *value = 1024; // MAX_TEXTURE_SIZE is cached client side, so it's OK
to query. | 246 *value = 1024; // MAX_TEXTURE_SIZE is cached client side, so it's OK
to query. |
247 else | 247 else |
248 ADD_FAILURE(); | 248 ADD_FAILURE(); |
249 } | 249 } |
250 | 250 |
251 // We allow querying the shader compilation and program link status in debug
mode, but not release. | 251 // We allow querying the shader compilation and program link status in debug
mode, but not release. |
252 virtual void getProgramiv(WebGLId program, WGC3Denum pname, WGC3Dint* value) | 252 virtual void getProgramiv(WebGLId program, WGC3Denum pname, WGC3Dint* value) |
253 { | 253 { |
254 #ifndef NDEBUG | 254 if (DCHECK_IS_ON()) |
255 *value = 1; | 255 *value = 1; |
256 #else | 256 else |
257 ADD_FAILURE(); | 257 ADD_FAILURE(); |
258 #endif | |
259 } | 258 } |
260 | 259 |
261 virtual void getShaderiv(WebGLId shader, WGC3Denum pname, WGC3Dint* value) | 260 virtual void getShaderiv(WebGLId shader, WGC3Denum pname, WGC3Dint* value) |
262 { | 261 { |
263 #ifndef NDEBUG | 262 if (DCHECK_IS_ON()) |
264 *value = 1; | 263 *value = 1; |
265 #else | 264 else |
266 ADD_FAILURE(); | 265 ADD_FAILURE(); |
267 #endif | |
268 } | 266 } |
269 | 267 |
270 virtual WebString getString(WGC3Denum name) | 268 virtual WebString getString(WGC3Denum name) |
271 { | 269 { |
272 // We allow querying the extension string. | 270 // We allow querying the extension string. |
273 // FIXME: It'd be better to check that we only do this before starting a
ny other expensive work (like starting a compilation) | 271 // FIXME: It'd be better to check that we only do this before starting a
ny other expensive work (like starting a compilation) |
274 if (name != GraphicsContext3D::EXTENSIONS) | 272 if (name != GraphicsContext3D::EXTENSIONS) |
275 ADD_FAILURE(); | 273 ADD_FAILURE(); |
276 return WebString(); | 274 return WebString(); |
277 } | 275 } |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 FakeCCRendererGL renderer(&mockClient, resourceProvider.get()); | 394 FakeCCRendererGL renderer(&mockClient, resourceProvider.get()); |
397 | 395 |
398 mockClient.rootRenderPass()->setHasTransparentBackground(false); | 396 mockClient.rootRenderPass()->setHasTransparentBackground(false); |
399 | 397 |
400 EXPECT_TRUE(renderer.initialize()); | 398 EXPECT_TRUE(renderer.initialize()); |
401 | 399 |
402 renderer.drawFrame(mockClient.renderPassesInDrawOrder(), mockClient.renderPa
sses()); | 400 renderer.drawFrame(mockClient.renderPassesInDrawOrder(), mockClient.renderPa
sses()); |
403 | 401 |
404 // On DEBUG builds, render passes with opaque background clear to blue to | 402 // On DEBUG builds, render passes with opaque background clear to blue to |
405 // easily see regions that were not drawn on the screen. | 403 // easily see regions that were not drawn on the screen. |
406 #if defined(NDEBUG) | 404 if (!DCHECK_IS_ON()) |
407 EXPECT_EQ(0, context->clearCount()); | 405 EXPECT_EQ(0, context->clearCount()); |
408 #else | 406 else |
409 EXPECT_EQ(1, context->clearCount()); | 407 EXPECT_EQ(1, context->clearCount()); |
410 #endif | |
411 } | 408 } |
412 | 409 |
413 TEST(CCRendererGLTest2, transparentBackground) | 410 TEST(CCRendererGLTest2, transparentBackground) |
414 { | 411 { |
415 FakeCCRendererClient mockClient; | 412 FakeCCRendererClient mockClient; |
416 scoped_ptr<CCGraphicsContext> ccContext(FakeWebCompositorOutputSurface::crea
te(adoptPtr(new ClearCountingContext))); | 413 scoped_ptr<CCGraphicsContext> ccContext(FakeWebCompositorOutputSurface::crea
te(adoptPtr(new ClearCountingContext))); |
417 ClearCountingContext* context = static_cast<ClearCountingContext*>(ccContext
->context3D()); | 414 ClearCountingContext* context = static_cast<ClearCountingContext*>(ccContext
->context3D()); |
418 OwnPtr<CCResourceProvider> resourceProvider(CCResourceProvider::create(ccCon
text.get())); | 415 OwnPtr<CCResourceProvider> resourceProvider(CCResourceProvider::create(ccCon
text.get())); |
419 FakeCCRendererGL renderer(&mockClient, resourceProvider.get()); | 416 FakeCCRendererGL renderer(&mockClient, resourceProvider.get()); |
420 | 417 |
421 mockClient.rootRenderPass()->setHasTransparentBackground(true); | 418 mockClient.rootRenderPass()->setHasTransparentBackground(true); |
422 | 419 |
423 EXPECT_TRUE(renderer.initialize()); | 420 EXPECT_TRUE(renderer.initialize()); |
424 | 421 |
425 renderer.drawFrame(mockClient.renderPassesInDrawOrder(), mockClient.renderPa
sses()); | 422 renderer.drawFrame(mockClient.renderPassesInDrawOrder(), mockClient.renderPa
sses()); |
426 | 423 |
427 EXPECT_EQ(1, context->clearCount()); | 424 EXPECT_EQ(1, context->clearCount()); |
428 } | 425 } |
OLD | NEW |