diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-30 19:24:42 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-30 19:24:42 +0000 |
commit | 3bcc6f70eff64f889b51a28aaf1c4ab90c8b992d (patch) | |
tree | 92c99c7621638cc09dc0bf943fcb77fd93d1baf7 | |
parent | e672003f7d20891741310383f7466662308f86c8 (diff) | |
download | chromium_src-3bcc6f70eff64f889b51a28aaf1c4ab90c8b992d.zip chromium_src-3bcc6f70eff64f889b51a28aaf1c4ab90c8b992d.tar.gz chromium_src-3bcc6f70eff64f889b51a28aaf1c4ab90c8b992d.tar.bz2 |
Relands the following. First attempt was reverted because it broke
clang bot (too much inlined). TBR since this just moves some code to
the .cc file.
Makes TestWebGraphicsContext3D::initialize create a stub context and
surface. This is needed otherwise we crash when code tries to access
the current context. Also makes GLContextStub::MakeCurrent set itself
as the current context.
BUG=104360
TEST=none
R=kbr@chromium.org,piman@chromium.org
TBR=kbr@chromium.org,piman@chromium.org
Review URL: http://codereview.chromium.org/8742022
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112264 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ui/gfx/compositor/compositor.gyp | 3 | ||||
-rw-r--r-- | ui/gfx/compositor/test_web_graphics_context_3d.cc | 225 | ||||
-rw-r--r-- | ui/gfx/compositor/test_web_graphics_context_3d.h | 156 | ||||
-rw-r--r-- | ui/gfx/gl/gl_context.cc | 3 | ||||
-rw-r--r-- | ui/gfx/gl/gl_context_stub.cc | 1 |
5 files changed, 285 insertions, 103 deletions
diff --git a/ui/gfx/compositor/compositor.gyp b/ui/gfx/compositor/compositor.gyp index 20c6ab7..648d25b 100644 --- a/ui/gfx/compositor/compositor.gyp +++ b/ui/gfx/compositor/compositor.gyp @@ -60,7 +60,8 @@ 'layer_animator.h', 'screen_rotation.cc', 'screen_rotation.h', - # This is needed for ui tests, so it's always compiled. + # UI tests need TestWebGraphicsContext3D, so we always build it. + 'test_web_graphics_context_3d.cc', 'test_web_graphics_context_3d.h', ], 'conditions': [ diff --git a/ui/gfx/compositor/test_web_graphics_context_3d.cc b/ui/gfx/compositor/test_web_graphics_context_3d.cc new file mode 100644 index 0000000..2d8286c --- /dev/null +++ b/ui/gfx/compositor/test_web_graphics_context_3d.cc @@ -0,0 +1,225 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ui/gfx/compositor/test_web_graphics_context_3d.h" + +#include "ui/gfx/gl/gl_context_stub.h" +#include "ui/gfx/gl/gl_surface_stub.h" + +namespace ui { + +TestWebGraphicsContext3D::TestWebGraphicsContext3D() {} +TestWebGraphicsContext3D::~TestWebGraphicsContext3D() {} + +bool TestWebGraphicsContext3D::initialize(Attributes attributes, + WebKit::WebView* view, + bool render_directly_to_web_view) { + gl_surface_ = new gfx::GLSurfaceStub; + gl_context_ = new gfx::GLContextStub; + gl_context_->MakeCurrent(gl_surface_.get()); + return true; +} + +bool TestWebGraphicsContext3D::makeContextCurrent() { + return true; +} + +int TestWebGraphicsContext3D::width() { + return 0; +} + +int TestWebGraphicsContext3D::height() { + return 0; +} + +bool TestWebGraphicsContext3D::isGLES2Compliant() { + return false; +} + +bool TestWebGraphicsContext3D::readBackFramebuffer( + unsigned char* pixels, + size_t bufferSize, + WebKit::WebGLId framebuffer, + int width, + int height) { + return false; +} + +WebKit::WebGLId TestWebGraphicsContext3D::getPlatformTextureId() { + return 0; +} + +bool TestWebGraphicsContext3D::isContextLost() { + return false; +} + +void* TestWebGraphicsContext3D::mapBufferSubDataCHROMIUM( + WebKit::WGC3Denum target, + WebKit::WGC3Dintptr offset, + WebKit::WGC3Dsizeiptr size, + WebKit::WGC3Denum access) { + return 0; +} + +void* TestWebGraphicsContext3D::mapTexSubImage2DCHROMIUM( + WebKit::WGC3Denum target, + WebKit::WGC3Dint level, + WebKit::WGC3Dint xoffset, + WebKit::WGC3Dint yoffset, + WebKit::WGC3Dsizei width, + WebKit::WGC3Dsizei height, + WebKit::WGC3Denum format, + WebKit::WGC3Denum type, + WebKit::WGC3Denum access) { + return 0; +} + +WebKit::WebString TestWebGraphicsContext3D::getRequestableExtensionsCHROMIUM() { + return WebKit::WebString(); +} + +WebKit::WGC3Denum TestWebGraphicsContext3D::checkFramebufferStatus( + WebKit::WGC3Denum target) { + return GL_FRAMEBUFFER_COMPLETE; +} + +bool TestWebGraphicsContext3D::getActiveAttrib(WebKit::WebGLId program, + WebKit::WGC3Duint index, + ActiveInfo& info) { + return false; +} + +bool TestWebGraphicsContext3D::getActiveUniform(WebKit::WebGLId program, + WebKit::WGC3Duint index, + ActiveInfo& info) { + return false; +} + +WebKit::WGC3Dint TestWebGraphicsContext3D::getAttribLocation( + WebKit::WebGLId program, + const WebKit::WGC3Dchar* name) { + return 0; +} + +TestWebGraphicsContext3D::Attributes +TestWebGraphicsContext3D::getContextAttributes() { + return Attributes(); +} + +WebKit::WGC3Denum TestWebGraphicsContext3D::getError() { + return 0; +} + +void TestWebGraphicsContext3D::getIntegerv(WebKit::WGC3Denum pname, + WebKit::WGC3Dint* value) { + if (pname == GL_MAX_TEXTURE_SIZE) + *value = 1024; +} + +void TestWebGraphicsContext3D::getProgramiv(WebKit::WebGLId program, + WebKit::WGC3Denum pname, + WebKit::WGC3Dint* value) { + if (pname == GL_LINK_STATUS) + *value = 1; +} + +WebKit::WebString TestWebGraphicsContext3D::getProgramInfoLog( + WebKit::WebGLId program) { + return WebKit::WebString(); +} + +void TestWebGraphicsContext3D::getShaderiv(WebKit::WebGLId shader, + WebKit::WGC3Denum pname, + WebKit::WGC3Dint* value) { + if (pname == GL_COMPILE_STATUS) + *value = 1; +} + +WebKit::WebString TestWebGraphicsContext3D::getShaderInfoLog( + WebKit::WebGLId shader) { + return WebKit::WebString(); +} + +WebKit::WebString TestWebGraphicsContext3D::getShaderSource( + WebKit::WebGLId shader) { + return WebKit::WebString(); +} + +WebKit::WebString TestWebGraphicsContext3D::getString(WebKit::WGC3Denum name) { + return WebKit::WebString(); +} + +WebKit::WGC3Dint TestWebGraphicsContext3D::getUniformLocation( + WebKit::WebGLId program, + const WebKit::WGC3Dchar* name) { + return 0; +} + +WebKit::WGC3Dsizeiptr TestWebGraphicsContext3D::getVertexAttribOffset( + WebKit::WGC3Duint index, + WebKit::WGC3Denum pname) { + return 0; +} + +WebKit::WGC3Dboolean TestWebGraphicsContext3D::isBuffer( + WebKit::WebGLId buffer) { + return false; +} + +WebKit::WGC3Dboolean TestWebGraphicsContext3D::isEnabled( + WebKit::WGC3Denum cap) { + return false; +} + +WebKit::WGC3Dboolean TestWebGraphicsContext3D::isFramebuffer( + WebKit::WebGLId framebuffer) { + return false; +} + +WebKit::WGC3Dboolean TestWebGraphicsContext3D::isProgram( + WebKit::WebGLId program) { + return false; +} + +WebKit::WGC3Dboolean TestWebGraphicsContext3D::isRenderbuffer( + WebKit::WebGLId renderbuffer) { + return false; +} + +WebKit::WGC3Dboolean TestWebGraphicsContext3D::isShader( + WebKit::WebGLId shader) { + return false; +} + +WebKit::WGC3Dboolean TestWebGraphicsContext3D::isTexture( + WebKit::WebGLId texture) { + return false; +} + +WebKit::WebGLId TestWebGraphicsContext3D::createBuffer() { + return 1; +} + +WebKit::WebGLId TestWebGraphicsContext3D::createFramebuffer() { + return 1; +} + +WebKit::WebGLId TestWebGraphicsContext3D::createProgram() { + return 1; +} + +WebKit::WebGLId TestWebGraphicsContext3D::createRenderbuffer() { + return 1; +} + +WebKit::WebGLId TestWebGraphicsContext3D::createShader( + WebKit::WGC3Denum value) { + return 1; +} + +WebKit::WebGLId TestWebGraphicsContext3D::createTexture() { + return 1; +} + +} // namespace ui diff --git a/ui/gfx/compositor/test_web_graphics_context_3d.h b/ui/gfx/compositor/test_web_graphics_context_3d.h index 31e6725..55a3086 100644 --- a/ui/gfx/compositor/test_web_graphics_context_3d.h +++ b/ui/gfx/compositor/test_web_graphics_context_3d.h @@ -7,46 +7,46 @@ #pragma once #include "base/logging.h" +#include "base/memory/ref_counted.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebGraphicsContext3D.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" #include "ui/gfx/gl/gl_bindings.h" +namespace gfx { +class GLContext; +class GLSurface; +} + namespace ui { // WebGraphicsContext3D that does nothing. Suitable for testing. class TestWebGraphicsContext3D : public WebKit::WebGraphicsContext3D { public: - TestWebGraphicsContext3D() {}; - virtual ~TestWebGraphicsContext3D() {} + TestWebGraphicsContext3D(); + virtual ~TestWebGraphicsContext3D(); virtual bool initialize(Attributes attributes, WebKit::WebView* view, - bool render_directly_to_web_view) { - return false; - } - virtual bool makeContextCurrent() { return true; } - virtual int width() { return 0; } - virtual int height() { return 0; } + bool render_directly_to_web_view); + virtual bool makeContextCurrent(); + virtual int width(); + virtual int height(); virtual void reshape(int width, int height) {} - virtual bool isGLES2Compliant() { return false; } + virtual bool isGLES2Compliant(); virtual bool readBackFramebuffer(unsigned char* pixels, size_t bufferSize, WebKit::WebGLId framebuffer, int width, - int height) { - return false; - } - virtual WebKit::WebGLId getPlatformTextureId() { return 0; } + int height); + virtual WebKit::WebGLId getPlatformTextureId(); virtual void prepareTexture() {} virtual void postSubBufferCHROMIUM(int x, int y, int width, int height) {} virtual void synthesizeGLError(WebKit::WGC3Denum value) {} - virtual bool isContextLost() { return false; } + virtual bool isContextLost(); virtual void* mapBufferSubDataCHROMIUM(WebKit::WGC3Denum target, WebKit::WGC3Dintptr offset, WebKit::WGC3Dsizeiptr size, - WebKit::WGC3Denum access) { - return 0; - } + WebKit::WGC3Denum access); virtual void unmapBufferSubDataCHROMIUM(const void* data) {} virtual void* mapTexSubImage2DCHROMIUM(WebKit::WGC3Denum target, WebKit::WGC3Dint level, @@ -56,14 +56,10 @@ class TestWebGraphicsContext3D : public WebKit::WebGraphicsContext3D { WebKit::WGC3Dsizei height, WebKit::WGC3Denum format, WebKit::WGC3Denum type, - WebKit::WGC3Denum access) { - return 0; - } + WebKit::WGC3Denum access); virtual void unmapTexSubImage2DCHROMIUM(const void* data) {} virtual void setVisibilityCHROMIUM(bool visible) {} - virtual WebKit::WebString getRequestableExtensionsCHROMIUM() { - return WebKit::WebString(); - } + virtual WebKit::WebString getRequestableExtensionsCHROMIUM(); virtual void requestExtensionCHROMIUM(const char*) {} virtual void blitFramebufferCHROMIUM(WebKit::WGC3Dint src_x0, WebKit::WGC3Dint src_y0, @@ -113,9 +109,7 @@ class TestWebGraphicsContext3D : public WebKit::WebGraphicsContext3D { WebKit::WGC3Dintptr offset, WebKit::WGC3Dsizeiptr size, const void* data) {} - virtual WebKit::WGC3Denum checkFramebufferStatus(WebKit::WGC3Denum target) { - return GL_FRAMEBUFFER_COMPLETE; - } + virtual WebKit::WGC3Denum checkFramebufferStatus(WebKit::WGC3Denum target); virtual void clear(WebKit::WGC3Dbitfield mask) {} virtual void clearColor(WebKit::WGC3Dclampf red, WebKit::WGC3Dclampf green, @@ -175,65 +169,42 @@ class TestWebGraphicsContext3D : public WebKit::WebGraphicsContext3D { virtual void generateMipmap(WebKit::WGC3Denum target) {} virtual bool getActiveAttrib(WebKit::WebGLId program, WebKit::WGC3Duint index, - ActiveInfo& info) { - return false; - } + ActiveInfo& info); virtual bool getActiveUniform(WebKit::WebGLId program, WebKit::WGC3Duint index, - ActiveInfo& info) { - return false; - } + ActiveInfo& info); virtual void getAttachedShaders(WebKit::WebGLId program, WebKit::WGC3Dsizei maxCount, WebKit::WGC3Dsizei* count, WebKit::WebGLId* shaders) {} virtual WebKit::WGC3Dint getAttribLocation(WebKit::WebGLId program, - const WebKit::WGC3Dchar* name) { - return 0; - } + const WebKit::WGC3Dchar* name); virtual void getBooleanv(WebKit::WGC3Denum pname, WebKit::WGC3Dboolean* value) {} virtual void getBufferParameteriv(WebKit::WGC3Denum target, WebKit::WGC3Denum pname, WebKit::WGC3Dint* value) {} - virtual Attributes getContextAttributes() { return Attributes(); } - virtual WebKit::WGC3Denum getError() { return 0; } + virtual Attributes getContextAttributes(); + virtual WebKit::WGC3Denum getError(); virtual void getFloatv(WebKit::WGC3Denum pname, WebKit::WGC3Dfloat* value) {} virtual void getFramebufferAttachmentParameteriv(WebKit::WGC3Denum target, WebKit::WGC3Denum attachment, WebKit::WGC3Denum pname, WebKit::WGC3Dint* value) {} - virtual void getIntegerv(WebKit::WGC3Denum pname, WebKit::WGC3Dint* value) { - if (pname == GL_MAX_TEXTURE_SIZE) - *value = 1024; - } + virtual void getIntegerv(WebKit::WGC3Denum pname, WebKit::WGC3Dint* value); virtual void getProgramiv(WebKit::WebGLId program, WebKit::WGC3Denum pname, - WebKit::WGC3Dint* value) { - if (pname == GL_LINK_STATUS) - *value = 1; - } - virtual WebKit::WebString getProgramInfoLog(WebKit::WebGLId program) { - return WebKit::WebString(); - } + WebKit::WGC3Dint* value); + virtual WebKit::WebString getProgramInfoLog(WebKit::WebGLId program); virtual void getRenderbufferParameteriv(WebKit::WGC3Denum target, WebKit::WGC3Denum pname, WebKit::WGC3Dint* value) {} virtual void getShaderiv(WebKit::WebGLId shader, WebKit::WGC3Denum pname, - WebKit::WGC3Dint* value) { - if (pname == GL_COMPILE_STATUS) - *value = 1; - } - virtual WebKit::WebString getShaderInfoLog(WebKit::WebGLId shader) { - return WebKit::WebString(); - } - virtual WebKit::WebString getShaderSource(WebKit::WebGLId shader) { - return WebKit::WebString(); - } - virtual WebKit::WebString getString(WebKit::WGC3Denum name) { - return WebKit::WebString(); - } + WebKit::WGC3Dint* value); + virtual WebKit::WebString getShaderInfoLog(WebKit::WebGLId shader); + virtual WebKit::WebString getShaderSource(WebKit::WebGLId shader); + virtual WebKit::WebString getString(WebKit::WGC3Denum name); virtual void getTexParameterfv(WebKit::WGC3Denum target, WebKit::WGC3Denum pname, WebKit::WGC3Dfloat* value) {} @@ -247,9 +218,7 @@ class TestWebGraphicsContext3D : public WebKit::WebGraphicsContext3D { WebKit::WGC3Dint location, WebKit::WGC3Dint* value) {} virtual WebKit::WGC3Dint getUniformLocation(WebKit::WebGLId program, - const WebKit::WGC3Dchar* name) { - return 0; - } + const WebKit::WGC3Dchar* name); virtual void getVertexAttribfv(WebKit::WGC3Duint index, WebKit::WGC3Denum pname, WebKit::WGC3Dfloat* value) {} @@ -257,31 +226,15 @@ class TestWebGraphicsContext3D : public WebKit::WebGraphicsContext3D { WebKit::WGC3Denum pname, WebKit::WGC3Dint* value) {} virtual WebKit::WGC3Dsizeiptr getVertexAttribOffset(WebKit::WGC3Duint index, - WebKit::WGC3Denum pname) { - return 0; - } + WebKit::WGC3Denum pname); virtual void hint(WebKit::WGC3Denum target, WebKit::WGC3Denum mode) {} - virtual WebKit::WGC3Dboolean isBuffer(WebKit::WebGLId buffer) { - return false; - } - virtual WebKit::WGC3Dboolean isEnabled(WebKit::WGC3Denum cap) { - return false; - } - virtual WebKit::WGC3Dboolean isFramebuffer(WebKit::WebGLId framebuffer) { - return false; - } - virtual WebKit::WGC3Dboolean isProgram(WebKit::WebGLId program) { - return false; - } - virtual WebKit::WGC3Dboolean isRenderbuffer(WebKit::WebGLId renderbuffer) { - return false; - } - virtual WebKit::WGC3Dboolean isShader(WebKit::WebGLId shader) { - return false; - } - virtual WebKit::WGC3Dboolean isTexture(WebKit::WebGLId texture) { - return false; - } + virtual WebKit::WGC3Dboolean isBuffer(WebKit::WebGLId buffer); + virtual WebKit::WGC3Dboolean isEnabled(WebKit::WGC3Denum cap); + virtual WebKit::WGC3Dboolean isFramebuffer(WebKit::WebGLId framebuffer); + virtual WebKit::WGC3Dboolean isProgram(WebKit::WebGLId program); + virtual WebKit::WGC3Dboolean isRenderbuffer(WebKit::WebGLId renderbuffer); + virtual WebKit::WGC3Dboolean isShader(WebKit::WebGLId shader); + virtual WebKit::WGC3Dboolean isTexture(WebKit::WebGLId texture); virtual void lineWidth(WebKit::WGC3Dfloat) {} virtual void linkProgram(WebKit::WebGLId program) {} virtual void pixelStorei(WebKit::WGC3Denum pname, WebKit::WGC3Dint param) {} @@ -443,20 +396,23 @@ class TestWebGraphicsContext3D : public WebKit::WebGraphicsContext3D { WebKit::WGC3Dint y, WebKit::WGC3Dsizei width, WebKit::WGC3Dsizei height) {} - virtual WebKit::WebGLId createBuffer() { return 1; } - virtual WebKit::WebGLId createFramebuffer() { return 1; } - virtual WebKit::WebGLId createProgram() { return 1; } - virtual WebKit::WebGLId createRenderbuffer() { return 1; } - virtual WebKit::WebGLId createShader(WebKit::WGC3Denum value) { return 1; } - virtual WebKit::WebGLId createTexture() { return 1; } - virtual void deleteBuffer(WebKit::WebGLId id) {} - virtual void deleteFramebuffer(WebKit::WebGLId id) {} - virtual void deleteProgram(WebKit::WebGLId id) {} - virtual void deleteRenderbuffer(WebKit::WebGLId id) {} - virtual void deleteShader(WebKit::WebGLId id) {} - virtual void deleteTexture(WebKit::WebGLId id) {} + virtual WebKit::WebGLId createBuffer(); + virtual WebKit::WebGLId createFramebuffer(); + virtual WebKit::WebGLId createProgram(); + virtual WebKit::WebGLId createRenderbuffer(); + virtual WebKit::WebGLId createShader(WebKit::WGC3Denum value); + virtual WebKit::WebGLId createTexture(); + virtual void deleteBuffer(WebKit::WebGLId) {} + virtual void deleteFramebuffer(WebKit::WebGLId) {} + virtual void deleteProgram(WebKit::WebGLId) {} + virtual void deleteRenderbuffer(WebKit::WebGLId) {} + virtual void deleteShader(WebKit::WebGLId) {} + virtual void deleteTexture(WebKit::WebGLId) {} private: + scoped_refptr<gfx::GLContext> gl_context_; + scoped_refptr<gfx::GLSurface> gl_surface_; + DISALLOW_COPY_AND_ASSIGN(TestWebGraphicsContext3D); }; diff --git a/ui/gfx/gl/gl_context.cc b/ui/gfx/gl/gl_context.cc index 9fc5411..e3b9612 100644 --- a/ui/gfx/gl/gl_context.cc +++ b/ui/gfx/gl/gl_context.cc @@ -69,8 +69,7 @@ GLShareGroup* GLContext::share_group() { return share_group_.get(); } -bool GLContext::LosesAllContextsOnContextLost() -{ +bool GLContext::LosesAllContextsOnContextLost() { switch (GetGLImplementation()) { case kGLImplementationDesktopGL: return false; diff --git a/ui/gfx/gl/gl_context_stub.cc b/ui/gfx/gl/gl_context_stub.cc index 5067413..94c9e1f 100644 --- a/ui/gfx/gl/gl_context_stub.cc +++ b/ui/gfx/gl/gl_context_stub.cc @@ -21,6 +21,7 @@ void GLContextStub::Destroy() { } bool GLContextStub::MakeCurrent(GLSurface* surface) { + SetCurrent(this, surface); return true; } |