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

Side by Side Diff: cc/gl_renderer_unittest.cc

Issue 11150025: Patch from https://codereview.chromium.org/11111005/ without actual file deletes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 | « cc/gl_renderer.cc ('k') | cc/heads_up_display_layer_impl.cc » ('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 "testing/gmock/include/gmock/gmock.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "third_party/khronos/GLES2/gl2.h"
8 #include "CCDrawQuad.h" 11 #include "CCDrawQuad.h"
9 #include "CCPrioritizedTextureManager.h" 12 #include "CCPrioritizedTextureManager.h"
10 #include "CCResourceProvider.h" 13 #include "CCResourceProvider.h"
11 #include "CCSettings.h" 14 #include "CCSettings.h"
12 #include "CCSingleThreadProxy.h" 15 #include "CCSingleThreadProxy.h"
13 #include "CCTestCommon.h" 16 #include "CCTestCommon.h"
14 #include "FakeWebCompositorOutputSurface.h" 17 #include "FakeWebCompositorOutputSurface.h"
15 #include "FakeWebGraphicsContext3D.h" 18 #include "FakeWebGraphicsContext3D.h"
16 #include "GraphicsContext3D.h"
17 #include "WebCompositorInitializer.h" 19 #include "WebCompositorInitializer.h"
18 #include "testing/gmock/include/gmock/gmock.h"
19 #include "testing/gtest/include/gtest/gtest.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 ASSERT(CCProxy::isImplThread()); 46 ASSERT(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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 virtual void getAttachedShaders(WebGLId program, WGC3Dsizei maxCount, WGC3Ds izei* count, WebGLId* shaders) { ADD_FAILURE(); } 235 virtual void getAttachedShaders(WebGLId program, WGC3Dsizei maxCount, WGC3Ds izei* count, WebGLId* shaders) { ADD_FAILURE(); }
236 virtual WGC3Dint getAttribLocation(WebGLId program, const WGC3Dchar* name) { ADD_FAILURE(); return 0; } 236 virtual WGC3Dint getAttribLocation(WebGLId program, const WGC3Dchar* name) { ADD_FAILURE(); return 0; }
237 virtual void getBooleanv(WGC3Denum pname, WGC3Dboolean* value) { ADD_FAILURE (); } 237 virtual void getBooleanv(WGC3Denum pname, WGC3Dboolean* value) { ADD_FAILURE (); }
238 virtual void getBufferParameteriv(WGC3Denum target, WGC3Denum pname, WGC3Din t* value) { ADD_FAILURE(); } 238 virtual void getBufferParameteriv(WGC3Denum target, WGC3Denum pname, WGC3Din t* value) { ADD_FAILURE(); }
239 virtual Attributes getContextAttributes() { ADD_FAILURE(); return m_attrs; } 239 virtual Attributes getContextAttributes() { ADD_FAILURE(); return m_attrs; }
240 virtual WGC3Denum getError() { ADD_FAILURE(); return 0; } 240 virtual WGC3Denum getError() { ADD_FAILURE(); return 0; }
241 virtual void getFloatv(WGC3Denum pname, WGC3Dfloat* value) { ADD_FAILURE(); } 241 virtual void getFloatv(WGC3Denum pname, WGC3Dfloat* value) { ADD_FAILURE(); }
242 virtual void getFramebufferAttachmentParameteriv(WGC3Denum target, WGC3Denum attachment, WGC3Denum pname, WGC3Dint* value) { ADD_FAILURE(); } 242 virtual void getFramebufferAttachmentParameteriv(WGC3Denum target, WGC3Denum attachment, WGC3Denum pname, WGC3Dint* value) { ADD_FAILURE(); }
243 virtual void getIntegerv(WGC3Denum pname, WGC3Dint* value) 243 virtual void getIntegerv(WGC3Denum pname, WGC3Dint* value)
244 { 244 {
245 if (pname == GraphicsContext3D::MAX_TEXTURE_SIZE) 245 if (pname == GL_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 #ifndef NDEBUG
255 *value = 1; 255 *value = 1;
256 #else 256 #else
257 ADD_FAILURE(); 257 ADD_FAILURE();
258 #endif 258 #endif
259 } 259 }
260 260
261 virtual void getShaderiv(WebGLId shader, WGC3Denum pname, WGC3Dint* value) 261 virtual void getShaderiv(WebGLId shader, WGC3Denum pname, WGC3Dint* value)
262 { 262 {
263 #ifndef NDEBUG 263 #ifndef NDEBUG
264 *value = 1; 264 *value = 1;
265 #else 265 #else
266 ADD_FAILURE(); 266 ADD_FAILURE();
267 #endif 267 #endif
268 } 268 }
269 269
270 virtual WebString getString(WGC3Denum name) 270 virtual WebString getString(WGC3Denum name)
271 { 271 {
272 // We allow querying the extension string. 272 // 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) 273 // 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) 274 if (name != GL_EXTENSIONS)
275 ADD_FAILURE(); 275 ADD_FAILURE();
276 return WebString(); 276 return WebString();
277 } 277 }
278 278
279 virtual WebString getProgramInfoLog(WebGLId program) { ADD_FAILURE(); return WebString(); } 279 virtual WebString getProgramInfoLog(WebGLId program) { ADD_FAILURE(); return WebString(); }
280 virtual void getRenderbufferParameteriv(WGC3Denum target, WGC3Denum pname, W GC3Dint* value) { ADD_FAILURE(); } 280 virtual void getRenderbufferParameteriv(WGC3Denum target, WGC3Denum pname, W GC3Dint* value) { ADD_FAILURE(); }
281 281
282 virtual WebString getShaderInfoLog(WebGLId shader) { ADD_FAILURE(); return W ebString(); } 282 virtual WebString getShaderInfoLog(WebGLId shader) { ADD_FAILURE(); return W ebString(); }
283 virtual void getShaderPrecisionFormat(WGC3Denum shadertype, WGC3Denum precis iontype, WGC3Dint* range, WGC3Dint* precision) { ADD_FAILURE(); } 283 virtual void getShaderPrecisionFormat(WGC3Denum shadertype, WGC3Denum precis iontype, WGC3Dint* range, WGC3Dint* precision) { ADD_FAILURE(); }
284 virtual WebString getShaderSource(WebGLId shader) { ADD_FAILURE(); return We bString(); } 284 virtual WebString getShaderSource(WebGLId shader) { ADD_FAILURE(); return We bString(); }
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 | « cc/gl_renderer.cc ('k') | cc/heads_up_display_layer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698