diff options
author | danakj <danakj@chromium.org> | 2016-03-21 21:11:54 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-22 04:13:28 +0000 |
commit | d8fb03aaed3416b77589c154ae1e9c2c832bfa4b (patch) | |
tree | 42112238f1938dd8eed939a197f2df9197530f49 | |
parent | 14c8b52dac1285bbf23514d05e6109aa7edc427f (diff) | |
download | chromium_src-d8fb03aaed3416b77589c154ae1e9c2c832bfa4b.zip chromium_src-d8fb03aaed3416b77589c154ae1e9c2c832bfa4b.tar.gz chromium_src-d8fb03aaed3416b77589c154ae1e9c2c832bfa4b.tar.bz2 |
Remove create/delete methods from WebGraphicsContext3D.
Have callers use the new Gen/Delete methods on GLES2Interface instead.
R=bajones@chromium.org, chrishtr@chromium.org, kbr@chromium.org, pfeldman@chromium.org
TBR=pfeldman
BUG=584497
CQ_INCLUDE_TRYBOTS=tryserver.chromium.win:win_optional_gpu_tests_rel
Review URL: https://codereview.chromium.org/1814263004
Cr-Commit-Position: refs/heads/master@{#382506}
26 files changed, 153 insertions, 317 deletions
diff --git a/components/test_runner/DEPS b/components/test_runner/DEPS index d0f42cc..c2f1ea1 100644 --- a/components/test_runner/DEPS +++ b/components/test_runner/DEPS @@ -4,6 +4,7 @@ include_rules = [ "+gpu/command_buffer/client", "+net/base", "+skia", + "+third_party/khronos/GLES2/gl2.h", "+third_party/skia", "+third_party/WebKit/public/platform", "+third_party/WebKit/public/web", diff --git a/components/test_runner/test_plugin.cc b/components/test_runner/test_plugin.cc index 155fd6b..f840eca 100644 --- a/components/test_runner/test_plugin.cc +++ b/components/test_runner/test_plugin.cc @@ -39,7 +39,7 @@ namespace test_runner { namespace { -void PremultiplyAlpha(const unsigned color_in[3], +void PremultiplyAlpha(const uint8_t color_in[3], float alpha, float color_out[4]) { for (int i = 0; i < 3; ++i) @@ -334,7 +334,7 @@ TestPlugin::Primitive TestPlugin::ParsePrimitive( // FIXME: This method should already exist. Use it. // For now just parse primary colors. -void TestPlugin::ParseColor(const blink::WebString& string, unsigned color[3]) { +void TestPlugin::ParseColor(const blink::WebString& string, uint8_t color[3]) { color[0] = color[1] = color[2] = 0; if (string == "black") return; @@ -359,14 +359,14 @@ bool TestPlugin::ParseBoolean(const blink::WebString& string) { } bool TestPlugin::InitScene() { - if (!context_) + if (!gl_) return true; float color[4]; PremultiplyAlpha(scene_.background_color, scene_.opacity, color); - color_texture_ = context_->createTexture(); - framebuffer_ = context_->createFramebuffer(); + gl_->GenTextures(1, &color_texture_); + gl_->GenFramebuffers(1, &framebuffer_); gl_->Viewport(0, 0, rect_.width, rect_.height); gl_->Disable(GL_DEPTH_TEST); @@ -423,17 +423,17 @@ void TestPlugin::DestroyScene() { scene_.program = 0; } if (scene_.vbo) { - context_->deleteBuffer(scene_.vbo); + gl_->DeleteBuffers(1, &scene_.vbo); scene_.vbo = 0; } if (framebuffer_) { - context_->deleteFramebuffer(framebuffer_); + gl_->DeleteFramebuffers(1, &framebuffer_); framebuffer_ = 0; } if (color_texture_) { - context_->deleteTexture(color_texture_); + gl_->DeleteTextures(1, &color_texture_); color_texture_ = 0; } } @@ -464,7 +464,7 @@ bool TestPlugin::InitProgram() { bool TestPlugin::InitPrimitive() { DCHECK_EQ(scene_.primitive, PrimitiveTriangle); - scene_.vbo = context_->createBuffer(); + gl_->GenBuffers(1, &scene_.vbo); if (!scene_.vbo) return false; @@ -496,8 +496,8 @@ void TestPlugin::DrawPrimitive() { gl_->DrawArrays(GL_TRIANGLES, 0, 3); } -unsigned TestPlugin::LoadShader(unsigned type, const std::string& source) { - unsigned shader = gl_->CreateShader(type); +GLuint TestPlugin::LoadShader(GLenum type, const std::string& source) { + GLuint shader = gl_->CreateShader(type); if (shader) { context_->shaderSource(shader, source.data()); gl_->CompileShader(shader); @@ -512,11 +512,11 @@ unsigned TestPlugin::LoadShader(unsigned type, const std::string& source) { return shader; } -unsigned TestPlugin::LoadProgram(const std::string& vertex_source, - const std::string& fragment_source) { - unsigned vertex_shader = LoadShader(GL_VERTEX_SHADER, vertex_source); - unsigned fragment_shader = LoadShader(GL_FRAGMENT_SHADER, fragment_source); - unsigned program = gl_->CreateProgram(); +GLuint TestPlugin::LoadProgram(const std::string& vertex_source, + const std::string& fragment_source) { + GLuint vertex_shader = LoadShader(GL_VERTEX_SHADER, vertex_source); + GLuint fragment_shader = LoadShader(GL_FRAGMENT_SHADER, fragment_source); + GLuint program = gl_->CreateProgram(); if (vertex_shader && fragment_shader && program) { gl_->AttachShader(program, vertex_shader); gl_->AttachShader(program, fragment_shader); diff --git a/components/test_runner/test_plugin.h b/components/test_runner/test_plugin.h index cc91cbd..9e43bab 100644 --- a/components/test_runner/test_plugin.h +++ b/components/test_runner/test_plugin.h @@ -17,6 +17,7 @@ #include "third_party/WebKit/public/platform/WebLayer.h" #include "third_party/WebKit/public/web/WebPlugin.h" #include "third_party/WebKit/public/web/WebPluginContainer.h" +#include "third_party/khronos/GLES2/gl2.h" namespace blink { class WebFrame; @@ -108,12 +109,12 @@ class TestPlugin : public blink::WebPlugin, public cc::TextureLayerClient { struct Scene { Primitive primitive; - unsigned background_color[3]; - unsigned primitive_color[3]; + uint8_t background_color[3]; + uint8_t primitive_color[3]; float opacity; - unsigned vbo; - unsigned program; + GLuint vbo; + GLuint program; int color_location; int position_location; @@ -132,7 +133,7 @@ class TestPlugin : public blink::WebPlugin, public cc::TextureLayerClient { // Functions for parsing plugin parameters. Primitive ParsePrimitive(const blink::WebString& string); - void ParseColor(const blink::WebString& string, unsigned color[3]); + void ParseColor(const blink::WebString& string, uint8_t color[3]); float ParseOpacity(const blink::WebString& string); bool ParseBoolean(const blink::WebString& string); @@ -143,9 +144,9 @@ class TestPlugin : public blink::WebPlugin, public cc::TextureLayerClient { bool InitProgram(); bool InitPrimitive(); void DrawPrimitive(); - unsigned LoadShader(unsigned type, const std::string& source); - unsigned LoadProgram(const std::string& vertex_source, - const std::string& fragment_source); + GLuint LoadShader(GLenum type, const std::string& source); + GLuint LoadProgram(const std::string& vertex_source, + const std::string& fragment_source); // Functions for drawing scene in Software. void DrawSceneSoftware(void* memory); @@ -157,11 +158,11 @@ class TestPlugin : public blink::WebPlugin, public cc::TextureLayerClient { blink::WebRect rect_; blink::WebGraphicsContext3D* context_; gpu::gles2::GLES2Interface* gl_; - unsigned color_texture_; + GLuint color_texture_; cc::TextureMailbox texture_mailbox_; scoped_ptr<cc::SharedBitmap> shared_bitmap_; bool mailbox_changed_; - unsigned framebuffer_; + GLuint framebuffer_; Scene scene_; scoped_refptr<cc::TextureLayer> layer_; scoped_ptr<blink::WebLayer> web_layer_; diff --git a/gpu/blink/webgraphicscontext3d_impl.cc b/gpu/blink/webgraphicscontext3d_impl.cc index da34cb5..4547528 100644 --- a/gpu/blink/webgraphicscontext3d_impl.cc +++ b/gpu/blink/webgraphicscontext3d_impl.cc @@ -330,48 +330,6 @@ void WebGraphicsContext3DImpl::shaderSource( gl_->ShaderSource(shader, 1, &string, &length); } -WebGLId WebGraphicsContext3DImpl::createBuffer() { - GLuint o; - gl_->GenBuffers(1, &o); - return o; -} - -WebGLId WebGraphicsContext3DImpl::createFramebuffer() { - GLuint o = 0; - gl_->GenFramebuffers(1, &o); - return o; -} - -WebGLId WebGraphicsContext3DImpl::createRenderbuffer() { - GLuint o; - gl_->GenRenderbuffers(1, &o); - return o; -} - -WebGLId WebGraphicsContext3DImpl::createTexture() { - GLuint o; - gl_->GenTextures(1, &o); - return o; -} - -void WebGraphicsContext3DImpl::deleteBuffer(WebGLId buffer) { - gl_->DeleteBuffers(1, &buffer); -} - -void WebGraphicsContext3DImpl::deleteFramebuffer( - WebGLId framebuffer) { - gl_->DeleteFramebuffers(1, &framebuffer); -} - -void WebGraphicsContext3DImpl::deleteRenderbuffer( - WebGLId renderbuffer) { - gl_->DeleteRenderbuffers(1, &renderbuffer); -} - -void WebGraphicsContext3DImpl::deleteTexture(WebGLId texture) { - gl_->DeleteTextures(1, &texture); -} - void WebGraphicsContext3DImpl::setErrorMessageCallback( WebGraphicsContext3D::WebGraphicsErrorMessageCallback* cb) { error_message_callback_ = cb; @@ -382,43 +340,11 @@ void WebGraphicsContext3DImpl::setContextLostCallback( context_lost_callback_ = cb; } -WebGLId WebGraphicsContext3DImpl::createQueryEXT() { - GLuint o; - gl_->GenQueriesEXT(1, &o); - return o; -} - -void WebGraphicsContext3DImpl::deleteQueryEXT( - WebGLId query) { - gl_->DeleteQueriesEXT(1, &query); -} - -WebGLId WebGraphicsContext3DImpl::createValuebufferCHROMIUM() { - GLuint o; - gl_->GenValuebuffersCHROMIUM(1, &o); - return o; -} - -void WebGraphicsContext3DImpl::deleteValuebufferCHROMIUM(WebGLId valuebuffer) { - gl_->DeleteValuebuffersCHROMIUM(1, &valuebuffer); -} - void WebGraphicsContext3DImpl::pushGroupMarkerEXT( const WGC3Dchar* marker) { gl_->PushGroupMarkerEXT(0, marker); } -WebGLId WebGraphicsContext3DImpl::createVertexArrayOES() { - GLuint array; - gl_->GenVertexArraysOES(1, &array); - return array; -} - -void WebGraphicsContext3DImpl::deleteVertexArrayOES( - WebGLId array) { - gl_->DeleteVertexArraysOES(1, &array); -} - DELEGATE_TO_GL_1(beginTransformFeedback, BeginTransformFeedback, WGC3Denum) DELEGATE_TO_GL_3(bindBufferBase, BindBufferBase, WGC3Denum, WGC3Duint, WGC3Duint) @@ -446,22 +372,6 @@ DELEGATE_TO_GL_5(copyBufferSubData, CopyBufferSubData, WGC3Denum, WGC3Denum, DELEGATE_TO_GL_9(copyTexSubImage3D, CopyTexSubImage3D, WGC3Denum, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dsizei, WGC3Dsizei) -WebGLId WebGraphicsContext3DImpl::createSampler() { - GLuint sampler; - gl_->GenSamplers(1, &sampler); - return sampler; -} -WebGLId WebGraphicsContext3DImpl::createTransformFeedback() { - GLuint tf; - gl_->GenTransformFeedbacks(1, &tf); - return tf; -} -void WebGraphicsContext3DImpl::deleteSampler(WebGLId sampler) { - gl_->DeleteSamplers(1, &sampler); -} -void WebGraphicsContext3DImpl::deleteTransformFeedback(WebGLId tf) { - gl_->DeleteTransformFeedbacks(1, &tf); -} DELEGATE_TO_GL(endTransformFeedback, EndTransformFeedback) DELEGATE_TO_GL_5(getActiveUniformBlockName, GetActiveUniformBlockName, WGC3Duint, WGC3Duint, WGC3Dsizei, WGC3Dsizei *, WGC3Dchar *) diff --git a/gpu/blink/webgraphicscontext3d_impl.h b/gpu/blink/webgraphicscontext3d_impl.h index 733a5e8..f799dde 100644 --- a/gpu/blink/webgraphicscontext3d_impl.h +++ b/gpu/blink/webgraphicscontext3d_impl.h @@ -52,16 +52,6 @@ class GPU_BLINK_EXPORT WebGraphicsContext3DImpl void shaderSource(blink::WebGLId shader, const blink::WGC3Dchar* string) override; - blink::WebGLId createBuffer() override; - blink::WebGLId createFramebuffer() override; - blink::WebGLId createRenderbuffer() override; - blink::WebGLId createTexture() override; - - void deleteBuffer(blink::WebGLId) override; - void deleteFramebuffer(blink::WebGLId) override; - void deleteRenderbuffer(blink::WebGLId) override; - void deleteTexture(blink::WebGLId) override; - blink::WebString getRequestableExtensionsCHROMIUM() override; blink::WebString getTranslatedShaderSourceANGLE( @@ -73,18 +63,8 @@ class GPU_BLINK_EXPORT WebGraphicsContext3DImpl void setErrorMessageCallback( WebGraphicsContext3D::WebGraphicsErrorMessageCallback* callback) override; - blink::WebGLId createQueryEXT() override; - void deleteQueryEXT(blink::WebGLId query) override; - - blink::WebGLId createValuebufferCHROMIUM() override; - void deleteValuebufferCHROMIUM(blink::WebGLId) override; - void pushGroupMarkerEXT(const blink::WGC3Dchar* marker) override; - // GL_OES_vertex_array_object - blink::WebGLId createVertexArrayOES() override; - void deleteVertexArrayOES(blink::WebGLId array) override; - // OpenGL ES 3.0 functions not represented by pre-existing extensions void beginTransformFeedback(blink::WGC3Denum primitiveMode) override; void bindBufferBase(blink::WGC3Denum target, @@ -145,10 +125,6 @@ class GPU_BLINK_EXPORT WebGraphicsContext3DImpl blink::WGC3Dint y, blink::WGC3Dsizei width, blink::WGC3Dsizei height) override; - blink::WebGLId createSampler() override; - blink::WebGLId createTransformFeedback() override; - void deleteSampler(blink::WebGLId sampler) override; - void deleteTransformFeedback(blink::WebGLId transformfeedback) override; void endTransformFeedback(void) override; void getActiveUniformBlockName(blink::WGC3Duint program, blink::WGC3Duint uniformBlockIndex, diff --git a/third_party/WebKit/Source/modules/webgl/CHROMIUMValuebuffer.cpp b/third_party/WebKit/Source/modules/webgl/CHROMIUMValuebuffer.cpp index bd13951..9390ee4 100644 --- a/third_party/WebKit/Source/modules/webgl/CHROMIUMValuebuffer.cpp +++ b/third_party/WebKit/Source/modules/webgl/CHROMIUMValuebuffer.cpp @@ -4,6 +4,7 @@ #include "modules/webgl/CHROMIUMValuebuffer.h" +#include "gpu/command_buffer/client/gles2_interface.h" #include "modules/webgl/WebGLRenderingContextBase.h" namespace blink { @@ -23,12 +24,14 @@ CHROMIUMValuebuffer::CHROMIUMValuebuffer(WebGLRenderingContextBase* ctx) : WebGLSharedPlatform3DObject(ctx) , m_hasEverBeenBound(false) { - setObject(ctx->webContext()->createValuebufferCHROMIUM()); + GLuint buffer; + ctx->contextGL()->GenValuebuffersCHROMIUM(1, &buffer); + setObject(buffer); } void CHROMIUMValuebuffer::deleteObjectImpl(WebGraphicsContext3D* context3d, gpu::gles2::GLES2Interface* gl) { - context3d->deleteValuebufferCHROMIUM(m_object); + gl->DeleteValuebuffersCHROMIUM(1, &m_object); m_object = 0; } diff --git a/third_party/WebKit/Source/modules/webgl/WebGLBuffer.cpp b/third_party/WebKit/Source/modules/webgl/WebGLBuffer.cpp index a3144ee..4f8e50e 100644 --- a/third_party/WebKit/Source/modules/webgl/WebGLBuffer.cpp +++ b/third_party/WebKit/Source/modules/webgl/WebGLBuffer.cpp @@ -25,6 +25,7 @@ #include "modules/webgl/WebGLBuffer.h" +#include "gpu/command_buffer/client/gles2_interface.h" #include "modules/webgl/WebGLRenderingContextBase.h" namespace blink { @@ -39,7 +40,9 @@ WebGLBuffer::WebGLBuffer(WebGLRenderingContextBase* ctx) , m_initialTarget(0) , m_size(0) { - setObject(ctx->webContext()->createBuffer()); + GLuint buffer; + ctx->contextGL()->GenBuffers(1, &buffer); + setObject(buffer); } WebGLBuffer::~WebGLBuffer() @@ -50,7 +53,7 @@ WebGLBuffer::~WebGLBuffer() void WebGLBuffer::deleteObjectImpl(WebGraphicsContext3D* context3d, gpu::gles2::GLES2Interface* gl) { - context3d->deleteBuffer(m_object); + gl->DeleteBuffers(1, &m_object); m_object = 0; } diff --git a/third_party/WebKit/Source/modules/webgl/WebGLDrawBuffers.cpp b/third_party/WebKit/Source/modules/webgl/WebGLDrawBuffers.cpp index bd921b8..4142408 100644 --- a/third_party/WebKit/Source/modules/webgl/WebGLDrawBuffers.cpp +++ b/third_party/WebKit/Source/modules/webgl/WebGLDrawBuffers.cpp @@ -101,7 +101,6 @@ void WebGLDrawBuffers::drawBuffersWEBGL(const Vector<GLenum>& buffers) // static bool WebGLDrawBuffers::satisfiesWebGLRequirements(WebGLRenderingContextBase* webglContext) { - WebGraphicsContext3D* context = webglContext->webContext(); gpu::gles2::GLES2Interface* gl = webglContext->contextGL(); Extensions3DUtil* extensionsUtil = webglContext->extensionsUtil(); @@ -113,7 +112,8 @@ bool WebGLDrawBuffers::satisfiesWebGLRequirements(WebGLRenderingContextBase* web if (maxDrawBuffers < 4 || maxColorAttachments < 4) return false; - Platform3DObject fbo = context->createFramebuffer(); + GLuint fbo; + gl->GenFramebuffers(1, &fbo); gl->BindFramebuffer(GL_FRAMEBUFFER, fbo); const unsigned char* buffer = 0; // Chromium doesn't allow init data for depth/stencil tetxures. @@ -122,15 +122,15 @@ bool WebGLDrawBuffers::satisfiesWebGLRequirements(WebGLRenderingContextBase* web || extensionsUtil->supportsExtension("GL_ARB_depth_texture")); bool supportsDepthStencil = (extensionsUtil->supportsExtension("GL_EXT_packed_depth_stencil") || extensionsUtil->supportsExtension("GL_OES_packed_depth_stencil")); - Platform3DObject depthStencil = 0; + GLuint depthStencil = 0; if (supportsDepthStencil) { - depthStencil = context->createTexture(); + gl->GenTextures(1, &depthStencil); gl->BindTexture(GL_TEXTURE_2D, depthStencil); gl->TexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_STENCIL_OES, 1, 1, 0, GL_DEPTH_STENCIL_OES, GL_UNSIGNED_INT_24_8_OES, buffer); } - Platform3DObject depth = 0; + GLuint depth = 0; if (supportsDepth) { - depth = context->createTexture(); + gl->GenTextures(1, &depth); gl->BindTexture(GL_TEXTURE_2D, depth); gl->TexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, 1, 1, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, buffer); } @@ -139,7 +139,8 @@ bool WebGLDrawBuffers::satisfiesWebGLRequirements(WebGLRenderingContextBase* web bool ok = true; GLint maxAllowedBuffers = std::min(maxDrawBuffers, maxColorAttachments); for (GLint i = 0; i < maxAllowedBuffers; ++i) { - Platform3DObject color = context->createTexture(); + GLuint color; + gl->GenTextures(1, &color); colors.append(color); gl->BindTexture(GL_TEXTURE_2D, color); gl->TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer); @@ -169,14 +170,13 @@ bool WebGLDrawBuffers::satisfiesWebGLRequirements(WebGLRenderingContextBase* web } webglContext->restoreCurrentFramebuffer(); - context->deleteFramebuffer(fbo); + gl->DeleteFramebuffers(1, &fbo); webglContext->restoreCurrentTexture2D(); if (supportsDepth) - context->deleteTexture(depth); + gl->DeleteTextures(1, &depth); if (supportsDepthStencil) - context->deleteTexture(depthStencil); - for (size_t i = 0; i < colors.size(); ++i) - context->deleteTexture(colors[i]); + gl->DeleteTextures(1, &depthStencil); + gl->DeleteTextures(colors.size(), colors.data()); return ok; } diff --git a/third_party/WebKit/Source/modules/webgl/WebGLFramebuffer.cpp b/third_party/WebKit/Source/modules/webgl/WebGLFramebuffer.cpp index 86ebce7..43d538b 100644 --- a/third_party/WebKit/Source/modules/webgl/WebGLFramebuffer.cpp +++ b/third_party/WebKit/Source/modules/webgl/WebGLFramebuffer.cpp @@ -201,11 +201,12 @@ WebGLFramebuffer* WebGLFramebuffer::create(WebGLRenderingContextBase* ctx) WebGLFramebuffer::WebGLFramebuffer(WebGLRenderingContextBase* ctx) : WebGLContextObject(ctx) - , m_object(ctx->webContext()->createFramebuffer()) + , m_object(0) , m_destructionInProgress(false) , m_hasEverBeenBound(false) , m_readBuffer(GL_COLOR_ATTACHMENT0) { + ctx->contextGL()->GenFramebuffers(1, &m_object); } WebGLFramebuffer::~WebGLFramebuffer() @@ -367,7 +368,7 @@ void WebGLFramebuffer::deleteObjectImpl(WebGraphicsContext3D* context3d, gpu::gl attachment.value->onDetached(context3d, gl); } - context3d->deleteFramebuffer(m_object); + gl->DeleteFramebuffers(1, &m_object); m_object = 0; } diff --git a/third_party/WebKit/Source/modules/webgl/WebGLFramebuffer.h b/third_party/WebKit/Source/modules/webgl/WebGLFramebuffer.h index 7899c9a..ff3915f 100644 --- a/third_party/WebKit/Source/modules/webgl/WebGLFramebuffer.h +++ b/third_party/WebKit/Source/modules/webgl/WebGLFramebuffer.h @@ -64,7 +64,7 @@ public: static WebGLFramebuffer* create(WebGLRenderingContextBase*); - Platform3DObject object() const { return m_object; } + GLuint object() const { return m_object; } void setAttachmentForBoundFramebuffer(GLenum target, GLenum attachment, GLenum texTarget, WebGLTexture*, GLint level, GLint layer); void setAttachmentForBoundFramebuffer(GLenum target, GLenum attachment, WebGLRenderbuffer*); @@ -114,7 +114,7 @@ private: // Check if a new drawBuffers call should be issued. This is called when we add or remove an attachment. void drawBuffersIfNecessary(bool force); - Platform3DObject m_object; + GLuint m_object; typedef HeapHashMap<GLenum, Member<WebGLAttachment>> AttachmentMap; diff --git a/third_party/WebKit/Source/modules/webgl/WebGLQuery.cpp b/third_party/WebKit/Source/modules/webgl/WebGLQuery.cpp index ddebb24..1657d56 100644 --- a/third_party/WebKit/Source/modules/webgl/WebGLQuery.cpp +++ b/third_party/WebKit/Source/modules/webgl/WebGLQuery.cpp @@ -31,7 +31,9 @@ WebGLQuery::WebGLQuery(WebGL2RenderingContextBase* ctx) , m_queryResultAvailable(false) , m_queryResult(0) { - setObject(ctx->webContext()->createQueryEXT()); + GLuint query; + ctx->contextGL()->GenQueriesEXT(1, &query); + setObject(query); } void WebGLQuery::setTarget(GLenum target) @@ -43,7 +45,7 @@ void WebGLQuery::setTarget(GLenum target) void WebGLQuery::deleteObjectImpl(WebGraphicsContext3D* context3d, gpu::gles2::GLES2Interface* gl) { - context3d->deleteQueryEXT(m_object); + gl->DeleteQueriesEXT(1, &m_object); m_object = 0; } diff --git a/third_party/WebKit/Source/modules/webgl/WebGLRenderbuffer.cpp b/third_party/WebKit/Source/modules/webgl/WebGLRenderbuffer.cpp index e71d4e6..8e4d7cd 100644 --- a/third_party/WebKit/Source/modules/webgl/WebGLRenderbuffer.cpp +++ b/third_party/WebKit/Source/modules/webgl/WebGLRenderbuffer.cpp @@ -25,6 +25,7 @@ #include "modules/webgl/WebGLRenderbuffer.h" +#include "gpu/command_buffer/client/gles2_interface.h" #include "modules/webgl/WebGLRenderingContextBase.h" namespace blink { @@ -47,12 +48,14 @@ WebGLRenderbuffer::WebGLRenderbuffer(WebGLRenderingContextBase* ctx) , m_height(0) , m_hasEverBeenBound(false) { - setObject(ctx->webContext()->createRenderbuffer()); + GLuint rbo; + ctx->contextGL()->GenRenderbuffers(1, &rbo); + setObject(rbo); } void WebGLRenderbuffer::deleteObjectImpl(WebGraphicsContext3D* context3d, gpu::gles2::GLES2Interface* gl) { - context3d->deleteRenderbuffer(m_object); + gl->DeleteRenderbuffers(1, &m_object); m_object = 0; } diff --git a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp index cc97dc8..71888dc 100644 --- a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp +++ b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp @@ -4102,7 +4102,7 @@ void WebGLRenderingContextBase::texImageCanvasByGPU(TexImageByGPUType functionTy targetLevel = 0; targetInternalformat = GL_RGBA; targetType = GL_UNSIGNED_BYTE; - targetTexture = webContext()->createTexture(); + contextGL()->GenTextures(1, &targetTexture); contextGL()->BindTexture(GL_TEXTURE_2D, targetTexture); contextGL()->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); contextGL()->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); @@ -4128,7 +4128,8 @@ void WebGLRenderingContextBase::texImageCanvasByGPU(TexImageByGPUType functionTy } if (!possibleDirectCopy) { - WebGLId tmpFBO = webContext()->createFramebuffer(); + GLuint tmpFBO; + contextGL()->GenFramebuffers(1, &tmpFBO); contextGL()->BindFramebuffer(GL_FRAMEBUFFER, tmpFBO); contextGL()->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, targetTexture, 0); contextGL()->BindTexture(texture->getTarget(), texture->object()); @@ -4141,8 +4142,8 @@ void WebGLRenderingContextBase::texImageCanvasByGPU(TexImageByGPUType functionTy } contextGL()->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0); restoreCurrentFramebuffer(); - webContext()->deleteFramebuffer(tmpFBO); - webContext()->deleteTexture(targetTexture); + contextGL()->DeleteFramebuffers(1, &tmpFBO); + contextGL()->DeleteTextures(1, &targetTexture); } } diff --git a/third_party/WebKit/Source/modules/webgl/WebGLSampler.cpp b/third_party/WebKit/Source/modules/webgl/WebGLSampler.cpp index eb4324f..2ef7eaa 100644 --- a/third_party/WebKit/Source/modules/webgl/WebGLSampler.cpp +++ b/third_party/WebKit/Source/modules/webgl/WebGLSampler.cpp @@ -4,6 +4,7 @@ #include "modules/webgl/WebGLSampler.h" +#include "gpu/command_buffer/client/gles2_interface.h" #include "modules/webgl/WebGL2RenderingContextBase.h" namespace blink { @@ -22,12 +23,14 @@ WebGLSampler::~WebGLSampler() WebGLSampler::WebGLSampler(WebGL2RenderingContextBase* ctx) : WebGLSharedPlatform3DObject(ctx) { - setObject(ctx->webContext()->createSampler()); + GLuint sampler; + ctx->contextGL()->GenSamplers(1, &sampler); + setObject(sampler); } void WebGLSampler::deleteObjectImpl(WebGraphicsContext3D* context3d, gpu::gles2::GLES2Interface* gl) { - context3d->deleteSampler(m_object); + gl->DeleteSamplers(1, &m_object); m_object = 0; } diff --git a/third_party/WebKit/Source/modules/webgl/WebGLTexture.cpp b/third_party/WebKit/Source/modules/webgl/WebGLTexture.cpp index d6ebe30..0985d33 100644 --- a/third_party/WebKit/Source/modules/webgl/WebGLTexture.cpp +++ b/third_party/WebKit/Source/modules/webgl/WebGLTexture.cpp @@ -25,6 +25,7 @@ #include "modules/webgl/WebGLTexture.h" +#include "gpu/command_buffer/client/gles2_interface.h" #include "modules/webgl/WebGLRenderingContextBase.h" namespace blink { @@ -38,7 +39,9 @@ WebGLTexture::WebGLTexture(WebGLRenderingContextBase* ctx) : WebGLSharedPlatform3DObject(ctx) , m_target(0) { - setObject(ctx->webContext()->createTexture()); + GLuint texture; + ctx->contextGL()->GenTextures(1, &texture); + setObject(texture); } WebGLTexture::~WebGLTexture() @@ -59,7 +62,7 @@ void WebGLTexture::setTarget(GLenum target) void WebGLTexture::deleteObjectImpl(WebGraphicsContext3D* context3d, gpu::gles2::GLES2Interface* gl) { - context3d->deleteTexture(m_object); + gl->DeleteTextures(1, &m_object); m_object = 0; } diff --git a/third_party/WebKit/Source/modules/webgl/WebGLTimerQueryEXT.cpp b/third_party/WebKit/Source/modules/webgl/WebGLTimerQueryEXT.cpp index 5ebdd0e..8f7073d 100644 --- a/third_party/WebKit/Source/modules/webgl/WebGLTimerQueryEXT.cpp +++ b/third_party/WebKit/Source/modules/webgl/WebGLTimerQueryEXT.cpp @@ -32,7 +32,7 @@ WebGLTimerQueryEXT::WebGLTimerQueryEXT(WebGLRenderingContextBase* ctx) , m_queryResultAvailable(false) , m_queryResult(0) { - m_queryId = context()->webContext()->createQueryEXT(); + context()->contextGL()->GenQueriesEXT(1, &m_queryId); } void WebGLTimerQueryEXT::resetCachedResult() @@ -82,7 +82,7 @@ GLuint64 WebGLTimerQueryEXT::getQueryResult() void WebGLTimerQueryEXT::deleteObjectImpl(WebGraphicsContext3D* context3d, gpu::gles2::GLES2Interface* gl) { - context3d->deleteQueryEXT(m_queryId); + gl->DeleteQueriesEXT(1, &m_queryId); m_queryId = 0; } diff --git a/third_party/WebKit/Source/modules/webgl/WebGLTransformFeedback.cpp b/third_party/WebKit/Source/modules/webgl/WebGLTransformFeedback.cpp index f4075ad..80cc902 100644 --- a/third_party/WebKit/Source/modules/webgl/WebGLTransformFeedback.cpp +++ b/third_party/WebKit/Source/modules/webgl/WebGLTransformFeedback.cpp @@ -4,6 +4,7 @@ #include "modules/webgl/WebGLTransformFeedback.h" +#include "gpu/command_buffer/client/gles2_interface.h" #include "modules/webgl/WebGL2RenderingContextBase.h" namespace blink { @@ -26,12 +27,14 @@ WebGLTransformFeedback::WebGLTransformFeedback(WebGL2RenderingContextBase* ctx) , m_paused(false) , m_program(nullptr) { - setObject(ctx->webContext()->createTransformFeedback()); + GLuint tf; + ctx->contextGL()->GenTransformFeedbacks(1, &tf); + setObject(tf); } void WebGLTransformFeedback::deleteObjectImpl(WebGraphicsContext3D* context3d, gpu::gles2::GLES2Interface* gl) { - context3d->deleteTransformFeedback(m_object); + gl->DeleteTransformFeedbacks(1, &m_object); m_object = 0; } diff --git a/third_party/WebKit/Source/modules/webgl/WebGLVertexArrayObjectBase.cpp b/third_party/WebKit/Source/modules/webgl/WebGLVertexArrayObjectBase.cpp index 3861be1..802f062 100644 --- a/third_party/WebKit/Source/modules/webgl/WebGLVertexArrayObjectBase.cpp +++ b/third_party/WebKit/Source/modules/webgl/WebGLVertexArrayObjectBase.cpp @@ -4,6 +4,7 @@ #include "modules/webgl/WebGLVertexArrayObjectBase.h" +#include "gpu/command_buffer/client/gles2_interface.h" #include "modules/webgl/WebGLRenderingContextBase.h" namespace blink { @@ -22,7 +23,7 @@ WebGLVertexArrayObjectBase::WebGLVertexArrayObjectBase(WebGLRenderingContextBase case VaoTypeDefault: break; default: - m_object = context()->webContext()->createVertexArrayOES(); + context()->contextGL()->GenVertexArraysOES(1, &m_object); break; } } @@ -55,7 +56,7 @@ void WebGLVertexArrayObjectBase::deleteObjectImpl(WebGraphicsContext3D* context3 case VaoTypeDefault: break; default: - context3d->deleteVertexArrayOES(m_object); + gl->DeleteVertexArraysOES(1, &m_object); m_object = 0; break; } diff --git a/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp b/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp index 26b0e05..daed9b9 100644 --- a/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp +++ b/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp @@ -258,12 +258,8 @@ Canvas2DLayerBridge::ImageInfo Canvas2DLayerBridge::createIOSurfaceBackedTexture if (!imageId) return Canvas2DLayerBridge::ImageInfo(); - GLuint textureId= webContext->createTexture(); - if (!textureId) { - gl->DestroyImageCHROMIUM(imageId); - return Canvas2DLayerBridge::ImageInfo(); - } - + GLuint textureId; + gl->GenTextures(1, &textureId); GLenum target = GC3D_TEXTURE_RECTANGLE_ARB; gl->BindTexture(target, textureId); gl->TexParameteri(target, GL_TEXTURE_MAG_FILTER, getGLFilter()); @@ -286,7 +282,7 @@ void Canvas2DLayerBridge::deleteCHROMIUMImage(ImageInfo info) gl->BindTexture(target, info.m_textureId); gl->ReleaseTexImage2DCHROMIUM(target, info.m_imageId); gl->DestroyImageCHROMIUM(info.m_imageId); - webContext->deleteTexture(info.m_textureId); + gl->DeleteTextures(1, &info.m_textureId); gl->BindTexture(target, 0); resetSkiaTextureBinding(); diff --git a/third_party/WebKit/Source/platform/graphics/ImageBuffer.cpp b/third_party/WebKit/Source/platform/graphics/ImageBuffer.cpp index 6d81dc8..9b472d6 100644 --- a/third_party/WebKit/Source/platform/graphics/ImageBuffer.cpp +++ b/third_party/WebKit/Source/platform/graphics/ImageBuffer.cpp @@ -224,7 +224,7 @@ bool ImageBuffer::copyToPlatformTexture(WebGraphicsContext3D* context, gpu::gles // The canvas is stored in an inverted position, so the flip semantics are reversed. gl->CopyTextureCHROMIUM(sourceTexture, texture, internalFormat, destType, flipY ? GL_FALSE : GL_TRUE, GL_FALSE, premultiplyAlpha ? GL_FALSE : GL_TRUE); - context->deleteTexture(sourceTexture); + gl->DeleteTextures(1, &sourceTexture); const GLuint64 contextFenceSync = gl->InsertFenceSyncCHROMIUM(); diff --git a/third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp b/third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp index ca5aa84..ab788be 100644 --- a/third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp +++ b/third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp @@ -276,12 +276,7 @@ bool DrawingBuffer::prepareMailbox(WebExternalTextureMailbox* outMailbox, WebExt // No buffer available to recycle, create a new one. if (!frontColorBufferMailbox) { - TextureInfo newTexture = createTextureAndAllocateMemory(m_size); - // Bad things happened, abandon ship. - if (!newTexture.textureId) - return false; - - frontColorBufferMailbox = createNewMailbox(newTexture); + frontColorBufferMailbox = createNewMailbox(createTextureAndAllocateMemory(m_size)); } if (m_preserveDrawingBuffer == Discard) { @@ -439,7 +434,7 @@ void DrawingBuffer::deleteMailbox(const WebExternalTextureMailbox& mailbox) deleteChromiumImageForTexture(&m_textureMailboxes[i]->textureInfo); - m_context->deleteTexture(m_textureMailboxes[i]->textureInfo.textureId); + m_gl->DeleteTextures(1, &m_textureMailboxes[i]->textureInfo.textureId); m_textureMailboxes.remove(i); return; } @@ -469,7 +464,7 @@ bool DrawingBuffer::initialize(const IntSize& size) } m_sampleCount = std::min(4, maxSampleCount); - m_fbo = m_context->createFramebuffer(); + m_gl->GenFramebuffers(1, &m_fbo); m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); createSecondaryBuffers(); @@ -550,7 +545,7 @@ bool DrawingBuffer::copyToPlatformTexture(WebGraphicsContext3D* context, gpu::gl gl->CopyTextureCHROMIUM(sourceTexture, texture, internalFormat, destType, flipY, unpackPremultiplyAlphaNeeded, unpackUnpremultiplyAlphaNeeded); - context->deleteTexture(sourceTexture); + gl->DeleteTextures(1, &sourceTexture); const GLuint64 fenceSync = gl->InsertFenceSyncCHROMIUM(); @@ -601,20 +596,20 @@ void DrawingBuffer::beginDestruction() deleteMailbox(m_recycledMailboxQueue.takeLast()); if (m_multisampleFBO) - m_context->deleteFramebuffer(m_multisampleFBO); + m_gl->DeleteFramebuffers(1, &m_multisampleFBO); if (m_fbo) - m_context->deleteFramebuffer(m_fbo); + m_gl->DeleteFramebuffers(1, &m_fbo); if (m_multisampleColorBuffer) - m_context->deleteRenderbuffer(m_multisampleColorBuffer); + m_gl->DeleteRenderbuffers(1, &m_multisampleColorBuffer); if (m_depthStencilBuffer) - m_context->deleteRenderbuffer(m_depthStencilBuffer); + m_gl->DeleteRenderbuffers(1, &m_depthStencilBuffer); if (m_colorBuffer.textureId) { deleteChromiumImageForTexture(&m_colorBuffer); - m_context->deleteTexture(m_colorBuffer.textureId); + m_gl->DeleteTextures(1, &m_colorBuffer.textureId); } setSize(IntSize()); @@ -632,16 +627,13 @@ void DrawingBuffer::beginDestruction() WebGLId DrawingBuffer::createColorTexture(const TextureParameters& parameters) { - WebGLId offscreenColorTexture = m_context->createTexture(); - if (!offscreenColorTexture) - return 0; - + GLuint offscreenColorTexture; + m_gl->GenTextures(1, &offscreenColorTexture); m_gl->BindTexture(parameters.target, offscreenColorTexture); m_gl->TexParameteri(parameters.target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); m_gl->TexParameteri(parameters.target, GL_TEXTURE_MIN_FILTER, GL_LINEAR); m_gl->TexParameteri(parameters.target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); m_gl->TexParameteri(parameters.target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - return offscreenColorTexture; } @@ -649,9 +641,9 @@ void DrawingBuffer::createSecondaryBuffers() { // create a multisample FBO if (m_antiAliasingMode == MSAAExplicitResolve) { - m_multisampleFBO = m_context->createFramebuffer(); + m_gl->GenFramebuffers(1, &m_multisampleFBO); m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO); - m_multisampleColorBuffer = m_context->createRenderbuffer(); + m_gl->GenRenderbuffers(1, &m_multisampleColorBuffer); } } @@ -692,7 +684,7 @@ void DrawingBuffer::resizeDepthStencil(const IntSize& size) return; if (!m_depthStencilBuffer) - m_depthStencilBuffer = m_context->createRenderbuffer(); + m_gl->GenRenderbuffers(1, &m_depthStencilBuffer); m_gl->BindRenderbuffer(GL_RENDERBUFFER, m_depthStencilBuffer); if (m_antiAliasingMode == MSAAImplicitResolve) m_gl->RenderbufferStorageMultisampleEXT(GL_RENDERBUFFER, m_sampleCount, GL_DEPTH24_STENCIL8_OES, size.width(), size.height()); @@ -878,9 +870,9 @@ bool DrawingBuffer::paintRenderingResultsToImageData(int& width, int& height, So WTF::ArrayBufferContents pixels(width * height, 4, WTF::ArrayBufferContents::NotShared, WTF::ArrayBufferContents::DontInitialize); - GLint fbo = 0; + GLuint fbo = 0; if (sourceBuffer == FrontBuffer && m_frontColorBuffer.texInfo.textureId) { - fbo = m_context->createFramebuffer(); + m_gl->GenFramebuffers(1, &fbo); m_gl->BindFramebuffer(GL_FRAMEBUFFER, fbo); m_gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_frontColorBuffer.texInfo.parameters.target, m_frontColorBuffer.texInfo.textureId, 0); } else { @@ -892,7 +884,7 @@ bool DrawingBuffer::paintRenderingResultsToImageData(int& width, int& height, So if (fbo) { m_gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_frontColorBuffer.texInfo.parameters.target, 0, 0); - m_context->deleteFramebuffer(fbo); + m_gl->DeleteFramebuffers(1, &fbo); } restoreFramebufferBindings(); @@ -982,11 +974,6 @@ DrawingBuffer::TextureInfo DrawingBuffer::createTextureAndAllocateMemory(const I return createDefaultTextureAndAllocateMemory(size); WebGLId textureId = createColorTexture(parameters); - if (!textureId) { - m_gl->DestroyImageCHROMIUM(imageId); - return createDefaultTextureAndAllocateMemory(size); - } - m_gl->BindTexImage2DCHROMIUM(parameters.target, imageId); TextureInfo info; diff --git a/third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.h b/third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.h index 856619c..83d531fd 100644 --- a/third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.h +++ b/third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.h @@ -311,7 +311,7 @@ private: WebGraphicsContext3D::Attributes m_requestedAttributes; bool m_multisampleExtensionSupported; bool m_discardFramebufferSupported; - Platform3DObject m_fbo; + GLuint m_fbo; // DrawingBuffer's output is double-buffered. m_colorBuffer is the back buffer. TextureInfo m_colorBuffer; struct FrontBufferInfo { @@ -323,11 +323,11 @@ private: OwnPtr<SameThreadClosure> m_newMailboxCallback; // This is used when the user requests either a depth or stencil buffer. - Platform3DObject m_depthStencilBuffer; + GLuint m_depthStencilBuffer; // For multisampling. - Platform3DObject m_multisampleFBO; - Platform3DObject m_multisampleColorBuffer; + GLuint m_multisampleFBO; + GLuint m_multisampleColorBuffer; // True if our contents have been modified since the last presentation of this buffer. bool m_contentsChanged; diff --git a/third_party/WebKit/Source/platform/graphics/gpu/DrawingBufferTest.cpp b/third_party/WebKit/Source/platform/graphics/gpu/DrawingBufferTest.cpp index 44fa3e3..2909155 100644 --- a/third_party/WebKit/Source/platform/graphics/gpu/DrawingBufferTest.cpp +++ b/third_party/WebKit/Source/platform/graphics/gpu/DrawingBufferTest.cpp @@ -168,26 +168,33 @@ public: memcpy(syncToken, &fenceSync, sizeof(fenceSync)); } - uint32_t boundTexture() const { return m_boundTexture; } - uint32_t boundTextureTarget() const { return m_boundTextureTarget; } - uint32_t mostRecentlyWaitedSyncToken() const { return m_mostRecentlyWaitedSyncToken; } - uint32_t currentImageId() const { return m_currentImageId; } + void GenTextures(GLsizei n, GLuint* textures) override + { + static GLuint id = 1; + for (GLsizei i = 0; i < n; ++i) + textures[i] = id++; + } + + GLuint boundTexture() const { return m_boundTexture; } + GLuint boundTextureTarget() const { return m_boundTextureTarget; } + GLuint mostRecentlyWaitedSyncToken() const { return m_mostRecentlyWaitedSyncToken; } + GLuint currentImageId() const { return m_currentImageId; } IntSize mostRecentlyProducedSize() const { return m_mostRecentlyProducedSize; } bool allowImageChromium() const { return m_allowImageChromium; } void setAllowImageChromium(bool allow) { m_allowImageChromium = allow; } private: - uint32_t m_boundTexture = 0; - uint32_t m_boundTextureTarget = 0; - uint32_t m_mostRecentlyWaitedSyncToken = 0; + GLuint m_boundTexture = 0; + GLuint m_boundTextureTarget = 0; + GLuint m_mostRecentlyWaitedSyncToken = 0; WGC3Dbyte m_currentMailboxByte = 0; IntSize m_mostRecentlyProducedSize; bool m_allowImageChromium = true; - uint32_t m_currentImageId = 1; - HashMap<uint32_t, IntSize> m_textureSizes; - HashMap<uint32_t, IntSize> m_imageSizes; - HashMap<uint32_t, uint32_t> m_imageToTextureMap; + GLuint m_currentImageId = 1; + HashMap<GLuint, IntSize> m_textureSizes; + HashMap<GLuint, IntSize> m_imageSizes; + HashMap<GLuint, GLuint> m_imageToTextureMap; }; class WebGraphicsContext3DForTests : public MockWebGraphicsContext3D { @@ -618,22 +625,29 @@ public: } } - uint32_t stencilAttachment() const { return m_stencilAttachment; } - uint32_t depthAttachment() const { return m_depthAttachment; } - uint32_t depthStencilAttachment() const { return m_depthStencilAttachment; } + void GenRenderbuffers(GLsizei n, GLuint* renderbuffers) override + { + for (GLsizei i = 0; i < n; ++i) + renderbuffers[i] = m_nextGenRenderbufferId++; + } + + GLuint stencilAttachment() const { return m_stencilAttachment; } + GLuint depthAttachment() const { return m_depthAttachment; } + GLuint depthStencilAttachment() const { return m_depthStencilAttachment; } + size_t numAllocatedRenderBuffer() const { return m_nextGenRenderbufferId - 1; } private: - uint32_t m_depthAttachment = 0; - uint32_t m_stencilAttachment = 0; - uint32_t m_depthStencilAttachment = 0; + GLuint m_nextGenRenderbufferId = 1; + GLuint m_depthAttachment = 0; + GLuint m_stencilAttachment = 0; + GLuint m_depthStencilAttachment = 0; }; class DepthStencilTrackingContext : public MockWebGraphicsContext3D { public: - DepthStencilTrackingContext() : m_nextRenderBufferId(1) {} ~DepthStencilTrackingContext() override {} - int numAllocatedRenderBuffer() const { return m_nextRenderBufferId - 1; } + size_t numAllocatedRenderBuffer() const { return m_contextGL.numAllocatedRenderBuffer(); } WebGLId stencilAttachment() const { return m_contextGL.stencilAttachment(); } WebGLId depthAttachment() const { return m_contextGL.depthAttachment(); } WebGLId depthStencilAttachment() const { return m_contextGL.depthStencilAttachment(); } @@ -646,15 +660,9 @@ public: return WebString(); } - WebGLId createRenderbuffer() override - { - return ++m_nextRenderBufferId; - } - gpu::gles2::GLES2Interface* getGLES2Interface() override { return &m_contextGL; } private: - WebGLId m_nextRenderBufferId; DepthStencilTrackingGLES2Interface m_contextGL; }; @@ -667,7 +675,7 @@ struct DepthStencilTestCase { bool requestStencil; bool requestDepth; - int expectedRenderBuffers; + size_t expectedRenderBuffers; const char* const testCaseName; }; diff --git a/third_party/WebKit/Source/platform/graphics/gpu/SharedContextRateLimiter.cpp b/third_party/WebKit/Source/platform/graphics/gpu/SharedContextRateLimiter.cpp index 4b0dbc7..1770d7e 100644 --- a/third_party/WebKit/Source/platform/graphics/gpu/SharedContextRateLimiter.cpp +++ b/third_party/WebKit/Source/platform/graphics/gpu/SharedContextRateLimiter.cpp @@ -43,12 +43,12 @@ void SharedContextRateLimiter::tick() return; gpu::gles2::GLES2Interface* gl = m_contextProvider->contextGL(); - if (!gl || gl->GetGraphicsResetStatusKHR() != GL_NO_ERROR) return; - WebGraphicsContext3D* context = m_contextProvider->context3d(); - m_queries.append(m_canUseSyncQueries ? context->createQueryEXT() : 0); + m_queries.append(0); + if (m_canUseSyncQueries) + gl->GenQueriesEXT(1, &m_queries.last()); if (m_canUseSyncQueries) { gl->BeginQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM, m_queries.last()); gl->EndQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM); @@ -57,7 +57,7 @@ void SharedContextRateLimiter::tick() if (m_canUseSyncQueries) { WGC3Duint result; gl->GetQueryObjectuivEXT(m_queries.first(), GL_QUERY_RESULT_EXT, &result); - context->deleteQueryEXT(m_queries.first()); + gl->DeleteQueriesEXT(1, &m_queries.first()); m_queries.removeFirst(); } else { gl->Finish(); @@ -73,9 +73,8 @@ void SharedContextRateLimiter::reset() gpu::gles2::GLES2Interface* gl = m_contextProvider->contextGL(); if (gl && gl->GetGraphicsResetStatusKHR() == GL_NO_ERROR) { - WebGraphicsContext3D* context = m_contextProvider->context3d(); while (m_queries.size() > 0) { - context->deleteQueryEXT(m_queries.first()); + gl->DeleteQueriesEXT(1, &m_queries.first()); m_queries.removeFirst(); } } else { diff --git a/third_party/WebKit/Source/platform/graphics/test/MockWebGraphicsContext3D.h b/third_party/WebKit/Source/platform/graphics/test/MockWebGraphicsContext3D.h index 66f8aec..73ef50e 100644 --- a/third_party/WebKit/Source/platform/graphics/test/MockWebGraphicsContext3D.h +++ b/third_party/WebKit/Source/platform/graphics/test/MockWebGraphicsContext3D.h @@ -55,45 +55,6 @@ public: virtual void shaderSource(WebGLId shader, const WGC3Dchar* string) { } - virtual void genBuffers(WGC3Dsizei count, WebGLId* ids) - { - for (int i = 0; i < count; ++i) - ids[i] = 1; - } - virtual void genFramebuffers(WGC3Dsizei count, WebGLId* ids) - { - for (int i = 0; i < count; ++i) - ids[i] = 1; - } - virtual void genRenderbuffers(WGC3Dsizei count, WebGLId* ids) - { - for (int i = 0; i < count; ++i) - ids[i] = 1; - } - virtual void genTextures(WGC3Dsizei count, WebGLId* ids) - { - for (int i = 0; i < count; ++i) - ids[i] = m_nextTextureId++; - } - - virtual void deleteBuffers(WGC3Dsizei count, WebGLId* ids) { } - virtual void deleteFramebuffers(WGC3Dsizei count, WebGLId* ids) { } - virtual void deleteRenderbuffers(WGC3Dsizei count, WebGLId* ids) { } - virtual void deleteTextures(WGC3Dsizei count, WebGLId* ids) { } - - virtual WebGLId createBuffer() { return 1; } - virtual WebGLId createFramebuffer() { return 1; } - virtual WebGLId createRenderbuffer() { return 1; } - virtual WebGLId createTexture() { return m_nextTextureId++; } - - virtual void deleteBuffer(WebGLId) { } - virtual void deleteFramebuffer(WebGLId) { } - virtual void deleteRenderbuffer(WebGLId) { } - virtual void deleteTexture(WebGLId) { } - - virtual WebGLId createQueryEXT() { return 1; } - virtual void deleteQueryEXT(WebGLId) { } - virtual WebString getTranslatedShaderSourceANGLE(WebGLId) { return WebString(); } // Don't use this, make a MockGLES2Interface instead. diff --git a/third_party/WebKit/public/platform/WebGraphicsContext3D.h b/third_party/WebKit/public/platform/WebGraphicsContext3D.h index 91cc4ef..4940b89 100644 --- a/third_party/WebKit/public/platform/WebGraphicsContext3D.h +++ b/third_party/WebKit/public/platform/WebGraphicsContext3D.h @@ -151,36 +151,14 @@ public: virtual void shaderSource(WebGLId shader, const WGC3Dchar* string) = 0; - virtual WebGLId createBuffer() = 0; - virtual WebGLId createFramebuffer() = 0; - virtual WebGLId createRenderbuffer() = 0; - virtual WebGLId createTexture() = 0; - - virtual void deleteBuffer(WebGLId) = 0; - virtual void deleteFramebuffer(WebGLId) = 0; - virtual void deleteRenderbuffer(WebGLId) = 0; - virtual void deleteTexture(WebGLId) = 0; - virtual void setContextLostCallback(WebGraphicsContextLostCallback* callback) { } virtual void setErrorMessageCallback(WebGraphicsErrorMessageCallback* callback) { } virtual WebString getTranslatedShaderSourceANGLE(WebGLId shader) = 0; - // GL_EXT_occlusion_query - virtual WebGLId createQueryEXT() { return 0; } - virtual void deleteQueryEXT(WebGLId query) { } - - // GL_CHROMIUM_subscribe_uniform - virtual WebGLId createValuebufferCHROMIUM() { return 0; } - virtual void deleteValuebufferCHROMIUM(WebGLId) { } - // GL_EXT_debug_marker virtual void pushGroupMarkerEXT(const WGC3Dchar* marker) { } - // GL_OES_vertex_array_object - virtual WebGLId createVertexArrayOES() { return 0; } - virtual void deleteVertexArrayOES(WebGLId array) { } - // OpenGL ES 3.0 functions not represented by pre-existing extensions virtual void beginTransformFeedback(WGC3Denum primitiveMode) { } virtual void bindBufferBase(WGC3Denum target, WGC3Duint index, WebGLId buffer) { } @@ -195,10 +173,6 @@ public: virtual void compressedTexSubImage3D(WGC3Denum target, WGC3Dint level, WGC3Dint xoffset, WGC3Dint yoffset, WGC3Dint zoffset, WGC3Dsizei width, WGC3Dsizei height, WGC3Dsizei depth, WGC3Denum format, WGC3Dsizei imageSize, const void *data) { } virtual void copyBufferSubData(WGC3Denum readTarget, WGC3Denum writeTarget, WGC3Dintptr readOffset, WGC3Dintptr writeOffset, WGC3Dsizeiptr size) { } virtual void copyTexSubImage3D(WGC3Denum target, WGC3Dint level, WGC3Dint xoffset, WGC3Dint yoffset, WGC3Dint zoffset, WGC3Dint x, WGC3Dint y, WGC3Dsizei width, WGC3Dsizei height) { } - virtual WebGLId createSampler() { return 0; } - virtual WebGLId createTransformFeedback() { return 0; } - virtual void deleteSampler(WebGLId sampler) { } - virtual void deleteTransformFeedback(WebGLId transformfeedback) { } virtual void endTransformFeedback(void) { } virtual void getActiveUniformBlockName(WebGLId program, WGC3Duint uniformBlockIndex, WGC3Dsizei bufSize, WGC3Dsizei *length, WGC3Dchar *uniformBlockName) { } virtual void getActiveUniformBlockiv(WebGLId program, WGC3Duint uniformBlockIndex, WGC3Denum pname, WGC3Dint *params) { } |