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" |
11 #include "CCSettings.h" | 11 #include "CCSettings.h" |
12 #include "CCSingleThreadProxy.h" | 12 #include "CCSingleThreadProxy.h" |
13 #include "GraphicsContext3D.h" | |
14 #include "cc/test/fake_web_compositor_output_surface.h" | 13 #include "cc/test/fake_web_compositor_output_surface.h" |
15 #include "cc/test/fake_web_graphics_context_3d.h" | 14 #include "cc/test/fake_web_graphics_context_3d.h" |
16 #include "cc/test/test_common.h" | 15 #include "cc/test/test_common.h" |
17 #include "cc/test/web_compositor_initializer.h" | 16 #include "cc/test/web_compositor_initializer.h" |
18 #include "testing/gmock/include/gmock/gmock.h" | 17 #include "testing/gmock/include/gmock/gmock.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 19 #include "third_party/khronos/GLES2/gl2.h" |
20 #include <public/WebTransformationMatrix.h> | 20 #include <public/WebTransformationMatrix.h> |
21 | 21 |
22 using namespace cc; | 22 using namespace cc; |
23 using namespace WebKit; | 23 using namespace WebKit; |
24 using namespace WebKitTests; | 24 using namespace WebKitTests; |
25 | 25 |
26 class FrameCountingMemoryAllocationSettingContext : public FakeWebGraphicsContex
t3D { | 26 class FrameCountingMemoryAllocationSettingContext : public FakeWebGraphicsContex
t3D { |
27 public: | 27 public: |
28 FrameCountingMemoryAllocationSettingContext() : m_frame(0) { } | 28 FrameCountingMemoryAllocationSettingContext() : m_frame(0) { } |
29 | 29 |
30 // WebGraphicsContext3D methods. | 30 // WebGraphicsContext3D methods. |
31 | 31 |
32 // This method would normally do a glSwapBuffers under the hood. | 32 // This method would normally do a glSwapBuffers under the hood. |
33 virtual void prepareTexture() { m_frame++; } | 33 virtual void prepareTexture() { m_frame++; } |
34 virtual void setMemoryAllocationChangedCallbackCHROMIUM(WebGraphicsMemoryAll
ocationChangedCallbackCHROMIUM* callback) { m_memoryAllocationChangedCallback =
callback; } | 34 virtual void setMemoryAllocationChangedCallbackCHROMIUM(WebGraphicsMemoryAll
ocationChangedCallbackCHROMIUM* callback) { m_memoryAllocationChangedCallback =
callback; } |
35 virtual WebString getString(WebKit::WGC3Denum name) | 35 virtual WebString getString(WebKit::WGC3Denum name) |
36 { | 36 { |
37 if (name == GraphicsContext3D::EXTENSIONS) | 37 if (name == GL_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 DCHECK(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. |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 virtual void getAttachedShaders(WebGLId program, WGC3Dsizei maxCount, WGC3Ds
izei* count, WebGLId* shaders) { ADD_FAILURE(); } | 234 virtual void getAttachedShaders(WebGLId program, WGC3Dsizei maxCount, WGC3Ds
izei* count, WebGLId* shaders) { ADD_FAILURE(); } |
235 virtual WGC3Dint getAttribLocation(WebGLId program, const WGC3Dchar* name) {
ADD_FAILURE(); return 0; } | 235 virtual WGC3Dint getAttribLocation(WebGLId program, const WGC3Dchar* name) {
ADD_FAILURE(); return 0; } |
236 virtual void getBooleanv(WGC3Denum pname, WGC3Dboolean* value) { ADD_FAILURE
(); } | 236 virtual void getBooleanv(WGC3Denum pname, WGC3Dboolean* value) { ADD_FAILURE
(); } |
237 virtual void getBufferParameteriv(WGC3Denum target, WGC3Denum pname, WGC3Din
t* value) { ADD_FAILURE(); } | 237 virtual void getBufferParameteriv(WGC3Denum target, WGC3Denum pname, WGC3Din
t* value) { ADD_FAILURE(); } |
238 virtual Attributes getContextAttributes() { ADD_FAILURE(); return m_attrs; } | 238 virtual Attributes getContextAttributes() { ADD_FAILURE(); return m_attrs; } |
239 virtual WGC3Denum getError() { ADD_FAILURE(); return 0; } | 239 virtual WGC3Denum getError() { ADD_FAILURE(); return 0; } |
240 virtual void getFloatv(WGC3Denum pname, WGC3Dfloat* value) { ADD_FAILURE();
} | 240 virtual void getFloatv(WGC3Denum pname, WGC3Dfloat* value) { ADD_FAILURE();
} |
241 virtual void getFramebufferAttachmentParameteriv(WGC3Denum target, WGC3Denum
attachment, WGC3Denum pname, WGC3Dint* value) { ADD_FAILURE(); } | 241 virtual void getFramebufferAttachmentParameteriv(WGC3Denum target, WGC3Denum
attachment, WGC3Denum pname, WGC3Dint* value) { ADD_FAILURE(); } |
242 virtual void getIntegerv(WGC3Denum pname, WGC3Dint* value) | 242 virtual void getIntegerv(WGC3Denum pname, WGC3Dint* value) |
243 { | 243 { |
244 if (pname == GraphicsContext3D::MAX_TEXTURE_SIZE) | 244 if (pname == GL_MAX_TEXTURE_SIZE) |
245 *value = 1024; // MAX_TEXTURE_SIZE is cached client side, so it's OK
to query. | 245 *value = 1024; // MAX_TEXTURE_SIZE is cached client side, so it's OK
to query. |
246 else | 246 else |
247 ADD_FAILURE(); | 247 ADD_FAILURE(); |
248 } | 248 } |
249 | 249 |
250 // We allow querying the shader compilation and program link status in debug
mode, but not release. | 250 // We allow querying the shader compilation and program link status in debug
mode, but not release. |
251 virtual void getProgramiv(WebGLId program, WGC3Denum pname, WGC3Dint* value) | 251 virtual void getProgramiv(WebGLId program, WGC3Denum pname, WGC3Dint* value) |
252 { | 252 { |
253 #ifndef NDEBUG | 253 #ifndef NDEBUG |
254 *value = 1; | 254 *value = 1; |
255 #else | 255 #else |
256 ADD_FAILURE(); | 256 ADD_FAILURE(); |
257 #endif | 257 #endif |
258 } | 258 } |
259 | 259 |
260 virtual void getShaderiv(WebGLId shader, WGC3Denum pname, WGC3Dint* value) | 260 virtual void getShaderiv(WebGLId shader, WGC3Denum pname, WGC3Dint* value) |
261 { | 261 { |
262 #ifndef NDEBUG | 262 #ifndef NDEBUG |
263 *value = 1; | 263 *value = 1; |
264 #else | 264 #else |
265 ADD_FAILURE(); | 265 ADD_FAILURE(); |
266 #endif | 266 #endif |
267 } | 267 } |
268 | 268 |
269 virtual WebString getString(WGC3Denum name) | 269 virtual WebString getString(WGC3Denum name) |
270 { | 270 { |
271 // We allow querying the extension string. | 271 // We allow querying the extension string. |
272 // FIXME: It'd be better to check that we only do this before starting a
ny other expensive work (like starting a compilation) | 272 // FIXME: It'd be better to check that we only do this before starting a
ny other expensive work (like starting a compilation) |
273 if (name != GraphicsContext3D::EXTENSIONS) | 273 if (name != GL_EXTENSIONS) |
274 ADD_FAILURE(); | 274 ADD_FAILURE(); |
275 return WebString(); | 275 return WebString(); |
276 } | 276 } |
277 | 277 |
278 virtual WebString getProgramInfoLog(WebGLId program) { ADD_FAILURE(); return
WebString(); } | 278 virtual WebString getProgramInfoLog(WebGLId program) { ADD_FAILURE(); return
WebString(); } |
279 virtual void getRenderbufferParameteriv(WGC3Denum target, WGC3Denum pname, W
GC3Dint* value) { ADD_FAILURE(); } | 279 virtual void getRenderbufferParameteriv(WGC3Denum target, WGC3Denum pname, W
GC3Dint* value) { ADD_FAILURE(); } |
280 | 280 |
281 virtual WebString getShaderInfoLog(WebGLId shader) { ADD_FAILURE(); return W
ebString(); } | 281 virtual WebString getShaderInfoLog(WebGLId shader) { ADD_FAILURE(); return W
ebString(); } |
282 virtual void getShaderPrecisionFormat(WGC3Denum shadertype, WGC3Denum precis
iontype, WGC3Dint* range, WGC3Dint* precision) { ADD_FAILURE(); } | 282 virtual void getShaderPrecisionFormat(WGC3Denum shadertype, WGC3Denum precis
iontype, WGC3Dint* range, WGC3Dint* precision) { ADD_FAILURE(); } |
283 virtual WebString getShaderSource(WebGLId shader) { ADD_FAILURE(); return We
bString(); } | 283 virtual WebString getShaderSource(WebGLId shader) { ADD_FAILURE(); return We
bString(); } |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 FakeCCRendererGL renderer(&mockClient, resourceProvider.get()); | 418 FakeCCRendererGL renderer(&mockClient, resourceProvider.get()); |
419 | 419 |
420 mockClient.rootRenderPass()->setHasTransparentBackground(true); | 420 mockClient.rootRenderPass()->setHasTransparentBackground(true); |
421 | 421 |
422 EXPECT_TRUE(renderer.initialize()); | 422 EXPECT_TRUE(renderer.initialize()); |
423 | 423 |
424 renderer.drawFrame(mockClient.renderPassesInDrawOrder(), mockClient.renderPa
sses()); | 424 renderer.drawFrame(mockClient.renderPassesInDrawOrder(), mockClient.renderPa
sses()); |
425 | 425 |
426 EXPECT_EQ(1, context->clearCount()); | 426 EXPECT_EQ(1, context->clearCount()); |
427 } | 427 } |
OLD | NEW |