From 611de09a17728eb0c1713b30ab3c2178a106d146 Mon Sep 17 00:00:00 2001 From: danakj Date: Fri, 18 Mar 2016 13:54:10 -0700 Subject: Move simple methods [A-E] from WebGraphicsContext3D to GLES2Interface. This removes methods from WebGraphicsContext3D that were simple macro- based pass-throughs to the underlying GLES2Interface, and changes callers in blink to use the GLES2Interface for them instead. R=junov@chromium.org, kbr@chromium.org, piman, chrishtr TBR=pfeldman, kbr BUG=584497 CQ_INCLUDE_TRYBOTS=tryserver.chromium.win:win_optional_gpu_tests_rel;tryserver.chromium.mac:mac_optional_gpu_tests_rel Review URL: https://codereview.chromium.org/1807103002 Cr-Commit-Position: refs/heads/master@{#382081} --- components/test_runner/test_plugin.cc | 36 +++--- content/browser/compositor/gl_helper_benchmark.cc | 110 ++++++++++-------- gpu/blink/webgraphicscontext3d_impl.cc | 108 ------------------ gpu/blink/webgraphicscontext3d_impl.h | 111 +----------------- .../modules/webgl/WebGL2RenderingContextBase.cpp | 2 +- .../Source/modules/webgl/WebGLDrawBuffers.cpp | 14 +-- .../modules/webgl/WebGLRenderingContextBase.cpp | 126 ++++++++++----------- .../platform/graphics/Canvas2DLayerBridge.cpp | 37 ++++-- .../Source/platform/graphics/Canvas2DLayerBridge.h | 7 ++ .../Source/platform/graphics/ImageBuffer.cpp | 17 +-- .../WebKit/Source/platform/graphics/ImageBuffer.h | 8 +- .../Source/platform/graphics/gpu/DrawingBuffer.cpp | 120 ++++++++++---------- .../Source/platform/graphics/gpu/DrawingBuffer.h | 2 +- .../platform/graphics/gpu/DrawingBufferTest.cpp | 86 ++++++++------ .../platform/graphics/gpu/Extensions3DUtil.cpp | 2 +- .../graphics/test/MockWebGraphicsContext3D.h | 47 -------- .../WebKit/public/platform/WebGraphicsContext3D.h | 52 --------- 17 files changed, 316 insertions(+), 569 deletions(-) diff --git a/components/test_runner/test_plugin.cc b/components/test_runner/test_plugin.cc index cd76b83..5def060 100644 --- a/components/test_runner/test_plugin.cc +++ b/components/test_runner/test_plugin.cc @@ -243,7 +243,7 @@ void TestPlugin::updateGeometry( } else if (context_) { context_->viewport(0, 0, rect_.width, rect_.height); - context_->bindTexture(GL_TEXTURE_2D, color_texture_); + gl_->BindTexture(GL_TEXTURE_2D, color_texture_); context_->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); context_->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); context_->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); @@ -257,7 +257,7 @@ void TestPlugin::updateGeometry( GL_RGBA, GL_UNSIGNED_BYTE, 0); - context_->bindFramebuffer(GL_FRAMEBUFFER, framebuffer_); + gl_->BindFramebuffer(GL_FRAMEBUFFER, framebuffer_); gl_->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, color_texture_, 0); @@ -266,7 +266,7 @@ void TestPlugin::updateGeometry( gpu::Mailbox mailbox; context_->genMailboxCHROMIUM(mailbox.name); context_->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); - const blink::WGC3Duint64 fence_sync = context_->insertFenceSyncCHROMIUM(); + const GLuint64 fence_sync = gl_->InsertFenceSyncCHROMIUM(); context_->flush(); gpu::SyncToken sync_token; @@ -376,13 +376,13 @@ bool TestPlugin::InitScene() { framebuffer_ = context_->createFramebuffer(); context_->viewport(0, 0, rect_.width, rect_.height); - context_->disable(GL_DEPTH_TEST); - context_->disable(GL_SCISSOR_TEST); + gl_->Disable(GL_DEPTH_TEST); + gl_->Disable(GL_SCISSOR_TEST); - context_->clearColor(color[0], color[1], color[2], color[3]); + gl_->ClearColor(color[0], color[1], color[2], color[3]); - context_->enable(GL_BLEND); - context_->blendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + gl_->Enable(GL_BLEND); + gl_->BlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); return scene_.primitive != PrimitiveNone ? InitProgram() && InitPrimitive() : true; @@ -390,7 +390,7 @@ bool TestPlugin::InitScene() { void TestPlugin::DrawSceneGL() { context_->viewport(0, 0, rect_.width, rect_.height); - context_->clear(GL_COLOR_BUFFER_BIT); + gl_->Clear(GL_COLOR_BUFFER_BIT); if (scene_.primitive != PrimitiveNone) DrawPrimitive(); @@ -478,9 +478,9 @@ bool TestPlugin::InitPrimitive() { const float vertices[] = {0.0f, 0.8f, 0.0f, -0.8f, -0.8f, 0.0f, 0.8f, -0.8f, 0.0f}; - context_->bindBuffer(GL_ARRAY_BUFFER, scene_.vbo); - context_->bufferData(GL_ARRAY_BUFFER, sizeof(vertices), 0, GL_STATIC_DRAW); - context_->bufferSubData(GL_ARRAY_BUFFER, 0, sizeof(vertices), vertices); + gl_->BindBuffer(GL_ARRAY_BUFFER, scene_.vbo); + gl_->BufferData(GL_ARRAY_BUFFER, sizeof(vertices), 0, GL_STATIC_DRAW); + gl_->BufferSubData(GL_ARRAY_BUFFER, 0, sizeof(vertices), vertices); return true; } @@ -498,18 +498,18 @@ void TestPlugin::DrawPrimitive() { scene_.color_location, color[0], color[1], color[2], color[3]); // Bind primitive vertices. - context_->bindBuffer(GL_ARRAY_BUFFER, scene_.vbo); - context_->enableVertexAttribArray(scene_.position_location); + gl_->BindBuffer(GL_ARRAY_BUFFER, scene_.vbo); + gl_->EnableVertexAttribArray(scene_.position_location); context_->vertexAttribPointer( scene_.position_location, 3, GL_FLOAT, GL_FALSE, 0, 0); - context_->drawArrays(GL_TRIANGLES, 0, 3); + gl_->DrawArrays(GL_TRIANGLES, 0, 3); } unsigned TestPlugin::LoadShader(unsigned type, const std::string& source) { unsigned shader = context_->createShader(type); if (shader) { context_->shaderSource(shader, source.data()); - context_->compileShader(shader); + gl_->CompileShader(shader); int compiled = 0; context_->getShaderiv(shader, GL_COMPILE_STATUS, &compiled); @@ -527,8 +527,8 @@ unsigned TestPlugin::LoadProgram(const std::string& vertex_source, unsigned fragment_shader = LoadShader(GL_FRAGMENT_SHADER, fragment_source); unsigned program = context_->createProgram(); if (vertex_shader && fragment_shader && program) { - context_->attachShader(program, vertex_shader); - context_->attachShader(program, fragment_shader); + gl_->AttachShader(program, vertex_shader); + gl_->AttachShader(program, fragment_shader); context_->linkProgram(program); int linked = 0; diff --git a/content/browser/compositor/gl_helper_benchmark.cc b/content/browser/compositor/gl_helper_benchmark.cc index fa87bf0..0cf27a3 100644 --- a/content/browser/compositor/gl_helper_benchmark.cc +++ b/content/browser/compositor/gl_helper_benchmark.cc @@ -26,7 +26,8 @@ #include "base/time/time.h" #include "content/browser/compositor/gl_helper.h" #include "content/browser/compositor/gl_helper_scaling.h" -#include "gpu/blink/webgraphicscontext3d_in_process_command_buffer_impl.h" +#include "gpu/command_buffer/client/gl_in_process_context.h" +#include "gpu/command_buffer/client/gles2_implementation.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkTypes.h" @@ -35,9 +36,6 @@ namespace content { -using blink::WebGLId; -using blink::WebGraphicsContext3D; - content::GLHelper::ScalerQuality kQualities[] = { content::GLHelper::SCALER_QUALITY_BEST, content::GLHelper::SCALER_QUALITY_GOOD, @@ -51,16 +49,34 @@ const char* kQualityNames[] = { class GLHelperTest : public testing::Test { protected: void SetUp() override { - WebGraphicsContext3D::Attributes attributes; - bool lose_context_when_out_of_memory = false; - context_ = gpu_blink::WebGraphicsContext3DInProcessCommandBufferImpl:: - CreateOffscreenContext(attributes, lose_context_when_out_of_memory); - context_->InitializeOnCurrentThread(); - - helper_.reset(new content::GLHelper(context_->GetGLInterface(), - context_->GetContextSupport())); - helper_scaling_.reset(new content::GLHelperScaling( - context_->GetGLInterface(), helper_.get())); + gpu::gles2::ContextCreationAttribHelper attributes; + attributes.alpha_size = 8; + attributes.depth_size = 24; + attributes.red_size = 8; + attributes.green_size = 8; + attributes.blue_size = 8; + attributes.stencil_size = 8; + attributes.samples = 4; + attributes.sample_buffers = 1; + attributes.bind_generates_resource = false; + + context_.reset(gpu::GLInProcessContext::Create( + nullptr, /* service */ + nullptr, /* surface */ + true, /* offscreen */ + gfx::kNullAcceleratedWidget, /* window */ + gfx::Size(1, 1), /* size */ + nullptr, /* share_context */ + true, /* use_global_share_group */ + attributes, gfx::PreferDiscreteGpu, + ::gpu::GLInProcessContextSharedMemoryLimits(), + nullptr, /* gpu_memory_buffer_manager */ + nullptr /* image_factory */)); + gl_ = context_->GetImplementation(); + gpu::ContextSupport* support = context_->GetImplementation(); + + helper_.reset(new content::GLHelper(gl_, support)); + helper_scaling_.reset(new content::GLHelperScaling(gl_, helper_.get())); } void TearDown() override { @@ -95,8 +111,8 @@ class GLHelperTest : public testing::Test { base::CloseFile(f); } - scoped_ptr - context_; + scoped_ptr context_; + gpu::gles2::GLES2Interface* gl_; scoped_ptr helper_; scoped_ptr helper_scaling_; std::deque x_ops_, y_ops_; @@ -111,9 +127,12 @@ TEST_F(GLHelperTest, ScaleBenchmark) { for (size_t q = 0; q < arraysize(kQualities); q++) { for (size_t outsize = 0; outsize < arraysize(output_sizes); outsize += 2) { for (size_t insize = 0; insize < arraysize(input_sizes); insize += 2) { - WebGLId src_texture = context_->createTexture(); - WebGLId dst_texture = context_->createTexture(); - WebGLId framebuffer = context_->createFramebuffer(); + uint32_t src_texture; + gl_->GenTextures(1, &src_texture); + uint32_t dst_texture; + gl_->GenTextures(1, &dst_texture); + uint32_t framebuffer; + gl_->GenFramebuffers(1, &framebuffer); const gfx::Size src_size(input_sizes[insize], input_sizes[insize + 1]); const gfx::Size dst_size(output_sizes[outsize], output_sizes[outsize + 1]); @@ -123,15 +142,14 @@ TEST_F(GLHelperTest, ScaleBenchmark) { SkBitmap output_pixels; output_pixels.allocN32Pixels(dst_size.width(), dst_size.height()); - context_->bindFramebuffer(GL_FRAMEBUFFER, framebuffer); - context_->bindTexture(GL_TEXTURE_2D, dst_texture); - context_->texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, dst_size.width(), - dst_size.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, - 0); - context_->bindTexture(GL_TEXTURE_2D, src_texture); - context_->texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, src_size.width(), - src_size.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, - input.getPixels()); + gl_->BindFramebuffer(GL_FRAMEBUFFER, framebuffer); + gl_->BindTexture(GL_TEXTURE_2D, dst_texture); + gl_->TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, dst_size.width(), + dst_size.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); + gl_->BindTexture(GL_TEXTURE_2D, src_texture); + gl_->TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, src_size.width(), + src_size.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, + input.getPixels()); gfx::Rect src_subrect(0, 0, src_size.width(), src_size.height()); scoped_ptr scaler( @@ -139,7 +157,7 @@ TEST_F(GLHelperTest, ScaleBenchmark) { dst_size, false, false)); // Scale once beforehand before we start measuring. scaler->Scale(src_texture, dst_texture); - context_->finish(); + gl_->Finish(); base::TimeTicks start_time = base::TimeTicks::Now(); int iterations = 0; @@ -148,9 +166,9 @@ TEST_F(GLHelperTest, ScaleBenchmark) { for (int i = 0; i < 50; i++) { iterations++; scaler->Scale(src_texture, dst_texture); - context_->flush(); + gl_->Flush(); } - context_->finish(); + gl_->Finish(); end_time = base::TimeTicks::Now(); if (iterations > 2000) { break; @@ -159,9 +177,9 @@ TEST_F(GLHelperTest, ScaleBenchmark) { break; } } - context_->deleteTexture(dst_texture); - context_->deleteTexture(src_texture); - context_->deleteFramebuffer(framebuffer); + gl_->DeleteTextures(1, &dst_texture); + gl_->DeleteTextures(1, &src_texture); + gl_->DeleteFramebuffers(1, &framebuffer); std::string name; name = base::StringPrintf("scale_%dx%d_to_%dx%d_%s", src_size.width(), @@ -191,20 +209,22 @@ TEST_F(GLHelperTest, DISABLED_ScaleTestImage) { LoadPngFileToSkBitmap(base::FilePath(FILE_PATH_LITERAL("testimage.png")), &input); - WebGLId framebuffer = context_->createFramebuffer(); - WebGLId src_texture = context_->createTexture(); + uint32_t framebuffer; + gl_->GenFramebuffers(1, &framebuffer); + uint32_t src_texture; + gl_->GenTextures(1, &src_texture); const gfx::Size src_size(input.width(), input.height()); - context_->bindFramebuffer(GL_FRAMEBUFFER, framebuffer); - context_->bindTexture(GL_TEXTURE_2D, src_texture); - context_->texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, src_size.width(), - src_size.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, - input.getPixels()); + gl_->BindFramebuffer(GL_FRAMEBUFFER, framebuffer); + gl_->BindTexture(GL_TEXTURE_2D, src_texture); + gl_->TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, src_size.width(), + src_size.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, + input.getPixels()); for (size_t q = 0; q < arraysize(kQualities); q++) { for (size_t p = 0; p < arraysize(percents); p++) { const gfx::Size dst_size(input.width() * percents[p] / 100, input.height() * percents[p] / 100); - WebGLId dst_texture = helper_->CopyAndScaleTexture( + uint32_t dst_texture = helper_->CopyAndScaleTexture( src_texture, src_size, dst_size, false, kQualities[q]); SkBitmap output_pixels; @@ -214,15 +234,15 @@ TEST_F(GLHelperTest, DISABLED_ScaleTestImage) { dst_texture, gfx::Rect(0, 0, dst_size.width(), dst_size.height()), static_cast(output_pixels.getPixels()), kN32_SkColorType); - context_->deleteTexture(dst_texture); + gl_->DeleteTextures(1, &dst_texture); std::string filename = base::StringPrintf("testoutput_%s_%d.ppm", kQualityNames[q], percents[p]); VLOG(0) << "Writing " << filename; SaveToFile(&output_pixels, base::FilePath::FromUTF8Unsafe(filename)); } } - context_->deleteTexture(src_texture); - context_->deleteFramebuffer(framebuffer); + gl_->DeleteTextures(1, &src_texture); + gl_->DeleteFramebuffers(1, &framebuffer); } } // namespace diff --git a/gpu/blink/webgraphicscontext3d_impl.cc b/gpu/blink/webgraphicscontext3d_impl.cc index ffabe1b..5d087a2 100644 --- a/gpu/blink/webgraphicscontext3d_impl.cc +++ b/gpu/blink/webgraphicscontext3d_impl.cc @@ -199,30 +199,18 @@ void WebGraphicsContext3DImpl::synthesizeGLError(WGC3Denum error) { } } -DELEGATE_TO_GL_R(lastFlushID, GetLastFlushIdCHROMIUM, WebGLId) - -DELEGATE_TO_GL_R(insertFenceSyncCHROMIUM, InsertFenceSyncCHROMIUM, WGC3Duint64) - bool WebGraphicsContext3DImpl::genSyncTokenCHROMIUM(WGC3Duint64 fenceSync, WGC3Dbyte* syncToken) { gl_->GenSyncTokenCHROMIUM(fenceSync, syncToken); return true; } -DELEGATE_TO_GL_1(waitSyncTokenCHROMIUM, WaitSyncTokenCHROMIUM, const WGC3Dbyte*) - -DELEGATE_TO_GL_3(discardFramebufferEXT, DiscardFramebufferEXT, WGC3Denum, - WGC3Dsizei, const WGC3Denum*) - blink::WebString WebGraphicsContext3DImpl:: getRequestableExtensionsCHROMIUM() { return blink::WebString::fromUTF8( gl_->GetRequestableExtensionsCHROMIUM()); } -DELEGATE_TO_GL_1(requestExtensionCHROMIUM, RequestExtensionCHROMIUM, - const char*) - void WebGraphicsContext3DImpl::blitFramebufferCHROMIUM( WGC3Dint srcX0, WGC3Dint srcY0, WGC3Dint srcX1, WGC3Dint srcY1, WGC3Dint dstX0, WGC3Dint dstY0, WGC3Dint dstX1, WGC3Dint dstY1, @@ -233,97 +221,6 @@ void WebGraphicsContext3DImpl::blitFramebufferCHROMIUM( mask, filter); } -DELEGATE_TO_GL_5(renderbufferStorageMultisampleCHROMIUM, - RenderbufferStorageMultisampleCHROMIUM, WGC3Denum, WGC3Dsizei, - WGC3Denum, WGC3Dsizei, WGC3Dsizei) - -DELEGATE_TO_GL_1(activeTexture, ActiveTexture, WGC3Denum) - -DELEGATE_TO_GL(applyScreenSpaceAntialiasingCHROMIUM, - ApplyScreenSpaceAntialiasingCHROMIUM); - -DELEGATE_TO_GL_2(attachShader, AttachShader, WebGLId, WebGLId) - -DELEGATE_TO_GL_3(bindAttribLocation, BindAttribLocation, WebGLId, - WGC3Duint, const WGC3Dchar*) - -DELEGATE_TO_GL_2(bindBuffer, BindBuffer, WGC3Denum, WebGLId) - -DELEGATE_TO_GL_2(bindFramebuffer, BindFramebuffer, WGC3Denum, WebGLId) - -DELEGATE_TO_GL_2(bindRenderbuffer, BindRenderbuffer, WGC3Denum, WebGLId) - -DELEGATE_TO_GL_2(bindTexture, BindTexture, WGC3Denum, WebGLId) - -DELEGATE_TO_GL_4(blendColor, BlendColor, - WGC3Dclampf, WGC3Dclampf, WGC3Dclampf, WGC3Dclampf) - -DELEGATE_TO_GL_1(blendEquation, BlendEquation, WGC3Denum) - -DELEGATE_TO_GL_2(blendEquationSeparate, BlendEquationSeparate, - WGC3Denum, WGC3Denum) - -DELEGATE_TO_GL_2(blendFunc, BlendFunc, WGC3Denum, WGC3Denum) - -DELEGATE_TO_GL_4(blendFuncSeparate, BlendFuncSeparate, - WGC3Denum, WGC3Denum, WGC3Denum, WGC3Denum) - -DELEGATE_TO_GL_4(bufferData, BufferData, - WGC3Denum, WGC3Dsizeiptr, const void*, WGC3Denum) - -DELEGATE_TO_GL_4(bufferSubData, BufferSubData, - WGC3Denum, WGC3Dintptr, WGC3Dsizeiptr, const void*) - -DELEGATE_TO_GL_1R(checkFramebufferStatus, CheckFramebufferStatus, - WGC3Denum, WGC3Denum) - -DELEGATE_TO_GL_1(clear, Clear, WGC3Dbitfield) - -DELEGATE_TO_GL_4(clearColor, ClearColor, - WGC3Dclampf, WGC3Dclampf, WGC3Dclampf, WGC3Dclampf) - -DELEGATE_TO_GL_1(clearDepth, ClearDepthf, WGC3Dclampf) - -DELEGATE_TO_GL_1(clearStencil, ClearStencil, WGC3Dint) - -DELEGATE_TO_GL_4(colorMask, ColorMask, - WGC3Dboolean, WGC3Dboolean, WGC3Dboolean, WGC3Dboolean) - -DELEGATE_TO_GL_1(compileShader, CompileShader, WebGLId) - -DELEGATE_TO_GL_8(compressedTexImage2D, CompressedTexImage2D, - WGC3Denum, WGC3Dint, WGC3Denum, WGC3Dint, WGC3Dint, - WGC3Dsizei, WGC3Dsizei, const void*) - -DELEGATE_TO_GL_9(compressedTexSubImage2D, CompressedTexSubImage2D, - WGC3Denum, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint, - WGC3Denum, WGC3Dsizei, const void*) - -DELEGATE_TO_GL_8(copyTexImage2D, CopyTexImage2D, - WGC3Denum, WGC3Dint, WGC3Denum, WGC3Dint, WGC3Dint, - WGC3Dsizei, WGC3Dsizei, WGC3Dint) - -DELEGATE_TO_GL_8(copyTexSubImage2D, CopyTexSubImage2D, - WGC3Denum, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint, - WGC3Dsizei, WGC3Dsizei) - -DELEGATE_TO_GL_1(cullFace, CullFace, WGC3Denum) - -DELEGATE_TO_GL_1(depthFunc, DepthFunc, WGC3Denum) - -DELEGATE_TO_GL_1(depthMask, DepthMask, WGC3Dboolean) - -DELEGATE_TO_GL_2(depthRange, DepthRangef, WGC3Dclampf, WGC3Dclampf) - -DELEGATE_TO_GL_2(detachShader, DetachShader, WebGLId, WebGLId) - -DELEGATE_TO_GL_1(disable, Disable, WGC3Denum) - -DELEGATE_TO_GL_1(disableVertexAttribArray, DisableVertexAttribArray, - WGC3Duint) - -DELEGATE_TO_GL_3(drawArrays, DrawArrays, WGC3Denum, WGC3Dint, WGC3Dsizei) - void WebGraphicsContext3DImpl::drawElements(WGC3Denum mode, WGC3Dsizei count, WGC3Denum type, @@ -333,11 +230,6 @@ void WebGraphicsContext3DImpl::drawElements(WGC3Denum mode, reinterpret_cast(static_cast(offset))); } -DELEGATE_TO_GL_1(enable, Enable, WGC3Denum) - -DELEGATE_TO_GL_1(enableVertexAttribArray, EnableVertexAttribArray, - WGC3Duint) - DELEGATE_TO_GL(finish, Finish) DELEGATE_TO_GL(flush, Flush) diff --git a/gpu/blink/webgraphicscontext3d_impl.h b/gpu/blink/webgraphicscontext3d_impl.h index 16eb3f7..cd423bc 100644 --- a/gpu/blink/webgraphicscontext3d_impl.h +++ b/gpu/blink/webgraphicscontext3d_impl.h @@ -37,111 +37,14 @@ class GPU_BLINK_EXPORT WebGraphicsContext3DImpl //---------------------------------------------------------------------- // WebGraphicsContext3D methods - uint32_t lastFlushID() override; - - blink::WGC3Duint64 insertFenceSyncCHROMIUM() override; bool genSyncTokenCHROMIUM(blink::WGC3Duint64 fenceSync, blink::WGC3Dbyte* syncToken) override; - void waitSyncTokenCHROMIUM(const blink::WGC3Dbyte* syncToken) override; - - void activeTexture(blink::WGC3Denum texture) override; - void applyScreenSpaceAntialiasingCHROMIUM() override; - void attachShader(blink::WebGLId program, blink::WebGLId shader) override; - void bindAttribLocation(blink::WebGLId program, - blink::WGC3Duint index, - const blink::WGC3Dchar* name) override; - void bindBuffer(blink::WGC3Denum target, blink::WebGLId buffer) override; - void bindFramebuffer(blink::WGC3Denum target, - blink::WebGLId framebuffer) override; - void bindRenderbuffer(blink::WGC3Denum target, - blink::WebGLId renderbuffer) override; - void bindTexture(blink::WGC3Denum target, blink::WebGLId texture) override; - void blendColor(blink::WGC3Dclampf red, - blink::WGC3Dclampf green, - blink::WGC3Dclampf blue, - blink::WGC3Dclampf alpha) override; - void blendEquation(blink::WGC3Denum mode) override; - void blendEquationSeparate(blink::WGC3Denum modeRGB, - blink::WGC3Denum modeAlpha) override; - void blendFunc(blink::WGC3Denum sfactor, blink::WGC3Denum dfactor) override; - void blendFuncSeparate(blink::WGC3Denum srcRGB, - blink::WGC3Denum dstRGB, - blink::WGC3Denum srcAlpha, - blink::WGC3Denum dstAlpha) override; - - void bufferData(blink::WGC3Denum target, - blink::WGC3Dsizeiptr size, - const void* data, - blink::WGC3Denum usage) override; - void bufferSubData(blink::WGC3Denum target, - blink::WGC3Dintptr offset, - blink::WGC3Dsizeiptr size, - const void* data) override; - - blink::WGC3Denum checkFramebufferStatus(blink::WGC3Denum target) override; - void clear(blink::WGC3Dbitfield mask) override; - void clearColor(blink::WGC3Dclampf red, - blink::WGC3Dclampf green, - blink::WGC3Dclampf blue, - blink::WGC3Dclampf alpha) override; - void clearDepth(blink::WGC3Dclampf depth) override; - void clearStencil(blink::WGC3Dint s) override; - void colorMask(blink::WGC3Dboolean red, - blink::WGC3Dboolean green, - blink::WGC3Dboolean blue, - blink::WGC3Dboolean alpha) override; - void compileShader(blink::WebGLId shader) override; - - void compressedTexImage2D(blink::WGC3Denum target, - blink::WGC3Dint level, - blink::WGC3Denum internalformat, - blink::WGC3Dsizei width, - blink::WGC3Dsizei height, - blink::WGC3Dint border, - blink::WGC3Dsizei imageSize, - const void* data) override; - void compressedTexSubImage2D(blink::WGC3Denum target, - blink::WGC3Dint level, - blink::WGC3Dint xoffset, - blink::WGC3Dint yoffset, - blink::WGC3Dsizei width, - blink::WGC3Dsizei height, - blink::WGC3Denum format, - blink::WGC3Dsizei imageSize, - const void* data) override; - void copyTexImage2D(blink::WGC3Denum target, - blink::WGC3Dint level, - blink::WGC3Denum internalformat, - blink::WGC3Dint x, - blink::WGC3Dint y, - blink::WGC3Dsizei width, - blink::WGC3Dsizei height, - blink::WGC3Dint border) override; - void copyTexSubImage2D(blink::WGC3Denum target, - blink::WGC3Dint level, - blink::WGC3Dint xoffset, - blink::WGC3Dint yoffset, - blink::WGC3Dint x, - blink::WGC3Dint y, - blink::WGC3Dsizei width, - blink::WGC3Dsizei height) override; - void cullFace(blink::WGC3Denum mode) override; - void depthFunc(blink::WGC3Denum func) override; - void depthMask(blink::WGC3Dboolean flag) override; - void depthRange(blink::WGC3Dclampf zNear, blink::WGC3Dclampf zFar) override; - void detachShader(blink::WebGLId program, blink::WebGLId shader) override; - void disable(blink::WGC3Denum cap) override; - void disableVertexAttribArray(blink::WGC3Duint index) override; - void drawArrays(blink::WGC3Denum mode, - blink::WGC3Dint first, - blink::WGC3Dsizei count) override; + void drawElements(blink::WGC3Denum mode, blink::WGC3Dsizei count, blink::WGC3Denum type, blink::WGC3Dintptr offset) override; - void enable(blink::WGC3Denum cap) override; - void enableVertexAttribArray(blink::WGC3Duint index) override; void finish() override; void flush() override; void frontFace(blink::WGC3Denum mode) override; @@ -442,12 +345,7 @@ class GPU_BLINK_EXPORT WebGraphicsContext3DImpl void synthesizeGLError(blink::WGC3Denum) override; - void discardFramebufferEXT(blink::WGC3Denum target, - blink::WGC3Dsizei numAttachments, - const blink::WGC3Denum* attachments) override; - blink::WebString getRequestableExtensionsCHROMIUM() override; - void requestExtensionCHROMIUM(const char*) override; void blitFramebufferCHROMIUM(blink::WGC3Dint srcX0, blink::WGC3Dint srcY0, @@ -459,13 +357,6 @@ class GPU_BLINK_EXPORT WebGraphicsContext3DImpl blink::WGC3Dint dstY1, blink::WGC3Dbitfield mask, blink::WGC3Denum filter) override; - void renderbufferStorageMultisampleCHROMIUM( - blink::WGC3Denum target, - blink::WGC3Dsizei samples, - blink::WGC3Denum internalformat, - blink::WGC3Dsizei width, - blink::WGC3Dsizei height) override; - blink::WebString getTranslatedShaderSourceANGLE( blink::WebGLId shader) override; diff --git a/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp b/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp index 0301507..810ff9e 100644 --- a/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp +++ b/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp @@ -699,7 +699,7 @@ void WebGL2RenderingContextBase::renderbufferStorageImpl( synthesizeGLError(GL_INVALID_OPERATION, functionName, "samples out of range"); return; } - webContext()->renderbufferStorageMultisampleCHROMIUM( + contextGL()->RenderbufferStorageMultisampleCHROMIUM( target, samples, internalformat, width, height); } break; diff --git a/third_party/WebKit/Source/modules/webgl/WebGLDrawBuffers.cpp b/third_party/WebKit/Source/modules/webgl/WebGLDrawBuffers.cpp index 4c007df..9ef1517 100644 --- a/third_party/WebKit/Source/modules/webgl/WebGLDrawBuffers.cpp +++ b/third_party/WebKit/Source/modules/webgl/WebGLDrawBuffers.cpp @@ -114,7 +114,7 @@ bool WebGLDrawBuffers::satisfiesWebGLRequirements(WebGLRenderingContextBase* web return false; Platform3DObject fbo = context->createFramebuffer(); - context->bindFramebuffer(GL_FRAMEBUFFER, fbo); + gl->BindFramebuffer(GL_FRAMEBUFFER, fbo); const unsigned char* buffer = 0; // Chromium doesn't allow init data for depth/stencil tetxures. bool supportsDepth = (extensionsUtil->supportsExtension("GL_CHROMIUM_depth_texture") @@ -125,13 +125,13 @@ bool WebGLDrawBuffers::satisfiesWebGLRequirements(WebGLRenderingContextBase* web Platform3DObject depthStencil = 0; if (supportsDepthStencil) { depthStencil = context->createTexture(); - context->bindTexture(GL_TEXTURE_2D, depthStencil); + gl->BindTexture(GL_TEXTURE_2D, depthStencil); context->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; if (supportsDepth) { depth = context->createTexture(); - context->bindTexture(GL_TEXTURE_2D, depth); + gl->BindTexture(GL_TEXTURE_2D, depth); context->texImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, 1, 1, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, buffer); } @@ -141,16 +141,16 @@ bool WebGLDrawBuffers::satisfiesWebGLRequirements(WebGLRenderingContextBase* web for (GLint i = 0; i < maxAllowedBuffers; ++i) { Platform3DObject color = context->createTexture(); colors.append(color); - context->bindTexture(GL_TEXTURE_2D, color); + gl->BindTexture(GL_TEXTURE_2D, color); context->texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer); gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, GL_TEXTURE_2D, color, 0); - if (context->checkFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { + if (gl->CheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { ok = false; break; } if (supportsDepth) { gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depth, 0); - if (context->checkFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { + if (gl->CheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { ok = false; break; } @@ -159,7 +159,7 @@ bool WebGLDrawBuffers::satisfiesWebGLRequirements(WebGLRenderingContextBase* web if (supportsDepthStencil) { gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthStencil, 0); gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, depthStencil, 0); - if (context->checkFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { + if (gl->CheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { ok = false; break; } diff --git a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp index 1fa00a8..2cca13e 100644 --- a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp +++ b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp @@ -150,7 +150,7 @@ WebGLRenderingContextBase* WebGLRenderingContextBase::oldestContext() ASSERT(!candidate->isContextLost()); for (WebGLRenderingContextBase* context : activeContexts()) { ASSERT(!context->isContextLost()); - if (context->webContext()->lastFlushID() < candidate->webContext()->lastFlushID()) { + if (context->contextGL()->GetLastFlushIdCHROMIUM() < candidate->contextGL()->GetLastFlushIdCHROMIUM()) { candidate = context; } } @@ -1162,28 +1162,28 @@ WebGLRenderingContextBase::HowToClear WebGLRenderingContextBase::clearIfComposit // Determine if it's possible to combine the clear the user asked for and this clear. bool combinedClear = mask && !m_scissorEnabled; - webContext()->disable(GL_SCISSOR_TEST); + contextGL()->Disable(GL_SCISSOR_TEST); if (combinedClear && (mask & GL_COLOR_BUFFER_BIT)) { - webContext()->clearColor(m_colorMask[0] ? m_clearColor[0] : 0, + contextGL()->ClearColor(m_colorMask[0] ? m_clearColor[0] : 0, m_colorMask[1] ? m_clearColor[1] : 0, m_colorMask[2] ? m_clearColor[2] : 0, m_colorMask[3] ? m_clearColor[3] : 0); } else { - webContext()->clearColor(0, 0, 0, 0); + contextGL()->ClearColor(0, 0, 0, 0); } - webContext()->colorMask(true, true, true, true); + contextGL()->ColorMask(true, true, true, true); GLbitfield clearMask = GL_COLOR_BUFFER_BIT; if (contextAttributes.get().depth()) { if (!combinedClear || !m_depthMask || !(mask & GL_DEPTH_BUFFER_BIT)) - webContext()->clearDepth(1.0f); + contextGL()->ClearDepthf(1.0f); clearMask |= GL_DEPTH_BUFFER_BIT; - webContext()->depthMask(true); + contextGL()->DepthMask(true); } if (contextAttributes.get().stencil() || drawingBuffer()->hasImplicitStencilBuffer()) { if (combinedClear && (mask & GL_STENCIL_BUFFER_BIT)) - webContext()->clearStencil(m_clearStencil & m_stencilMask); + contextGL()->ClearStencil(m_clearStencil & m_stencilMask); else - webContext()->clearStencil(0); + contextGL()->ClearStencil(0); clearMask |= GL_STENCIL_BUFFER_BIT; webContext()->stencilMaskSeparate(GL_FRONT, 0xFFFFFFFF); } @@ -1204,15 +1204,15 @@ void WebGLRenderingContextBase::restoreStateAfterClear() // Restore the state that the context set. if (m_scissorEnabled) - webContext()->enable(GL_SCISSOR_TEST); - webContext()->clearColor(m_clearColor[0], m_clearColor[1], + contextGL()->Enable(GL_SCISSOR_TEST); + contextGL()->ClearColor(m_clearColor[0], m_clearColor[1], m_clearColor[2], m_clearColor[3]); - webContext()->colorMask(m_colorMask[0], m_colorMask[1], + contextGL()->ColorMask(m_colorMask[0], m_colorMask[1], m_colorMask[2], m_colorMask[3]); - webContext()->clearDepth(m_clearDepth); - webContext()->clearStencil(m_clearStencil); + contextGL()->ClearDepthf(m_clearDepth); + contextGL()->ClearStencil(m_clearStencil); webContext()->stencilMaskSeparate(GL_FRONT, m_stencilMask); - webContext()->depthMask(m_depthMask); + contextGL()->DepthMask(m_depthMask); } void WebGLRenderingContextBase::markLayerComposited() @@ -1314,8 +1314,8 @@ void WebGLRenderingContextBase::reshape(int width, int height) drawingBuffer()->reset(IntSize(width, height)); restoreStateAfterClear(); - webContext()->bindTexture(GL_TEXTURE_2D, objectOrZero(m_textureUnits[m_activeTextureUnit].m_texture2DBinding.get())); - webContext()->bindRenderbuffer(GL_RENDERBUFFER, objectOrZero(m_renderbufferBinding.get())); + contextGL()->BindTexture(GL_TEXTURE_2D, objectOrZero(m_textureUnits[m_activeTextureUnit].m_texture2DBinding.get())); + contextGL()->BindRenderbuffer(GL_RENDERBUFFER, objectOrZero(m_renderbufferBinding.get())); drawingBuffer()->restoreFramebufferBindings(); } @@ -1338,7 +1338,7 @@ void WebGLRenderingContextBase::activeTexture(GLenum texture) return; } m_activeTextureUnit = texture - GL_TEXTURE0; - webContext()->activeTexture(texture); + contextGL()->ActiveTexture(texture); drawingBuffer()->setActiveTextureUnit(texture); @@ -1352,7 +1352,7 @@ void WebGLRenderingContextBase::attachShader(ScriptState* scriptState, WebGLProg synthesizeGLError(GL_INVALID_OPERATION, "attachShader", "shader attachment already has shader"); return; } - webContext()->attachShader(objectOrZero(program), objectOrZero(shader)); + contextGL()->AttachShader(objectOrZero(program), objectOrZero(shader)); shader->onAttached(); preserveObjectWrapper(scriptState, program, "shader", shader->type(), shader); } @@ -1367,7 +1367,7 @@ void WebGLRenderingContextBase::bindAttribLocation(WebGLProgram* program, GLuint synthesizeGLError(GL_INVALID_OPERATION, "bindAttribLocation", "reserved prefix"); return; } - webContext()->bindAttribLocation(objectOrZero(program), index, name.utf8().data()); + contextGL()->BindAttribLocation(objectOrZero(program), index, name.utf8().data()); } bool WebGLRenderingContextBase::checkObjectToBeBound(const char* functionName, WebGLObject* object, bool& deleted) @@ -1422,7 +1422,7 @@ void WebGLRenderingContextBase::bindBuffer(ScriptState* scriptState, GLenum targ if (!validateAndUpdateBufferBindTarget("bindBuffer", target, buffer)) return; - webContext()->bindBuffer(target, objectOrZero(buffer)); + contextGL()->BindBuffer(target, objectOrZero(buffer)); preserveObjectWrapper(scriptState, this, "buffer", target, buffer); maybePreserveDefaultVAOObjectWrapper(scriptState); } @@ -1460,7 +1460,7 @@ void WebGLRenderingContextBase::bindRenderbuffer(ScriptState* scriptState, GLenu return; } m_renderbufferBinding = renderBuffer; - webContext()->bindRenderbuffer(target, objectOrZero(renderBuffer)); + contextGL()->BindRenderbuffer(target, objectOrZero(renderBuffer)); preserveObjectWrapper(scriptState, this, "renderbuffer", 0, renderBuffer); if (renderBuffer) renderBuffer->setHasEverBeenBound(); @@ -1499,7 +1499,7 @@ void WebGLRenderingContextBase::bindTexture(ScriptState* scriptState, GLenum tar return; } - webContext()->bindTexture(target, objectOrZero(texture)); + contextGL()->BindTexture(target, objectOrZero(texture)); // This is called both internally and externally (from JavaScript). We only update which wrapper // is preserved when it's called from JavaScript. if (scriptState) { @@ -1530,21 +1530,21 @@ void WebGLRenderingContextBase::blendColor(GLfloat red, GLfloat green, GLfloat b { if (isContextLost()) return; - webContext()->blendColor(red, green, blue, alpha); + contextGL()->BlendColor(red, green, blue, alpha); } void WebGLRenderingContextBase::blendEquation(GLenum mode) { if (isContextLost() || !validateBlendEquation("blendEquation", mode)) return; - webContext()->blendEquation(mode); + contextGL()->BlendEquation(mode); } void WebGLRenderingContextBase::blendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) { if (isContextLost() || !validateBlendEquation("blendEquationSeparate", modeRGB) || !validateBlendEquation("blendEquationSeparate", modeAlpha)) return; - webContext()->blendEquationSeparate(modeRGB, modeAlpha); + contextGL()->BlendEquationSeparate(modeRGB, modeAlpha); } @@ -1552,7 +1552,7 @@ void WebGLRenderingContextBase::blendFunc(GLenum sfactor, GLenum dfactor) { if (isContextLost() || !validateBlendFuncFactors("blendFunc", sfactor, dfactor)) return; - webContext()->blendFunc(sfactor, dfactor); + contextGL()->BlendFunc(sfactor, dfactor); } void WebGLRenderingContextBase::blendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) @@ -1560,7 +1560,7 @@ void WebGLRenderingContextBase::blendFuncSeparate(GLenum srcRGB, GLenum dstRGB, // Note: Alpha does not have the same restrictions as RGB. if (isContextLost() || !validateBlendFuncFactors("blendFuncSeparate", srcRGB, dstRGB)) return; - webContext()->blendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha); + contextGL()->BlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha); } void WebGLRenderingContextBase::bufferDataImpl(GLenum target, long long size, const void* data, GLenum usage) @@ -1577,7 +1577,7 @@ void WebGLRenderingContextBase::bufferDataImpl(GLenum target, long long size, co buffer->setSize(size); - webContext()->bufferData(target, static_cast(size), data, usage); + contextGL()->BufferData(target, static_cast(size), data, usage); } void WebGLRenderingContextBase::bufferData(GLenum target, long long size, GLenum usage) @@ -1623,7 +1623,7 @@ void WebGLRenderingContextBase::bufferSubDataImpl(GLenum target, long long offse return; } - webContext()->bufferSubData(target, static_cast(offset), size, data); + contextGL()->BufferSubData(target, static_cast(offset), size, data); } void WebGLRenderingContextBase::bufferSubData(GLenum target, long long offset, DOMArrayBuffer* data) @@ -1684,7 +1684,7 @@ GLenum WebGLRenderingContextBase::checkFramebufferStatus(GLenum target) return status; } } - return webContext()->checkFramebufferStatus(target); + return contextGL()->CheckFramebufferStatus(target); } void WebGLRenderingContextBase::clear(GLbitfield mask) @@ -1708,7 +1708,7 @@ void WebGLRenderingContextBase::clear(GLbitfield mask) // claim that the stencil buffer doesn't exist. mask |= GL_STENCIL_BUFFER_BIT; } - webContext()->clear(mask); + contextGL()->Clear(mask); } markContextChanged(CanvasChanged); } @@ -1729,7 +1729,7 @@ void WebGLRenderingContextBase::clearColor(GLfloat r, GLfloat g, GLfloat b, GLfl m_clearColor[1] = g; m_clearColor[2] = b; m_clearColor[3] = a; - webContext()->clearColor(r, g, b, a); + contextGL()->ClearColor(r, g, b, a); } void WebGLRenderingContextBase::clearDepth(GLfloat depth) @@ -1737,7 +1737,7 @@ void WebGLRenderingContextBase::clearDepth(GLfloat depth) if (isContextLost()) return; m_clearDepth = depth; - webContext()->clearDepth(depth); + contextGL()->ClearDepthf(depth); } void WebGLRenderingContextBase::clearStencil(GLint s) @@ -1745,7 +1745,7 @@ void WebGLRenderingContextBase::clearStencil(GLint s) if (isContextLost()) return; m_clearStencil = s; - webContext()->clearStencil(s); + contextGL()->ClearStencil(s); } void WebGLRenderingContextBase::colorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) @@ -1756,14 +1756,14 @@ void WebGLRenderingContextBase::colorMask(GLboolean red, GLboolean green, GLbool m_colorMask[1] = green; m_colorMask[2] = blue; m_colorMask[3] = alpha; - webContext()->colorMask(red, green, blue, alpha); + contextGL()->ColorMask(red, green, blue, alpha); } void WebGLRenderingContextBase::compileShader(WebGLShader* shader) { if (isContextLost() || !validateWebGLObject("compileShader", shader)) return; - webContext()->compileShader(objectOrZero(shader)); + contextGL()->CompileShader(objectOrZero(shader)); } void WebGLRenderingContextBase::compressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, DOMArrayBufferView* data) @@ -1774,7 +1774,7 @@ void WebGLRenderingContextBase::compressedTexImage2D(GLenum target, GLint level, return; if (!validateCompressedTexFormat("compressedTexImage2D", internalformat)) return; - webContext()->compressedTexImage2D(target, level, internalformat, width, height, + contextGL()->CompressedTexImage2D(target, level, internalformat, width, height, border, data->byteLength(), data->baseAddress()); } @@ -1786,7 +1786,7 @@ void WebGLRenderingContextBase::compressedTexSubImage2D(GLenum target, GLint lev return; if (!validateCompressedTexFormat("compressedTexSubImage2D", format)) return; - webContext()->compressedTexSubImage2D(target, level, xoffset, yoffset, + contextGL()->CompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, data->byteLength(), data->baseAddress()); } @@ -1832,7 +1832,7 @@ void WebGLRenderingContextBase::copyTexImage2D(GLenum target, GLint level, GLenu return; clearIfComposited(); ScopedDrawingBufferBinder binder(drawingBuffer(), readFramebufferBinding); - webContext()->copyTexImage2D(target, level, internalformat, x, y, width, height, border); + contextGL()->CopyTexImage2D(target, level, internalformat, x, y, width, height, border); } void WebGLRenderingContextBase::copyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) @@ -1846,7 +1846,7 @@ void WebGLRenderingContextBase::copyTexSubImage2D(GLenum target, GLint level, GL return; clearIfComposited(); ScopedDrawingBufferBinder binder(drawingBuffer(), readFramebufferBinding); - webContext()->copyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height); + contextGL()->CopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height); } WebGLBuffer* WebGLRenderingContextBase::createBuffer() @@ -1922,7 +1922,7 @@ void WebGLRenderingContextBase::cullFace(GLenum mode) { if (isContextLost()) return; - webContext()->cullFace(mode); + contextGL()->CullFace(mode); } bool WebGLRenderingContextBase::deleteObject(WebGLObject* object) @@ -2027,7 +2027,7 @@ void WebGLRenderingContextBase::depthFunc(GLenum func) { if (isContextLost()) return; - webContext()->depthFunc(func); + contextGL()->DepthFunc(func); } void WebGLRenderingContextBase::depthMask(GLboolean flag) @@ -2035,7 +2035,7 @@ void WebGLRenderingContextBase::depthMask(GLboolean flag) if (isContextLost()) return; m_depthMask = flag; - webContext()->depthMask(flag); + contextGL()->DepthMask(flag); } void WebGLRenderingContextBase::depthRange(GLfloat zNear, GLfloat zFar) @@ -2047,7 +2047,7 @@ void WebGLRenderingContextBase::depthRange(GLfloat zNear, GLfloat zFar) synthesizeGLError(GL_INVALID_OPERATION, "depthRange", "zNear > zFar"); return; } - webContext()->depthRange(zNear, zFar); + contextGL()->DepthRangef(zNear, zFar); } void WebGLRenderingContextBase::detachShader(ScriptState* scriptState, WebGLProgram* program, WebGLShader* shader) @@ -2058,7 +2058,7 @@ void WebGLRenderingContextBase::detachShader(ScriptState* scriptState, WebGLProg synthesizeGLError(GL_INVALID_OPERATION, "detachShader", "shader not attached"); return; } - webContext()->detachShader(objectOrZero(program), objectOrZero(shader)); + contextGL()->DetachShader(objectOrZero(program), objectOrZero(shader)); shader->onDetached(webContext()); preserveObjectWrapper(scriptState, program, "shader", shader->type(), nullptr); } @@ -2076,7 +2076,7 @@ void WebGLRenderingContextBase::disable(GLenum cap) m_scissorEnabled = false; drawingBuffer()->setScissorEnabled(m_scissorEnabled); } - webContext()->disable(cap); + contextGL()->Disable(cap); } void WebGLRenderingContextBase::disableVertexAttribArray(GLuint index) @@ -2088,7 +2088,7 @@ void WebGLRenderingContextBase::disableVertexAttribArray(GLuint index) return; } - webContext()->disableVertexAttribArray(index); + contextGL()->DisableVertexAttribArray(index); } bool WebGLRenderingContextBase::validateRenderingState(const char* functionName) @@ -2121,7 +2121,7 @@ void WebGLRenderingContextBase::drawArrays(GLenum mode, GLint first, GLsizei cou return; clearIfComposited(); - webContext()->drawArrays(mode, first, count); + contextGL()->DrawArrays(mode, first, count); markContextChanged(CanvasChanged); } @@ -2173,7 +2173,7 @@ void WebGLRenderingContextBase::enable(GLenum cap) m_scissorEnabled = true; drawingBuffer()->setScissorEnabled(m_scissorEnabled); } - webContext()->enable(cap); + contextGL()->Enable(cap); } void WebGLRenderingContextBase::enableVertexAttribArray(GLuint index) @@ -2185,7 +2185,7 @@ void WebGLRenderingContextBase::enableVertexAttribArray(GLuint index) return; } - webContext()->enableVertexAttribArray(index); + contextGL()->EnableVertexAttribArray(index); } void WebGLRenderingContextBase::finish() @@ -3811,7 +3811,7 @@ void WebGLRenderingContextBase::bindValuebufferCHROMIUM(GLenum target, CHROMIUMV if (deleted) valuebuffer = 0; m_valuebufferBinding = valuebuffer; - webContext()->bindValuebufferCHROMIUM(target, objectOrZero(valuebuffer)); + contextGL()->BindValuebufferCHROMIUM(target, objectOrZero(valuebuffer)); if (valuebuffer) valuebuffer->setHasEverBeenBound(); } @@ -4069,7 +4069,7 @@ void WebGLRenderingContextBase::texImageCanvasByGPU(TexImageByGPUType functionTy targetInternalformat = GL_RGBA; targetType = GL_UNSIGNED_BYTE; targetTexture = webContext()->createTexture(); - webContext()->bindTexture(GL_TEXTURE_2D, targetTexture); + contextGL()->BindTexture(GL_TEXTURE_2D, targetTexture); webContext()->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); webContext()->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); webContext()->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); @@ -4080,14 +4080,14 @@ void WebGLRenderingContextBase::texImageCanvasByGPU(TexImageByGPUType functionTy if (!canvas->is3D()) { ImageBuffer* buffer = canvas->buffer(); - if (!buffer->copyToPlatformTexture(webContext(), targetTexture, targetInternalformat, targetType, + if (!buffer->copyToPlatformTexture(webContext(), contextGL(), targetTexture, targetInternalformat, targetType, targetLevel, m_unpackPremultiplyAlpha, m_unpackFlipY)) { ASSERT_NOT_REACHED(); } } else { WebGLRenderingContextBase* gl = toWebGLRenderingContextBase(canvas->renderingContext()); ScopedTexture2DRestorer restorer(gl); - if (!gl->drawingBuffer()->copyToPlatformTexture(webContext(), targetTexture, targetInternalformat, targetType, + if (!gl->drawingBuffer()->copyToPlatformTexture(webContext(), contextGL(), targetTexture, targetInternalformat, targetType, targetLevel, m_unpackPremultiplyAlpha, !m_unpackFlipY, BackBuffer)) { ASSERT_NOT_REACHED(); } @@ -4095,13 +4095,13 @@ void WebGLRenderingContextBase::texImageCanvasByGPU(TexImageByGPUType functionTy if (!possibleDirectCopy) { WebGLId tmpFBO = webContext()->createFramebuffer(); - webContext()->bindFramebuffer(GL_FRAMEBUFFER, tmpFBO); + contextGL()->BindFramebuffer(GL_FRAMEBUFFER, tmpFBO); contextGL()->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, targetTexture, 0); - webContext()->bindTexture(texture->getTarget(), texture->object()); + contextGL()->BindTexture(texture->getTarget(), texture->object()); if (functionType == TexImage2DByGPU) { - webContext()->copyTexSubImage2D(target, level, 0, 0, 0, 0, canvas->width(), canvas->height()); + contextGL()->CopyTexSubImage2D(target, level, 0, 0, 0, 0, canvas->width(), canvas->height()); } else if (functionType == TexSubImage2DByGPU) { - webContext()->copyTexSubImage2D(target, level, xoffset, yoffset, 0, 0, canvas->width(), canvas->height()); + contextGL()->CopyTexSubImage2D(target, level, xoffset, yoffset, 0, 0, canvas->width(), canvas->height()); } else if (functionType == TexSubImage3DByGPU) { webContext()->copyTexSubImage3D(target, level, xoffset, yoffset, zoffset, 0, 0, canvas->width(), canvas->height()); } @@ -4183,7 +4183,7 @@ void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLint int video->paintCurrentFrame(imageBuffer->canvas(), IntRect(0, 0, video->videoWidth(), video->videoHeight()), nullptr); // This is a straight GPU-GPU copy, any necessary color space conversion was handled in the paintCurrentFrameInContext() call. - if (imageBuffer->copyToPlatformTexture(webContext(), texture->object(), internalformat, type, + if (imageBuffer->copyToPlatformTexture(webContext(), contextGL(), texture->object(), internalformat, type, level, m_unpackPremultiplyAlpha, m_unpackFlipY)) { return; } @@ -6097,9 +6097,9 @@ void WebGLRenderingContextBase::enableOrDisable(GLenum capability, bool enable) if (isContextLost()) return; if (enable) - webContext()->enable(capability); + contextGL()->Enable(capability); else - webContext()->disable(capability); + contextGL()->Disable(capability); } IntSize WebGLRenderingContextBase::clampedCanvasSize() @@ -6149,7 +6149,7 @@ void WebGLRenderingContextBase::setFramebuffer(GLenum target, WebGLFramebuffer* // Instead of binding fb 0, bind the drawing buffer. drawingBuffer()->bind(target); } else { - webContext()->bindFramebuffer(target, buffer->object()); + contextGL()->BindFramebuffer(target, buffer->object()); } } diff --git a/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp b/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp index 21d3da2..19d3be5 100644 --- a/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp +++ b/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp @@ -217,6 +217,7 @@ bool Canvas2DLayerBridge::prepareIOSurfaceMailboxFromImage(SkImage* image, WebEx if (imageInfo.empty()) return false; + gpu::gles2::GLES2Interface* gl = contextGL(); GLuint imageTexture = skia::GrBackendObjectToGrGLTextureInfo(image->getTextureHandle(true))->fID; context()->copySubTextureCHROMIUM(imageTexture, imageInfo.m_textureId, 0, 0, 0, 0, m_size.width(), m_size.height(), GL_FALSE, GL_FALSE, GL_FALSE); @@ -226,14 +227,14 @@ bool Canvas2DLayerBridge::prepareIOSurfaceMailboxFromImage(SkImage* image, WebEx context()->produceTextureDirectCHROMIUM(imageInfo.m_textureId, info.m_mailbox.textureTarget, info.m_mailbox.name); info.m_mailbox.allowOverlay = true; - const WGC3Duint64 fenceSync = context()->insertFenceSyncCHROMIUM(); + const WGC3Duint64 fenceSync = gl->InsertFenceSyncCHROMIUM(); context()->flush(); info.m_mailbox.validSyncToken = context()->genSyncTokenCHROMIUM(fenceSync, info.m_mailbox.syncToken); info.m_imageInfo = imageInfo; *outMailbox = info.m_mailbox; - context()->bindTexture(GC3D_TEXTURE_RECTANGLE_ARB, 0); + gl->BindTexture(GC3D_TEXTURE_RECTANGLE_ARB, 0); // Because we are changing the texture binding without going through skia, // we must dirty the context. @@ -251,6 +252,7 @@ Canvas2DLayerBridge::ImageInfo Canvas2DLayerBridge::createIOSurfaceBackedTexture } WebGraphicsContext3D* webContext = context(); + gpu::gles2::GLES2Interface* gl = contextGL(); GLuint imageId = webContext->createGpuMemoryBufferImageCHROMIUM(m_size.width(), m_size.height(), GL_BGRA_EXT, GC3D_SCANOUT_CHROMIUM); if (!imageId) return Canvas2DLayerBridge::ImageInfo(); @@ -262,7 +264,7 @@ Canvas2DLayerBridge::ImageInfo Canvas2DLayerBridge::createIOSurfaceBackedTexture } GLenum target = GC3D_TEXTURE_RECTANGLE_ARB; - webContext->bindTexture(target, textureId); + gl->BindTexture(target, textureId); webContext->texParameteri(target, GL_TEXTURE_MAG_FILTER, getGLFilter()); webContext->texParameteri(target, GL_TEXTURE_MIN_FILTER, getGLFilter()); webContext->texParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); @@ -274,16 +276,17 @@ Canvas2DLayerBridge::ImageInfo Canvas2DLayerBridge::createIOSurfaceBackedTexture void Canvas2DLayerBridge::deleteCHROMIUMImage(ImageInfo info) { - if (m_contextProvider->contextGL()->GetGraphicsResetStatusKHR() != GL_NO_ERROR) + WebGraphicsContext3D* webContext = context(); + gpu::gles2::GLES2Interface* gl = contextGL(); + if (gl->GetGraphicsResetStatusKHR() != GL_NO_ERROR) return; GLenum target = GC3D_TEXTURE_RECTANGLE_ARB; - WebGraphicsContext3D* webContext = context(); - webContext->bindTexture(target, info.m_textureId); + gl->BindTexture(target, info.m_textureId); webContext->releaseTexImage2DCHROMIUM(target, info.m_imageId); webContext->destroyImageCHROMIUM(info.m_imageId); webContext->deleteTexture(info.m_textureId); - webContext->bindTexture(target, 0); + gl->BindTexture(target, 0); resetSkiaTextureBinding(); } @@ -341,8 +344,9 @@ bool Canvas2DLayerBridge::prepareMailboxFromImage(PassRefPtr image, Web mailboxInfo.m_mailbox.textureTarget = GL_TEXTURE_2D; WebGraphicsContext3D* webContext = context(); + gpu::gles2::GLES2Interface* gl = contextGL(); GLuint textureID = skia::GrBackendObjectToGrGLTextureInfo(mailboxInfo.m_image->getTextureHandle(true))->fID; - webContext->bindTexture(GL_TEXTURE_2D, textureID); + gl->BindTexture(GL_TEXTURE_2D, textureID); webContext->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, getGLFilter()); webContext->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, getGLFilter()); webContext->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); @@ -366,11 +370,11 @@ bool Canvas2DLayerBridge::prepareMailboxFromImage(PassRefPtr image, Web } else { // FIXME: We'd rather insert a syncpoint than perform a flush here, // but currently the canvas will flicker if we don't flush here. - const WGC3Duint64 fenceSync = webContext->insertFenceSyncCHROMIUM(); + const GLuint64 fenceSync = gl->InsertFenceSyncCHROMIUM(); webContext->flush(); mailboxInfo.m_mailbox.validSyncToken = webContext->genSyncTokenCHROMIUM(fenceSync, mailboxInfo.m_mailbox.syncToken); } - webContext->bindTexture(GL_TEXTURE_2D, 0); + gl->BindTexture(GL_TEXTURE_2D, 0); // Because we are changing the texture binding without going through skia, // we must dirty the context. grContext->resetContext(kTextureBinding_GrGLBackendState); @@ -718,6 +722,17 @@ WebGraphicsContext3D* Canvas2DLayerBridge::context() return m_contextProvider ? m_contextProvider->context3d() : 0; } +gpu::gles2::GLES2Interface* Canvas2DLayerBridge::contextGL() +{ + // Check on m_layer is necessary because contextGL() may be called during + // the destruction of m_layer + if (m_layer && !m_destructionInProgress) { + // Ensure rate limiter is disabled if context is lost. + checkSurfaceValid(); + } + return m_contextProvider ? m_contextProvider->contextGL() : nullptr; +} + bool Canvas2DLayerBridge::checkSurfaceValid() { ASSERT(!m_destructionInProgress); @@ -844,7 +859,7 @@ void Canvas2DLayerBridge::mailboxReleased(const WebExternalTextureMailbox& mailb ASSERT(releasedMailboxInfo->m_imageInfo.empty()); #endif // USE_IOSURFACE_FOR_2D_CANVAS if (mailbox.validSyncToken) { - context()->waitSyncTokenCHROMIUM(mailbox.syncToken); + contextGL()->WaitSyncTokenCHROMIUM(mailbox.syncToken); } GrTexture* texture = releasedMailboxInfo->m_image->getTexture(); if (texture) { diff --git a/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.h b/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.h index c3dc4ca..fc314be 100644 --- a/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.h +++ b/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.h @@ -45,6 +45,12 @@ class SkPictureRecorder; +namespace gpu { +namespace gles2 { +class GLES2Interface; +} +} + namespace blink { class Canvas2DLayerBridgeHistogramLogger; @@ -176,6 +182,7 @@ private: Canvas2DLayerBridge(PassOwnPtr, const IntSize&, int msaaSampleCount, OpacityMode, AccelerationMode); WebGraphicsContext3D* context(); + gpu::gles2::GLES2Interface* contextGL(); void startRecording(); void skipQueuedDrawCommands(); void flushRecordingOnly(); diff --git a/third_party/WebKit/Source/platform/graphics/ImageBuffer.cpp b/third_party/WebKit/Source/platform/graphics/ImageBuffer.cpp index 0d45edd..78e01fb 100644 --- a/third_party/WebKit/Source/platform/graphics/ImageBuffer.cpp +++ b/third_party/WebKit/Source/platform/graphics/ImageBuffer.cpp @@ -32,7 +32,7 @@ #include "platform/graphics/ImageBuffer.h" -#include "GrContext.h" +#include "gpu/command_buffer/client/gles2_interface.h" #include "platform/MIMETypeRegistry.h" #include "platform/geometry/IntRect.h" #include "platform/graphics/GraphicsContext.h" @@ -52,6 +52,7 @@ #include "public/platform/WebGraphicsContext3DProvider.h" #include "skia/ext/texture_handle.h" #include "third_party/skia/include/core/SkPicture.h" +#include "third_party/skia/include/gpu/GrContext.h" #include "third_party/skia/include/gpu/gl/GrGLTypes.h" #include "wtf/ArrayBufferContents.h" #include "wtf/MathExtras.h" @@ -177,7 +178,7 @@ WebLayer* ImageBuffer::platformLayer() const return m_surface->layer(); } -bool ImageBuffer::copyToPlatformTexture(WebGraphicsContext3D* context, Platform3DObject texture, GLenum internalFormat, GLenum destType, GLint level, bool premultiplyAlpha, bool flipY) +bool ImageBuffer::copyToPlatformTexture(WebGraphicsContext3D* context, gpu::gles2::GLES2Interface* gl, Platform3DObject texture, GLenum internalFormat, GLenum destType, GLint level, bool premultiplyAlpha, bool flipY) { if (!Extensions3DUtil::canUseCopyTextureCHROMIUM(GL_TEXTURE_2D, internalFormat, destType, level)) return false; @@ -203,6 +204,7 @@ bool ImageBuffer::copyToPlatformTexture(WebGraphicsContext3D* context, Platform3 if (!provider) return false; WebGraphicsContext3D* sharedContext = provider->context3d(); + gpu::gles2::GLES2Interface* sharedGL = provider->contextGL(); OwnPtr mailbox = adoptPtr(new WebExternalTextureMailbox); mailbox->textureSize = WebSize(textureImage->width(), textureImage->height()); @@ -210,12 +212,12 @@ bool ImageBuffer::copyToPlatformTexture(WebGraphicsContext3D* context, Platform3 // Contexts may be in a different share group. We must transfer the texture through a mailbox first sharedContext->genMailboxCHROMIUM(mailbox->name); sharedContext->produceTextureDirectCHROMIUM(textureInfo->fID, textureInfo->fTarget, mailbox->name); - const WGC3Duint64 sharedFenceSync = sharedContext->insertFenceSyncCHROMIUM(); + const GLuint64 sharedFenceSync = sharedGL->InsertFenceSyncCHROMIUM(); sharedContext->flush(); mailbox->validSyncToken = sharedContext->genSyncTokenCHROMIUM(sharedFenceSync, mailbox->syncToken); if (mailbox->validSyncToken) - context->waitSyncTokenCHROMIUM(mailbox->syncToken); + gl->WaitSyncTokenCHROMIUM(mailbox->syncToken); Platform3DObject sourceTexture = context->createAndConsumeTextureCHROMIUM(textureInfo->fTarget, mailbox->name); @@ -225,13 +227,13 @@ bool ImageBuffer::copyToPlatformTexture(WebGraphicsContext3D* context, Platform3 context->deleteTexture(sourceTexture); - const WGC3Duint64 contextFenceSync = context->insertFenceSyncCHROMIUM(); + const GLuint64 contextFenceSync = gl->InsertFenceSyncCHROMIUM(); context->flush(); WGC3Dbyte syncToken[24]; if (context->genSyncTokenCHROMIUM(contextFenceSync, syncToken)) - sharedContext->waitSyncTokenCHROMIUM(syncToken); + sharedGL->WaitSyncTokenCHROMIUM(syncToken); // Undo grContext texture binding changes introduced in this function provider->grContext()->resetContext(kTextureBinding_GrGLBackendState); @@ -247,13 +249,14 @@ bool ImageBuffer::copyRenderingResultsFromDrawingBuffer(DrawingBuffer* drawingBu if (!provider) return false; WebGraphicsContext3D* context3D = provider->context3d(); + gpu::gles2::GLES2Interface* gl = provider->contextGL(); Platform3DObject textureId = m_surface->getBackingTextureHandleForOverwrite(); if (!textureId) return false; context3D->flush(); - return drawingBuffer->copyToPlatformTexture(context3D, textureId, GL_RGBA, + return drawingBuffer->copyToPlatformTexture(context3D, gl, textureId, GL_RGBA, GL_UNSIGNED_BYTE, 0, true, false, sourceBuffer); } diff --git a/third_party/WebKit/Source/platform/graphics/ImageBuffer.h b/third_party/WebKit/Source/platform/graphics/ImageBuffer.h index a794d6c..83039ac 100644 --- a/third_party/WebKit/Source/platform/graphics/ImageBuffer.h +++ b/third_party/WebKit/Source/platform/graphics/ImageBuffer.h @@ -45,6 +45,12 @@ #include "wtf/Vector.h" #include "wtf/text/WTFString.h" +namespace gpu { +namespace gles2 { +class GLES2Interface; +} +} + namespace WTF { class ArrayBufferContents; @@ -118,7 +124,7 @@ public: // with textures that are RGB or RGBA format, UNSIGNED_BYTE type and level 0, as specified in // Extensions3D::canUseCopyTextureCHROMIUM(). // Destroys the TEXTURE_2D binding for the active texture unit of the passed context - bool copyToPlatformTexture(WebGraphicsContext3D*, Platform3DObject, GLenum, GLenum, GLint, bool, bool); + bool copyToPlatformTexture(WebGraphicsContext3D*, gpu::gles2::GLES2Interface*, Platform3DObject, GLenum, GLenum, GLint, bool, bool); bool copyRenderingResultsFromDrawingBuffer(DrawingBuffer*, SourceDrawingBuffer); diff --git a/third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp b/third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp index 1cfa344..861edba 100644 --- a/third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp +++ b/third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp @@ -66,21 +66,21 @@ class ScopedTextureUnit0BindingRestorer { STACK_ALLOCATED(); WTF_MAKE_NONCOPYABLE(ScopedTextureUnit0BindingRestorer); public: - ScopedTextureUnit0BindingRestorer(WebGraphicsContext3D* context, GLenum activeTextureUnit, Platform3DObject textureUnitZeroId) - : m_context(context) + ScopedTextureUnit0BindingRestorer(gpu::gles2::GLES2Interface* gl, GLenum activeTextureUnit, Platform3DObject textureUnitZeroId) + : m_gl(gl) , m_oldActiveTextureUnit(activeTextureUnit) , m_oldTextureUnitZeroId(textureUnitZeroId) { - m_context->activeTexture(GL_TEXTURE0); + m_gl->ActiveTexture(GL_TEXTURE0); } ~ScopedTextureUnit0BindingRestorer() { - m_context->bindTexture(GL_TEXTURE_2D, m_oldTextureUnitZeroId); - m_context->activeTexture(m_oldActiveTextureUnit); + m_gl->BindTexture(GL_TEXTURE_2D, m_oldTextureUnitZeroId); + m_gl->ActiveTexture(m_oldActiveTextureUnit); } private: - WebGraphicsContext3D* m_context; + gpu::gles2::GLES2Interface* m_gl; GLenum m_oldActiveTextureUnit; Platform3DObject m_oldTextureUnitZeroId; }; @@ -269,7 +269,7 @@ bool DrawingBuffer::prepareMailbox(WebExternalTextureMailbox* outMailbox, WebExt // We must restore the texture binding since creating new textures, // consuming and producing mailboxes changes it. - ScopedTextureUnit0BindingRestorer restorer(m_context.get(), m_activeTextureUnit, m_texture2DBinding); + ScopedTextureUnit0BindingRestorer restorer(m_gl, m_activeTextureUnit, m_texture2DBinding); // First try to recycle an old buffer. RefPtr frontColorBufferMailbox = recycledMailbox(); @@ -290,13 +290,13 @@ bool DrawingBuffer::prepareMailbox(WebExternalTextureMailbox* outMailbox, WebExt // WebGLRenderingContext::clearIfComposited() call made before the next draw call which restores the framebuffer binding. // If this stops being true at some point, we should track the current framebuffer binding in the DrawingBuffer and restore // it after attaching the new back buffer here. - m_context->bindFramebuffer(GL_FRAMEBUFFER, m_fbo); + m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); attachColorBufferToCurrentFBO(); if (m_discardFramebufferSupported) { // Explicitly discard framebuffer to save GPU memory bandwidth for tile-based GPU arch. const WGC3Denum attachments[3] = { GL_COLOR_ATTACHMENT0, GL_DEPTH_ATTACHMENT, GL_STENCIL_ATTACHMENT}; - m_context->discardFramebufferEXT(GL_FRAMEBUFFER, 3, attachments); + m_gl->DiscardFramebufferEXT(GL_FRAMEBUFFER, 3, attachments); } } else { m_context->copyTextureCHROMIUM(m_colorBuffer.textureId, frontColorBufferMailbox->textureInfo.textureId, frontColorBufferMailbox->textureInfo.parameters.internalColorFormat, GL_UNSIGNED_BYTE, GL_FALSE, GL_FALSE, GL_FALSE); @@ -306,7 +306,7 @@ bool DrawingBuffer::prepareMailbox(WebExternalTextureMailbox* outMailbox, WebExt m_contentsChanged = false; m_context->produceTextureDirectCHROMIUM(frontColorBufferMailbox->textureInfo.textureId, frontColorBufferMailbox->textureInfo.parameters.target, frontColorBufferMailbox->mailbox.name); - const WGC3Duint64 fenceSync = m_context->insertFenceSyncCHROMIUM(); + const GLuint64 fenceSync = m_gl->InsertFenceSyncCHROMIUM(); m_context->flush(); frontColorBufferMailbox->mailbox.validSyncToken = m_context->genSyncTokenCHROMIUM(fenceSync, frontColorBufferMailbox->mailbox.syncToken); frontColorBufferMailbox->mailbox.allowOverlay = frontColorBufferMailbox->textureInfo.imageId != 0; @@ -407,7 +407,7 @@ PassRefPtr DrawingBuffer::recycledMailbox() ASSERT(mailboxInfo); if (mailboxInfo->mailbox.validSyncToken) { - m_context->waitSyncTokenCHROMIUM(mailboxInfo->mailbox.syncToken); + m_gl->WaitSyncTokenCHROMIUM(mailboxInfo->mailbox.syncToken); mailboxInfo->mailbox.validSyncToken = false; } @@ -434,7 +434,7 @@ void DrawingBuffer::deleteMailbox(const WebExternalTextureMailbox& mailbox) for (size_t i = 0; i < m_textureMailboxes.size(); i++) { if (nameEquals(m_textureMailboxes[i]->mailbox, mailbox)) { if (mailbox.validSyncToken) - m_context->waitSyncTokenCHROMIUM(mailbox.syncToken); + m_gl->WaitSyncTokenCHROMIUM(mailbox.syncToken); deleteChromiumImageForTexture(&m_textureMailboxes[i]->textureInfo); @@ -470,7 +470,7 @@ bool DrawingBuffer::initialize(const IntSize& size) m_fbo = m_context->createFramebuffer(); - m_context->bindFramebuffer(GL_FRAMEBUFFER, m_fbo); + m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); createSecondaryBuffers(); // We first try to initialize everything with the requested attributes. if (!reset(size)) @@ -502,7 +502,7 @@ bool DrawingBuffer::initialize(const IntSize& size) return true; } -bool DrawingBuffer::copyToPlatformTexture(WebGraphicsContext3D* context, Platform3DObject texture, GLenum internalFormat, +bool DrawingBuffer::copyToPlatformTexture(WebGraphicsContext3D* context, gpu::gles2::GLES2Interface* gl, Platform3DObject texture, GLenum internalFormat, GLenum destType, GLint level, bool premultiplyAlpha, bool flipY, SourceDrawingBuffer sourceBuffer) { if (m_contentsChanged) { @@ -530,13 +530,13 @@ bool DrawingBuffer::copyToPlatformTexture(WebGraphicsContext3D* context, Platfor target = m_colorBuffer.parameters.target; m_context->genMailboxCHROMIUM(mailbox.name); m_context->produceTextureDirectCHROMIUM(textureId, target, mailbox.name); - const WGC3Duint64 fenceSync = m_context->insertFenceSyncCHROMIUM(); + const GLuint64 fenceSync = m_gl->InsertFenceSyncCHROMIUM(); m_context->flush(); mailbox.validSyncToken = m_context->genSyncTokenCHROMIUM(fenceSync, mailbox.syncToken); } if (mailbox.validSyncToken) - context->waitSyncTokenCHROMIUM(mailbox.syncToken); + gl->WaitSyncTokenCHROMIUM(mailbox.syncToken); Platform3DObject sourceTexture = context->createAndConsumeTextureCHROMIUM(target, mailbox.name); GLboolean unpackPremultiplyAlphaNeeded = GL_FALSE; @@ -550,12 +550,12 @@ bool DrawingBuffer::copyToPlatformTexture(WebGraphicsContext3D* context, Platfor context->deleteTexture(sourceTexture); - const WGC3Duint64 fenceSync = context->insertFenceSyncCHROMIUM(); + const GLuint64 fenceSync = gl->InsertFenceSyncCHROMIUM(); context->flush(); GLbyte syncToken[24]; if (context->genSyncTokenCHROMIUM(fenceSync, syncToken)) - m_context->waitSyncTokenCHROMIUM(syncToken); + m_gl->WaitSyncTokenCHROMIUM(syncToken); return true; } @@ -634,7 +634,7 @@ WebGLId DrawingBuffer::createColorTexture(const TextureParameters& parameters) if (!offscreenColorTexture) return 0; - m_context->bindTexture(parameters.target, offscreenColorTexture); + m_gl->BindTexture(parameters.target, offscreenColorTexture); m_context->texParameteri(parameters.target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); m_context->texParameteri(parameters.target, GL_TEXTURE_MIN_FILTER, GL_LINEAR); m_context->texParameteri(parameters.target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); @@ -648,17 +648,17 @@ void DrawingBuffer::createSecondaryBuffers() // create a multisample FBO if (m_antiAliasingMode == MSAAExplicitResolve) { m_multisampleFBO = m_context->createFramebuffer(); - m_context->bindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO); + m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO); m_multisampleColorBuffer = m_context->createRenderbuffer(); } } bool DrawingBuffer::resizeFramebuffer(const IntSize& size) { - m_context->bindFramebuffer(GL_FRAMEBUFFER, m_fbo); + m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); if (m_antiAliasingMode != MSAAExplicitResolve) resizeDepthStencil(size); - if (m_context->checkFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) + if (m_gl->CheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) return false; return true; @@ -667,17 +667,17 @@ bool DrawingBuffer::resizeFramebuffer(const IntSize& size) bool DrawingBuffer::resizeMultisampleFramebuffer(const IntSize& size) { if (m_antiAliasingMode == MSAAExplicitResolve) { - m_context->bindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO); + m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO); - m_context->bindRenderbuffer(GL_RENDERBUFFER, m_multisampleColorBuffer); - m_context->renderbufferStorageMultisampleCHROMIUM(GL_RENDERBUFFER, m_sampleCount, m_colorBuffer.parameters.internalRenderbufferFormat, size.width(), size.height()); + m_gl->BindRenderbuffer(GL_RENDERBUFFER, m_multisampleColorBuffer); + m_gl->RenderbufferStorageMultisampleCHROMIUM(GL_RENDERBUFFER, m_sampleCount, m_colorBuffer.parameters.internalRenderbufferFormat, size.width(), size.height()); if (m_context->getError() == GL_OUT_OF_MEMORY) return false; m_gl->FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_multisampleColorBuffer); resizeDepthStencil(size); - if (m_context->checkFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) + if (m_gl->CheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) return false; } @@ -691,15 +691,15 @@ void DrawingBuffer::resizeDepthStencil(const IntSize& size) if (!m_depthStencilBuffer) m_depthStencilBuffer = m_context->createRenderbuffer(); - m_context->bindRenderbuffer(GL_RENDERBUFFER, m_depthStencilBuffer); + m_gl->BindRenderbuffer(GL_RENDERBUFFER, m_depthStencilBuffer); if (m_antiAliasingMode == MSAAImplicitResolve) m_context->renderbufferStorageMultisampleEXT(GL_RENDERBUFFER, m_sampleCount, GL_DEPTH24_STENCIL8_OES, size.width(), size.height()); else if (m_antiAliasingMode == MSAAExplicitResolve) - m_context->renderbufferStorageMultisampleCHROMIUM(GL_RENDERBUFFER, m_sampleCount, GL_DEPTH24_STENCIL8_OES, size.width(), size.height()); + m_gl->RenderbufferStorageMultisampleCHROMIUM(GL_RENDERBUFFER, m_sampleCount, GL_DEPTH24_STENCIL8_OES, size.width(), size.height()); else m_context->renderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_OES, size.width(), size.height()); m_gl->FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_depthStencilBuffer); - m_context->bindRenderbuffer(GL_RENDERBUFFER, 0); + m_gl->BindRenderbuffer(GL_RENDERBUFFER, 0); } @@ -708,12 +708,12 @@ void DrawingBuffer::clearFramebuffers(GLbitfield clearMask) { // We will clear the multisample FBO, but we also need to clear the non-multisampled buffer. if (m_multisampleFBO) { - m_context->bindFramebuffer(GL_FRAMEBUFFER, m_fbo); - m_context->clear(GL_COLOR_BUFFER_BIT); + m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); + m_gl->Clear(GL_COLOR_BUFFER_BIT); } - m_context->bindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO ? m_multisampleFBO : m_fbo); - m_context->clear(clearMask); + m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO ? m_multisampleFBO : m_fbo); + m_gl->Clear(clearMask); } bool DrawingBuffer::hasImplicitStencilBuffer() const @@ -758,7 +758,7 @@ bool DrawingBuffer::reset(const IntSize& newSize) m_colorBuffer = createTextureAndAllocateMemory(adjustedSize); } - m_context->bindFramebuffer(GL_FRAMEBUFFER, m_fbo); + m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); attachColorBufferToCurrentFBO(); // resize multisample FBO @@ -775,18 +775,18 @@ bool DrawingBuffer::reset(const IntSize& newSize) return false; } - m_context->disable(GL_SCISSOR_TEST); - m_context->clearColor(0, 0, 0, 0); - m_context->colorMask(true, true, true, true); + m_gl->Disable(GL_SCISSOR_TEST); + m_gl->ClearColor(0, 0, 0, 0); + m_gl->ColorMask(true, true, true, true); GLbitfield clearMask = GL_COLOR_BUFFER_BIT; if (m_actualAttributes.depth) { - m_context->clearDepth(1.0f); + m_gl->ClearDepthf(1.0f); clearMask |= GL_DEPTH_BUFFER_BIT; - m_context->depthMask(true); + m_gl->DepthMask(true); } if (m_actualAttributes.stencil) { - m_context->clearStencil(0); + m_gl->ClearStencil(0); clearMask |= GL_STENCIL_BUFFER_BIT; m_context->stencilMaskSeparate(GL_FRONT, 0xFFFFFFFF); } @@ -798,11 +798,11 @@ bool DrawingBuffer::reset(const IntSize& newSize) void DrawingBuffer::commit() { if (m_multisampleFBO && !m_contentsChangeCommitted) { - m_context->bindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, m_multisampleFBO); - m_context->bindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, m_fbo); + m_gl->BindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, m_multisampleFBO); + m_gl->BindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, m_fbo); if (m_scissorEnabled) - m_context->disable(GL_SCISSOR_TEST); + m_gl->Disable(GL_SCISSOR_TEST); int width = m_size.width(); int height = m_size.height(); @@ -810,12 +810,12 @@ void DrawingBuffer::commit() m_context->blitFramebufferCHROMIUM(0, 0, width, height, 0, 0, width, height, GL_COLOR_BUFFER_BIT, GL_NEAREST); if (m_scissorEnabled) - m_context->enable(GL_SCISSOR_TEST); + m_gl->Enable(GL_SCISSOR_TEST); } - m_context->bindFramebuffer(GL_FRAMEBUFFER, m_fbo); + m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); if (m_antiAliasingMode == ScreenSpaceAntialiasing) { - m_context->applyScreenSpaceAntialiasingCHROMIUM(); + m_gl->ApplyScreenSpaceAntialiasingCHROMIUM(); } m_contentsChangeCommitted = true; } @@ -824,10 +824,10 @@ void DrawingBuffer::restoreFramebufferBindings() { if (m_drawFramebufferBinding && m_readFramebufferBinding) { if (m_drawFramebufferBinding == m_readFramebufferBinding) { - m_context->bindFramebuffer(GL_FRAMEBUFFER, m_readFramebufferBinding); + m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_readFramebufferBinding); } else { - m_context->bindFramebuffer(GL_READ_FRAMEBUFFER, m_readFramebufferBinding); - m_context->bindFramebuffer(GL_DRAW_FRAMEBUFFER, m_drawFramebufferBinding); + m_gl->BindFramebuffer(GL_READ_FRAMEBUFFER, m_readFramebufferBinding); + m_gl->BindFramebuffer(GL_DRAW_FRAMEBUFFER, m_drawFramebufferBinding); } return; } @@ -837,10 +837,10 @@ void DrawingBuffer::restoreFramebufferBindings() } if (!m_drawFramebufferBinding) { bind(GL_DRAW_FRAMEBUFFER); - m_context->bindFramebuffer(GL_READ_FRAMEBUFFER, m_readFramebufferBinding); + m_gl->BindFramebuffer(GL_READ_FRAMEBUFFER, m_readFramebufferBinding); } else { bind(GL_READ_FRAMEBUFFER); - m_context->bindFramebuffer(GL_DRAW_FRAMEBUFFER, m_drawFramebufferBinding); + m_gl->BindFramebuffer(GL_DRAW_FRAMEBUFFER, m_drawFramebufferBinding); } } @@ -852,9 +852,9 @@ bool DrawingBuffer::multisample() const void DrawingBuffer::bind(GLenum target) { if (target != GL_READ_FRAMEBUFFER) - m_context->bindFramebuffer(target, m_multisampleFBO ? m_multisampleFBO : m_fbo); + m_gl->BindFramebuffer(target, m_multisampleFBO ? m_multisampleFBO : m_fbo); else - m_context->bindFramebuffer(target, m_fbo); + m_gl->BindFramebuffer(target, m_fbo); } void DrawingBuffer::setPackAlignment(GLint param) @@ -879,10 +879,10 @@ bool DrawingBuffer::paintRenderingResultsToImageData(int& width, int& height, So GLint fbo = 0; if (sourceBuffer == FrontBuffer && m_frontColorBuffer.texInfo.textureId) { fbo = m_context->createFramebuffer(); - m_context->bindFramebuffer(GL_FRAMEBUFFER, 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 { - m_context->bindFramebuffer(GL_FRAMEBUFFER, framebuffer()); + m_gl->BindFramebuffer(GL_FRAMEBUFFER, framebuffer()); } readBackFramebuffer(static_cast(pixels.data()), width, height, ReadbackRGBA, WebGLImageConversion::AlphaDoNothing); @@ -954,7 +954,7 @@ void DrawingBuffer::texImage2DResourceSafe(GLenum target, GLint level, GLenum in void DrawingBuffer::deleteChromiumImageForTexture(TextureInfo* info) { if (info->imageId) { - m_context->bindTexture(info->parameters.target, info->textureId); + m_gl->BindTexture(info->parameters.target, info->textureId); m_context->releaseTexImage2DCHROMIUM(info->parameters.target, info->imageId); m_context->destroyImageCHROMIUM(info->imageId); info->imageId = 0; @@ -1013,7 +1013,7 @@ void DrawingBuffer::resizeTextureMemory(TextureInfo* info, const IntSize& size) deleteChromiumImageForTexture(info); info->imageId = m_context->createGpuMemoryBufferImageCHROMIUM(size.width(), size.height(), info->parameters.internalColorFormat, GC3D_SCANOUT_CHROMIUM); if (info->imageId) { - m_context->bindTexture(info->parameters.target, info->textureId); + m_gl->BindTexture(info->parameters.target, info->textureId); m_context->bindTexImage2DCHROMIUM(info->parameters.target, info->imageId); return; } @@ -1024,7 +1024,7 @@ void DrawingBuffer::resizeTextureMemory(TextureInfo* info, const IntSize& size) return; } - m_context->bindTexture(info->parameters.target, info->textureId); + m_gl->BindTexture(info->parameters.target, info->textureId); texImage2DResourceSafe(info->parameters.target, 0, info->parameters.internalColorFormat, size.width(), size.height(), 0, info->parameters.colorFormat, GL_UNSIGNED_BYTE); } @@ -1032,14 +1032,14 @@ void DrawingBuffer::attachColorBufferToCurrentFBO() { WGC3Denum target = m_colorBuffer.parameters.target; - m_context->bindTexture(target, m_colorBuffer.textureId); + m_gl->BindTexture(target, m_colorBuffer.textureId); if (m_antiAliasingMode == MSAAImplicitResolve) m_context->framebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, target, m_colorBuffer.textureId, 0, m_sampleCount); else m_gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, target, m_colorBuffer.textureId, 0); - m_context->bindTexture(GL_TEXTURE_2D, m_texture2DBinding); + m_gl->BindTexture(GL_TEXTURE_2D, m_texture2DBinding); } } // namespace blink diff --git a/third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.h b/third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.h index 80e83bf..856619c 100644 --- a/third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.h +++ b/third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.h @@ -161,7 +161,7 @@ public: void mailboxReleased(const WebExternalTextureMailbox&, bool lostResource = false) override; // Destroys the TEXTURE_2D binding for the owned context - bool copyToPlatformTexture(WebGraphicsContext3D*, Platform3DObject texture, GLenum internalFormat, + bool copyToPlatformTexture(WebGraphicsContext3D*, gpu::gles2::GLES2Interface*, Platform3DObject texture, GLenum internalFormat, GLenum destType, GLint level, bool premultiplyAlpha, bool flipY, SourceDrawingBuffer); void setPackAlignment(GLint param); diff --git a/third_party/WebKit/Source/platform/graphics/gpu/DrawingBufferTest.cpp b/third_party/WebKit/Source/platform/graphics/gpu/DrawingBufferTest.cpp index 2ced4a1..9b13f2e 100644 --- a/third_party/WebKit/Source/platform/graphics/gpu/DrawingBufferTest.cpp +++ b/third_party/WebKit/Source/platform/graphics/gpu/DrawingBufferTest.cpp @@ -70,23 +70,8 @@ WGC3Denum drawingBufferTextureTarget(bool allowImageChromium) } // namespace class GLES2InterfaceForTests : public gpu::gles2::GLES2InterfaceStub { -}; - -class WebGraphicsContext3DForTests : public MockWebGraphicsContext3D { public: - WebGraphicsContext3DForTests(PassOwnPtr contextGL) - : MockWebGraphicsContext3D() - , m_boundTexture(0) - , m_boundTextureTarget(0) - , m_currentMailboxByte(0) - , m_mostRecentlyWaitedSyncToken(0) - , m_currentImageId(1) - , m_allowImageChromium(true) - , m_contextGL(std::move(contextGL)) - { - } - - void bindTexture(WGC3Denum target, WebGLId texture) override + void BindTexture(GLenum target, GLuint texture) override { if (target != m_boundTextureTarget && texture == 0) return; @@ -97,10 +82,46 @@ public: m_boundTexture = texture; } + GLuint64 InsertFenceSyncCHROMIUM() override + { + static WGC3Duint64 syncPointGenerator = 0; + return ++syncPointGenerator; + } + + void WaitSyncTokenCHROMIUM(const GLbyte* syncToken) override + { + memcpy(&m_mostRecentlyWaitedSyncToken, syncToken, sizeof(m_mostRecentlyWaitedSyncToken)); + } + + GLenum CheckFramebufferStatus(GLenum target) override + { + return GL_FRAMEBUFFER_COMPLETE; + } + + uint32_t boundTexture() const { return m_boundTexture; } + uint32_t boundTextureTarget() const { return m_boundTextureTarget; } + uint32_t mostRecentlyWaitedSyncToken() const { return m_mostRecentlyWaitedSyncToken; } + +private: + uint32_t m_boundTexture = 0; + uint32_t m_boundTextureTarget = 0; + uint32_t m_mostRecentlyWaitedSyncToken = 0; +}; + +class WebGraphicsContext3DForTests : public MockWebGraphicsContext3D { +public: + WebGraphicsContext3DForTests(PassOwnPtr contextGL) + : m_currentMailboxByte(0) + , m_currentImageId(1) + , m_allowImageChromium(true) + , m_contextGL(std::move(contextGL)) + { + } + void texImage2D(WGC3Denum target, WGC3Dint level, WGC3Denum internalformat, WGC3Dsizei width, WGC3Dsizei height, WGC3Dint border, WGC3Denum format, WGC3Denum type, const void* pixels) override { if (target == GL_TEXTURE_2D && !level) { - m_textureSizes.set(m_boundTexture, IntSize(width, height)); + m_textureSizes.set(m_contextGL->boundTexture(), IntSize(width, height)); } } @@ -123,23 +144,12 @@ public: return m_mostRecentlyProducedSize; } - WGC3Duint64 insertFenceSyncCHROMIUM() override - { - static WGC3Duint64 syncPointGenerator = 0; - return ++syncPointGenerator; - } - bool genSyncTokenCHROMIUM(WGC3Duint64 fenceSync, WGC3Dbyte* syncToken) override { memcpy(syncToken, &fenceSync, sizeof(fenceSync)); return true; } - void waitSyncTokenCHROMIUM(const WGC3Dbyte* syncToken) override - { - memcpy(&m_mostRecentlyWaitedSyncToken, syncToken, sizeof(m_mostRecentlyWaitedSyncToken)); - } - WGC3Duint createGpuMemoryBufferImageCHROMIUM(WGC3Dsizei width, WGC3Dsizei height, WGC3Denum internalformat, WGC3Denum usage) override { if (!m_allowImageChromium) @@ -162,8 +172,8 @@ public: void bindTexImage2DCHROMIUM(WGC3Denum target, WGC3Dint imageId) { if (target == imageTextureTarget()) { - m_textureSizes.set(m_boundTexture, m_imageSizes.find(imageId)->value); - m_imageToTextureMap.set(imageId, m_boundTexture); + m_textureSizes.set(m_contextGL->boundTexture(), m_imageSizes.find(imageId)->value); + m_imageToTextureMap.set(imageId, m_contextGL->boundTexture()); bindTexImage2DMock(imageId); } } @@ -180,7 +190,7 @@ public: WGC3Duint mostRecentlyWaitedSyncToken() { - return m_mostRecentlyWaitedSyncToken; + return m_contextGL->mostRecentlyWaitedSyncToken(); } WGC3Duint nextImageIdToBeCreated() @@ -199,12 +209,9 @@ public: } private: - WebGLId m_boundTexture; - WGC3Denum m_boundTextureTarget; HashMap m_textureSizes; WGC3Dbyte m_currentMailboxByte; IntSize m_mostRecentlyProducedSize; - WGC3Duint m_mostRecentlyWaitedSyncToken; WGC3Duint m_currentImageId; HashMap m_imageSizes; HashMap m_imageToTextureMap; @@ -451,7 +458,7 @@ TEST_F(DrawingBufferTest, verifyInsertAndWaitSyncTokenCorrectly) EXPECT_EQ(0u, webContext()->mostRecentlyWaitedSyncToken()); WGC3Duint64 waitSyncToken = 0; - webContext()->genSyncTokenCHROMIUM(webContext()->insertFenceSyncCHROMIUM(), reinterpret_cast(&waitSyncToken)); + webContext()->genSyncTokenCHROMIUM(m_gl->InsertFenceSyncCHROMIUM(), reinterpret_cast(&waitSyncToken)); memcpy(mailbox.syncToken, &waitSyncToken, sizeof(waitSyncToken)); mailbox.validSyncToken = true; m_drawingBuffer->mailboxReleased(mailbox, false); @@ -464,7 +471,7 @@ TEST_F(DrawingBufferTest, verifyInsertAndWaitSyncTokenCorrectly) EXPECT_EQ(waitSyncToken, webContext()->mostRecentlyWaitedSyncToken()); m_drawingBuffer->beginDestruction(); - webContext()->genSyncTokenCHROMIUM(webContext()->insertFenceSyncCHROMIUM(), reinterpret_cast(&waitSyncToken)); + webContext()->genSyncTokenCHROMIUM(m_gl->InsertFenceSyncCHROMIUM(), reinterpret_cast(&waitSyncToken)); memcpy(mailbox.syncToken, &waitSyncToken, sizeof(waitSyncToken)); mailbox.validSyncToken = true; m_drawingBuffer->mailboxReleased(mailbox, false); @@ -587,6 +594,11 @@ public: } } + GLenum CheckFramebufferStatus(GLenum target) override + { + return GL_FRAMEBUFFER_COMPLETE; + } + uint32_t stencilAttachment() const { return m_stencilAttachment; } uint32_t depthAttachment() const { return m_depthAttachment; } uint32_t depthStencilAttachment() const { return m_depthStencilAttachment; } @@ -717,7 +729,7 @@ TEST_F(DrawingBufferTest, verifySetIsHiddenProperlyAffectsMailboxes) m_drawingBuffer->markContentsChanged(); EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); - mailbox.validSyncToken = webContext()->genSyncTokenCHROMIUM(webContext()->insertFenceSyncCHROMIUM(), mailbox.syncToken); + mailbox.validSyncToken = webContext()->genSyncTokenCHROMIUM(m_gl->InsertFenceSyncCHROMIUM(), mailbox.syncToken); m_drawingBuffer->setIsHidden(true); m_drawingBuffer->mailboxReleased(mailbox); // m_drawingBuffer deletes mailbox immediately when hidden. diff --git a/third_party/WebKit/Source/platform/graphics/gpu/Extensions3DUtil.cpp b/third_party/WebKit/Source/platform/graphics/gpu/Extensions3DUtil.cpp index 4941e8d..ce6494c 100644 --- a/third_party/WebKit/Source/platform/graphics/gpu/Extensions3DUtil.cpp +++ b/third_party/WebKit/Source/platform/graphics/gpu/Extensions3DUtil.cpp @@ -69,7 +69,7 @@ bool Extensions3DUtil::ensureExtensionEnabled(const String& name) return true; if (m_requestableExtensions.contains(name)) { - m_context->requestExtensionCHROMIUM(name.ascii().data()); + m_gl->RequestExtensionCHROMIUM(name.ascii().data()); m_enabledExtensions.clear(); m_requestableExtensions.clear(); initializeExtensions(); diff --git a/third_party/WebKit/Source/platform/graphics/test/MockWebGraphicsContext3D.h b/third_party/WebKit/Source/platform/graphics/test/MockWebGraphicsContext3D.h index 14cde23..a986c12 100644 --- a/third_party/WebKit/Source/platform/graphics/test/MockWebGraphicsContext3D.h +++ b/third_party/WebKit/Source/platform/graphics/test/MockWebGraphicsContext3D.h @@ -43,59 +43,12 @@ public: virtual void synthesizeGLError(WGC3Denum) { } - virtual void discardFramebufferEXT(WGC3Denum target, WGC3Dsizei numAttachments, const WGC3Denum* attachments) { } - virtual void ensureFramebufferCHROMIUM() { } - virtual WebString getRequestableExtensionsCHROMIUM() { return WebString(); } - virtual void requestExtensionCHROMIUM(const char*) { } virtual void blitFramebufferCHROMIUM(WGC3Dint srcX0, WGC3Dint srcY0, WGC3Dint srcX1, WGC3Dint srcY1, WGC3Dint dstX0, WGC3Dint dstY0, WGC3Dint dstX1, WGC3Dint dstY1, WGC3Dbitfield mask, WGC3Denum filter) { } - virtual void renderbufferStorageMultisampleCHROMIUM(WGC3Denum target, WGC3Dsizei samples, WGC3Denum internalformat, WGC3Dsizei width, WGC3Dsizei height) { } - - virtual void activeTexture(WGC3Denum texture) { } - virtual void attachShader(WebGLId program, WebGLId shader) { } - virtual void bindAttribLocation(WebGLId program, WGC3Duint index, const WGC3Dchar* name) { } - virtual void bindBuffer(WGC3Denum target, WebGLId buffer) { } - virtual void bindFramebuffer(WGC3Denum target, WebGLId framebuffer) { } - virtual void bindRenderbuffer(WGC3Denum target, WebGLId renderbuffer) { } - virtual void bindTexture(WGC3Denum target, WebGLId texture) { } - virtual void blendColor(WGC3Dclampf red, WGC3Dclampf green, WGC3Dclampf blue, WGC3Dclampf alpha) { } - virtual void blendEquation(WGC3Denum mode) { } - virtual void blendEquationSeparate(WGC3Denum modeRGB, WGC3Denum modeAlpha) { } - virtual void blendFunc(WGC3Denum sfactor, WGC3Denum dfactor) { } - virtual void blendFuncSeparate(WGC3Denum srcRGB, WGC3Denum dstRGB, WGC3Denum srcAlpha, WGC3Denum dstAlpha) { } - - virtual void bufferData(WGC3Denum target, WGC3Dsizeiptr size, const void* data, WGC3Denum usage) { } - virtual void bufferSubData(WGC3Denum target, WGC3Dintptr offset, WGC3Dsizeiptr size, const void* data) { } - - virtual WGC3Denum checkFramebufferStatus(WGC3Denum target) - { - return GL_FRAMEBUFFER_COMPLETE; - } - virtual void clear(WGC3Dbitfield mask) { } - virtual void clearColor(WGC3Dclampf red, WGC3Dclampf green, WGC3Dclampf blue, WGC3Dclampf alpha) { } - virtual void clearDepth(WGC3Dclampf depth) { } - virtual void clearStencil(WGC3Dint s) { } - virtual void colorMask(WGC3Dboolean red, WGC3Dboolean green, WGC3Dboolean blue, WGC3Dboolean alpha) { } - virtual void compileShader(WebGLId shader) { } - - virtual void compressedTexImage2D(WGC3Denum target, WGC3Dint level, WGC3Denum internalformat, WGC3Dsizei width, WGC3Dsizei height, WGC3Dint border, WGC3Dsizei imageSize, const void* data) { } - virtual void compressedTexSubImage2D(WGC3Denum target, WGC3Dint level, WGC3Dint xoffset, WGC3Dint yoffset, WGC3Dsizei width, WGC3Dsizei height, WGC3Denum format, WGC3Dsizei imageSize, const void* data) { } - virtual void copyTexImage2D(WGC3Denum target, WGC3Dint level, WGC3Denum internalformat, WGC3Dint x, WGC3Dint y, WGC3Dsizei width, WGC3Dsizei height, WGC3Dint border) { } - virtual void copyTexSubImage2D(WGC3Denum target, WGC3Dint level, WGC3Dint xoffset, WGC3Dint yoffset, WGC3Dint x, WGC3Dint y, WGC3Dsizei width, WGC3Dsizei height) { } - virtual void cullFace(WGC3Denum mode) { } - virtual void depthFunc(WGC3Denum func) { } - virtual void depthMask(WGC3Dboolean flag) { } - virtual void depthRange(WGC3Dclampf zNear, WGC3Dclampf zFar) { } - virtual void detachShader(WebGLId program, WebGLId shader) { } - virtual void disable(WGC3Denum cap) { } - virtual void disableVertexAttribArray(WGC3Duint index) { } - virtual void drawArrays(WGC3Denum mode, WGC3Dint first, WGC3Dsizei count) { } virtual void drawElements(WGC3Denum mode, WGC3Dsizei count, WGC3Denum type, WGC3Dintptr offset) { } - virtual void enable(WGC3Denum cap) { } - virtual void enableVertexAttribArray(WGC3Duint index) { } virtual void finish() { } virtual void flush() { } virtual void frontFace(WGC3Denum mode) { } diff --git a/third_party/WebKit/public/platform/WebGraphicsContext3D.h b/third_party/WebKit/public/platform/WebGraphicsContext3D.h index ab0c4fb..12e0f4c 100644 --- a/third_party/WebKit/public/platform/WebGraphicsContext3D.h +++ b/third_party/WebKit/public/platform/WebGraphicsContext3D.h @@ -137,16 +137,7 @@ public: // This destructor needs to be public so that using classes can destroy instances if initialization fails. virtual ~WebGraphicsContext3D() { } - // Each flush or finish is assigned an unique ID. The larger - // the ID number, the more recently the context has been flushed. - virtual uint32_t lastFlushID() { return 0; } - - // GL_EXT_discard_framebuffer - makes specified attachments of currently bound framebuffer undefined. - virtual void discardFramebufferEXT(WGC3Denum target, WGC3Dsizei numAttachments, const WGC3Denum* attachments) { } - - virtual WGC3Duint64 insertFenceSyncCHROMIUM() { return 0; } virtual bool genSyncTokenCHROMIUM(WGC3Duint64, WGC3Dbyte*) { return false; } - virtual void waitSyncTokenCHROMIUM(const WGC3Dbyte*) {} // Synthesizes an OpenGL error which will be returned from a // later call to getError. This is used to emulate OpenGL ES @@ -160,55 +151,15 @@ public: // GL_CHROMIUM_request_extension virtual WebString getRequestableExtensionsCHROMIUM() = 0; - virtual void requestExtensionCHROMIUM(const char*) = 0; // GL_CHROMIUM_framebuffer_multisample virtual void blitFramebufferCHROMIUM(WGC3Dint srcX0, WGC3Dint srcY0, WGC3Dint srcX1, WGC3Dint srcY1, WGC3Dint dstX0, WGC3Dint dstY0, WGC3Dint dstX1, WGC3Dint dstY1, WGC3Dbitfield mask, WGC3Denum filter) = 0; - virtual void renderbufferStorageMultisampleCHROMIUM(WGC3Denum target, WGC3Dsizei samples, WGC3Denum internalformat, WGC3Dsizei width, WGC3Dsizei height) = 0; // The entry points below map directly to the OpenGL ES 2.0 API. // See: http://www.khronos.org/registry/gles/ // and: http://www.khronos.org/opengles/sdk/docs/man/ - virtual void activeTexture(WGC3Denum texture) = 0; - virtual void attachShader(WebGLId program, WebGLId shader) = 0; - virtual void bindAttribLocation(WebGLId program, WGC3Duint index, const WGC3Dchar* name) = 0; - virtual void bindBuffer(WGC3Denum target, WebGLId buffer) = 0; - virtual void bindFramebuffer(WGC3Denum target, WebGLId framebuffer) = 0; - virtual void bindRenderbuffer(WGC3Denum target, WebGLId renderbuffer) = 0; - virtual void bindTexture(WGC3Denum target, WebGLId texture) = 0; - virtual void blendColor(WGC3Dclampf red, WGC3Dclampf green, WGC3Dclampf blue, WGC3Dclampf alpha) = 0; - virtual void blendEquation(WGC3Denum mode) = 0; - virtual void blendEquationSeparate(WGC3Denum modeRGB, WGC3Denum modeAlpha) = 0; - virtual void blendFunc(WGC3Denum sfactor, WGC3Denum dfactor) = 0; - virtual void blendFuncSeparate(WGC3Denum srcRGB, WGC3Denum dstRGB, WGC3Denum srcAlpha, WGC3Denum dstAlpha) = 0; - - virtual void bufferData(WGC3Denum target, WGC3Dsizeiptr size, const void* data, WGC3Denum usage) = 0; - virtual void bufferSubData(WGC3Denum target, WGC3Dintptr offset, WGC3Dsizeiptr size, const void* data) = 0; - - virtual WGC3Denum checkFramebufferStatus(WGC3Denum target) = 0; - virtual void clear(WGC3Dbitfield mask) = 0; - virtual void clearColor(WGC3Dclampf red, WGC3Dclampf green, WGC3Dclampf blue, WGC3Dclampf alpha) = 0; - virtual void clearDepth(WGC3Dclampf depth) = 0; - virtual void clearStencil(WGC3Dint s) = 0; - virtual void colorMask(WGC3Dboolean red, WGC3Dboolean green, WGC3Dboolean blue, WGC3Dboolean alpha) = 0; - virtual void compileShader(WebGLId shader) = 0; - - virtual void compressedTexImage2D(WGC3Denum target, WGC3Dint level, WGC3Denum internalformat, WGC3Dsizei width, WGC3Dsizei height, WGC3Dint border, WGC3Dsizei imageSize, const void* data) = 0; - virtual void compressedTexSubImage2D(WGC3Denum target, WGC3Dint level, WGC3Dint xoffset, WGC3Dint yoffset, WGC3Dsizei width, WGC3Dsizei height, WGC3Denum format, WGC3Dsizei imageSize, const void* data) = 0; - virtual void copyTexImage2D(WGC3Denum target, WGC3Dint level, WGC3Denum internalformat, WGC3Dint x, WGC3Dint y, WGC3Dsizei width, WGC3Dsizei height, WGC3Dint border) = 0; - virtual void copyTexSubImage2D(WGC3Denum target, WGC3Dint level, WGC3Dint xoffset, WGC3Dint yoffset, WGC3Dint x, WGC3Dint y, WGC3Dsizei width, WGC3Dsizei height) = 0; - virtual void cullFace(WGC3Denum mode) = 0; - virtual void depthFunc(WGC3Denum func) = 0; - virtual void depthMask(WGC3Dboolean flag) = 0; - virtual void depthRange(WGC3Dclampf zNear, WGC3Dclampf zFar) = 0; - virtual void detachShader(WebGLId program, WebGLId shader) = 0; - virtual void disable(WGC3Denum cap) = 0; - virtual void disableVertexAttribArray(WGC3Duint index) = 0; - virtual void drawArrays(WGC3Denum mode, WGC3Dint first, WGC3Dsizei count) = 0; virtual void drawElements(WGC3Denum mode, WGC3Dsizei count, WGC3Denum type, WGC3Dintptr offset) = 0; - virtual void enable(WGC3Denum cap) = 0; - virtual void enableVertexAttribArray(WGC3Duint index) = 0; virtual void finish() = 0; virtual void flush() = 0; virtual void frontFace(WGC3Denum mode) = 0; @@ -331,9 +282,6 @@ public: virtual WebString getTranslatedShaderSourceANGLE(WebGLId shader) = 0; - // GL_CHROMIUM_screen_space_antialiasing - virtual void applyScreenSpaceAntialiasingCHROMIUM() { } - // GL_EXT_texture_storage virtual void texStorage2DEXT(WGC3Denum target, WGC3Dint levels, WGC3Duint internalformat, WGC3Dint width, WGC3Dint height) { } -- cgit v1.1