summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordanakj <danakj@chromium.org>2016-03-22 12:58:24 -0700
committerCommit bot <commit-bot@chromium.org>2016-03-22 20:00:16 +0000
commit11e6d011bc903cb926b1b6c40795c14f5af48384 (patch)
tree89a3e3788c6ab1a238ec14a3e2452d575e5e0238
parent840cab012a5c84ea39f564babc3ea5f92fedf023 (diff)
downloadchromium_src-11e6d011bc903cb926b1b6c40795c14f5af48384.zip
chromium_src-11e6d011bc903cb926b1b6c40795c14f5af48384.tar.gz
chromium_src-11e6d011bc903cb926b1b6c40795c14f5af48384.tar.bz2
Make Platform return a WebGraphicsContext3DProvider* always.
Currently we return a WebGraphicsContext3DProvider* for the shared main thread context (for canvas), but we return a WebGraphicsContext3D* for webgl. After this CL, Platform will return a WebGraphicsContext3DProvider* for webgl also, which can grab the WebGraphicsContext3D* and the GLES2Interface* off it. This is largely in preparation for exposing gpu::ContextSupport (or something wrapping it) on WebGraphicsContext3DProvider so that we can expose lost context callbacks through there instead of on WebGraphicsContext3D. R=kbr@chromium.org, pfeldman@chromium.org, piman@chromium.org TBR=pfeldman BUG=584497 CQ_INCLUDE_TRYBOTS=tryserver.chromium.win:win_optional_gpu_tests_rel Review URL: https://codereview.chromium.org/1822993002 Cr-Commit-Position: refs/heads/master@{#382657}
-rw-r--r--components/test_runner/test_plugin.cc17
-rw-r--r--components/test_runner/test_plugin.h2
-rw-r--r--content/common/gpu/gpu_command_buffer_stub.cc2
-rw-r--r--content/renderer/renderer_blink_platform_impl.cc58
-rw-r--r--content/renderer/renderer_blink_platform_impl.h9
-rw-r--r--third_party/WebKit/Source/modules/webgl/WebGL2RenderingContext.cpp17
-rw-r--r--third_party/WebKit/Source/modules/webgl/WebGL2RenderingContext.h2
-rw-r--r--third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp6
-rw-r--r--third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.h2
-rw-r--r--third_party/WebKit/Source/modules/webgl/WebGLRenderingContext.cpp17
-rw-r--r--third_party/WebKit/Source/modules/webgl/WebGLRenderingContext.h2
-rw-r--r--third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp32
-rw-r--r--third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.h6
-rw-r--r--third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp22
-rw-r--r--third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.h11
-rw-r--r--third_party/WebKit/Source/platform/graphics/gpu/DrawingBufferTest.cpp77
-rw-r--r--third_party/WebKit/public/platform/Platform.h19
17 files changed, 161 insertions, 140 deletions
diff --git a/components/test_runner/test_plugin.cc b/components/test_runner/test_plugin.cc
index 155fd6b..08aed02 100644
--- a/components/test_runner/test_plugin.cc
+++ b/components/test_runner/test_plugin.cc
@@ -20,6 +20,7 @@
#include "third_party/WebKit/public/platform/Platform.h"
#include "third_party/WebKit/public/platform/WebCompositorSupport.h"
#include "third_party/WebKit/public/platform/WebGraphicsContext3D.h"
+#include "third_party/WebKit/public/platform/WebGraphicsContext3DProvider.h"
#include "third_party/WebKit/public/platform/WebTaskRunner.h"
#include "third_party/WebKit/public/platform/WebThread.h"
#include "third_party/WebKit/public/platform/WebTraceLocation.h"
@@ -173,9 +174,12 @@ TestPlugin::~TestPlugin() {
bool TestPlugin::initialize(blink::WebPluginContainer* container) {
blink::WebGraphicsContext3D::Attributes attrs;
- context_ =
- blink::Platform::current()->createOffscreenGraphicsContext3D(attrs);
- gl_ = context_ ? context_->getGLES2Interface() : nullptr;
+ blink::WebGraphicsContext3D::WebGraphicsInfo gl_info;
+ context_provider_ = make_scoped_ptr(
+ blink::Platform::current()->createOffscreenGraphicsContext3DProvider(
+ attrs, nullptr, &gl_info));
+ context_ = context_provider_ ? context_provider_->context3d() : nullptr;
+ gl_ = context_provider_ ? context_provider_->contextGL() : nullptr;
if (!InitScene())
return false;
@@ -205,8 +209,7 @@ void TestPlugin::destroy() {
DestroyScene();
gl_ = nullptr;
- delete context_;
- context_ = nullptr;
+ context_provider_.reset();
container_ = nullptr;
frame_ = nullptr;
@@ -240,7 +243,7 @@ void TestPlugin::updateGeometry(
if (rect_.isEmpty()) {
texture_mailbox_ = cc::TextureMailbox();
- } else if (context_) {
+ } else if (gl_) {
gl_->Viewport(0, 0, rect_.width, rect_.height);
gl_->BindTexture(GL_TEXTURE_2D, color_texture_);
@@ -359,7 +362,7 @@ bool TestPlugin::ParseBoolean(const blink::WebString& string) {
}
bool TestPlugin::InitScene() {
- if (!context_)
+ if (!gl_)
return true;
float color[4];
diff --git a/components/test_runner/test_plugin.h b/components/test_runner/test_plugin.h
index cc91cbd..b074b6e 100644
--- a/components/test_runner/test_plugin.h
+++ b/components/test_runner/test_plugin.h
@@ -21,6 +21,7 @@
namespace blink {
class WebFrame;
class WebGraphicsContext3D;
+class WebGraphicsContext3DProvider;
class WebLayer;
struct WebPluginParams;
}
@@ -155,6 +156,7 @@ class TestPlugin : public blink::WebPlugin, public cc::TextureLayerClient {
blink::WebPluginContainer* container_;
blink::WebRect rect_;
+ scoped_ptr<blink::WebGraphicsContext3DProvider> context_provider_;
blink::WebGraphicsContext3D* context_;
gpu::gles2::GLES2Interface* gl_;
unsigned color_texture_;
diff --git a/content/common/gpu/gpu_command_buffer_stub.cc b/content/common/gpu/gpu_command_buffer_stub.cc
index ecb252e..ca4689b 100644
--- a/content/common/gpu/gpu_command_buffer_stub.cc
+++ b/content/common/gpu/gpu_command_buffer_stub.cc
@@ -105,7 +105,7 @@ class GpuCommandBufferMemoryTracker : public gpu::gles2::MemoryTracker {
// url_hash matches.
void FastSetActiveURL(const GURL& url, size_t url_hash, GpuChannel* channel) {
// Leave the previously set URL in the empty case -- empty URLs are given by
- // BlinkPlatformImpl::createOffscreenGraphicsContext3D. Hopefully the
+ // BlinkPlatformImpl::createOffscreenGraphicsContext3DProvider. Hopefully the
// onscreen context URL was set previously and will show up even when a crash
// occurs during offscreen command processing.
if (url.is_empty())
diff --git a/content/renderer/renderer_blink_platform_impl.cc b/content/renderer/renderer_blink_platform_impl.cc
index 9409b90..84e9f36 100644
--- a/content/renderer/renderer_blink_platform_impl.cc
+++ b/content/renderer/renderer_blink_platform_impl.cc
@@ -944,22 +944,7 @@ blink::WebSpeechSynthesizer* RendererBlinkPlatformImpl::createSpeechSynthesizer(
//------------------------------------------------------------------------------
-blink::WebGraphicsContext3D*
-RendererBlinkPlatformImpl::createOffscreenGraphicsContext3D(
- const blink::WebGraphicsContext3D::Attributes& attributes) {
- return createOffscreenGraphicsContext3D(attributes, NULL);
-}
-
-blink::WebGraphicsContext3D*
-RendererBlinkPlatformImpl::createOffscreenGraphicsContext3D(
- const blink::WebGraphicsContext3D::Attributes& attributes,
- blink::WebGraphicsContext3D* share_context) {
- blink::WebGraphicsContext3D::WebGraphicsInfo gl_info;
- return createOffscreenGraphicsContext3D(attributes, share_context, &gl_info);
-}
-
static void Collect3DContextInformationOnFailure(
- blink::WebGraphicsContext3D* share_context,
blink::WebGraphicsContext3D::WebGraphicsInfo* gl_info,
GpuChannelHost* host) {
DCHECK(gl_info);
@@ -997,44 +982,43 @@ static void Collect3DContextInformationOnFailure(
}
}
-blink::WebGraphicsContext3D*
-RendererBlinkPlatformImpl::createOffscreenGraphicsContext3D(
+blink::WebGraphicsContext3DProvider*
+RendererBlinkPlatformImpl::createOffscreenGraphicsContext3DProvider(
const blink::WebGraphicsContext3D::Attributes& attributes,
- blink::WebGraphicsContext3D* share_context,
+ blink::WebGraphicsContext3DProvider* share_provider,
blink::WebGraphicsContext3D::WebGraphicsInfo* gl_info) {
DCHECK(gl_info);
if (!RenderThreadImpl::current()) {
std::string error_message("Failed to run in Current RenderThreadImpl");
gl_info->errorMessage = WebString::fromUTF8(error_message);
- return NULL;
+ return nullptr;
}
scoped_refptr<GpuChannelHost> gpu_channel_host(
RenderThreadImpl::current()->EstablishGpuChannelSync(
CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE));
+ WebGraphicsContext3DCommandBufferImpl* share_context =
+ share_provider ? static_cast<WebGraphicsContext3DCommandBufferImpl*>(
+ share_provider->context3d())
+ : nullptr;
WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits limits;
bool lose_context_when_out_of_memory = false;
scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context(
WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext(
- gpu_channel_host.get(),
- attributes,
- lose_context_when_out_of_memory,
- blink::WebStringToGURL(attributes.topDocumentURL),
- limits,
- static_cast<WebGraphicsContext3DCommandBufferImpl*>(share_context)));
-
- // Most likely the GPU process exited and the attempt to reconnect to it
- // failed. Need to try to restore the context again later.
- if (!context || !context->InitializeOnCurrentThread() ||
- gl_info->testFailContext) {
+ gpu_channel_host.get(), attributes, lose_context_when_out_of_memory,
+ blink::WebStringToGURL(attributes.topDocumentURL), limits,
+ share_context));
+ scoped_refptr<ContextProviderCommandBuffer> provider =
+ ContextProviderCommandBuffer::Create(std::move(context),
+ RENDERER_MAINTHREAD_CONTEXT);
+ if (!provider || !provider->BindToCurrentThread()) {
// Collect Graphicsinfo if there is a context failure or it is failed
// purposefully in case of layout tests.
- Collect3DContextInformationOnFailure(share_context, gl_info,
- gpu_channel_host.get());
- return NULL;
+ Collect3DContextInformationOnFailure(gl_info, gpu_channel_host.get());
+ return nullptr;
}
- return context.release();
+ return new WebGraphicsContext3DProviderImpl(std::move(provider));
}
//------------------------------------------------------------------------------
@@ -1043,9 +1027,9 @@ blink::WebGraphicsContext3DProvider*
RendererBlinkPlatformImpl::createSharedOffscreenGraphicsContext3DProvider() {
scoped_refptr<cc_blink::ContextProviderWebContext> provider =
RenderThreadImpl::current()->SharedMainThreadContextProvider();
- if (!provider.get())
- return NULL;
- return new WebGraphicsContext3DProviderImpl(provider);
+ if (!provider)
+ return nullptr;
+ return new WebGraphicsContext3DProviderImpl(std::move(provider));
}
//------------------------------------------------------------------------------
diff --git a/content/renderer/renderer_blink_platform_impl.h b/content/renderer/renderer_blink_platform_impl.h
index 6fc8155..c78d484 100644
--- a/content/renderer/renderer_blink_platform_impl.h
+++ b/content/renderer/renderer_blink_platform_impl.h
@@ -162,14 +162,9 @@ class CONTENT_EXPORT RendererBlinkPlatformImpl : public BlinkPlatformImpl {
void createHTMLVideoElementCapturer(
blink::WebMediaStream* web_media_stream,
blink::WebMediaPlayer* web_media_player) override;
- blink::WebGraphicsContext3D* createOffscreenGraphicsContext3D(
- const blink::WebGraphicsContext3D::Attributes& attributes) override;
- blink::WebGraphicsContext3D* createOffscreenGraphicsContext3D(
+ blink::WebGraphicsContext3DProvider* createOffscreenGraphicsContext3DProvider(
const blink::WebGraphicsContext3D::Attributes& attributes,
- blink::WebGraphicsContext3D* share_context) override;
- blink::WebGraphicsContext3D* createOffscreenGraphicsContext3D(
- const blink::WebGraphicsContext3D::Attributes& attributes,
- blink::WebGraphicsContext3D* share_context,
+ blink::WebGraphicsContext3DProvider* share_provider,
blink::WebGraphicsContext3D::WebGraphicsInfo* gl_info) override;
blink::WebGraphicsContext3DProvider*
createSharedOffscreenGraphicsContext3DProvider() override;
diff --git a/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContext.cpp b/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContext.cpp
index 888b74d..3957cc4 100644
--- a/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContext.cpp
+++ b/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContext.cpp
@@ -26,6 +26,7 @@
#include "modules/webgl/WebGLLoseContext.h"
#include "platform/graphics/gpu/DrawingBuffer.h"
#include "public/platform/Platform.h"
+#include "public/platform/WebGraphicsContext3DProvider.h"
namespace blink {
@@ -37,18 +38,18 @@ PassOwnPtrWillBeRawPtr<CanvasRenderingContext> WebGL2RenderingContext::Factory::
}
WebGLContextAttributes attributes = toWebGLContextAttributes(attrs);
- OwnPtr<WebGraphicsContext3D> context(createWebGraphicsContext3D(canvas, attributes, 2));
- if (!context)
+ OwnPtr<WebGraphicsContext3DProvider> contextProvider(createWebGraphicsContext3DProvider(canvas, attributes, 2));
+ if (!contextProvider)
return nullptr;
- OwnPtr<Extensions3DUtil> extensionsUtil = Extensions3DUtil::create(context.get(), context->getGLES2Interface());
+ OwnPtr<Extensions3DUtil> extensionsUtil = Extensions3DUtil::create(contextProvider->context3d(), contextProvider->contextGL());
if (!extensionsUtil)
return nullptr;
if (extensionsUtil->supportsExtension("GL_EXT_debug_marker")) {
- String contextLabel(String::format("WebGL2RenderingContext-%p", context.get()));
- context->pushGroupMarkerEXT(contextLabel.ascii().data());
+ String contextLabel(String::format("WebGL2RenderingContext-%p", contextProvider.get()));
+ contextProvider->context3d()->pushGroupMarkerEXT(contextLabel.ascii().data());
}
- OwnPtrWillBeRawPtr<WebGL2RenderingContext> renderingContext = adoptPtrWillBeNoop(new WebGL2RenderingContext(canvas, context.release(), attributes));
+ OwnPtrWillBeRawPtr<WebGL2RenderingContext> renderingContext = adoptPtrWillBeNoop(new WebGL2RenderingContext(canvas, contextProvider.release(), attributes));
if (!renderingContext->drawingBuffer()) {
canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcontextcreationerror, false, true, "Could not create a WebGL2 context."));
@@ -66,8 +67,8 @@ void WebGL2RenderingContext::Factory::onError(HTMLCanvasElement* canvas, const S
canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcontextcreationerror, false, true, error));
}
-WebGL2RenderingContext::WebGL2RenderingContext(HTMLCanvasElement* passedCanvas, PassOwnPtr<WebGraphicsContext3D> context, const WebGLContextAttributes& requestedAttributes)
- : WebGL2RenderingContextBase(passedCanvas, context, requestedAttributes)
+WebGL2RenderingContext::WebGL2RenderingContext(HTMLCanvasElement* passedCanvas, PassOwnPtr<WebGraphicsContext3DProvider> contextProvider, const WebGLContextAttributes& requestedAttributes)
+ : WebGL2RenderingContextBase(passedCanvas, contextProvider, requestedAttributes)
{
}
diff --git a/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContext.h b/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContext.h
index 5a27233e..c470846 100644
--- a/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContext.h
+++ b/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContext.h
@@ -38,7 +38,7 @@ public:
DECLARE_VIRTUAL_TRACE();
protected:
- WebGL2RenderingContext(HTMLCanvasElement* passedCanvas, PassOwnPtr<WebGraphicsContext3D>, const WebGLContextAttributes& requestedAttributes);
+ WebGL2RenderingContext(HTMLCanvasElement* passedCanvas, PassOwnPtr<WebGraphicsContext3DProvider>, const WebGLContextAttributes& requestedAttributes);
PersistentWillBeMember<CHROMIUMSubscribeUniform> m_chromiumSubscribeUniform;
PersistentWillBeMember<EXTColorBufferFloat> m_extColorBufferFloat;
diff --git a/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp b/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp
index 2424ab4..4cf1ff9 100644
--- a/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp
+++ b/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp
@@ -26,6 +26,8 @@
#include "modules/webgl/WebGLVertexArrayObject.h"
#include "platform/CheckedInt.h"
#include "platform/NotImplemented.h"
+#include "public/platform/WebGraphicsContext3D.h"
+#include "public/platform/WebGraphicsContext3DProvider.h"
#include "wtf/OwnPtr.h"
#include "wtf/PassOwnPtr.h"
@@ -111,8 +113,8 @@ const GLenum kCompressedTextureFormatsETC2EAC[] = {
GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,
};
-WebGL2RenderingContextBase::WebGL2RenderingContextBase(HTMLCanvasElement* passedCanvas, PassOwnPtr<WebGraphicsContext3D> context, const WebGLContextAttributes& requestedAttributes)
- : WebGLRenderingContextBase(passedCanvas, context, requestedAttributes)
+WebGL2RenderingContextBase::WebGL2RenderingContextBase(HTMLCanvasElement* passedCanvas, PassOwnPtr<WebGraphicsContext3DProvider> contextProvider, const WebGLContextAttributes& requestedAttributes)
+ : WebGLRenderingContextBase(passedCanvas, contextProvider, requestedAttributes)
{
m_supportedInternalFormatsStorage.insert(kSupportedInternalFormatsStorage, kSupportedInternalFormatsStorage + WTF_ARRAY_LENGTH(kSupportedInternalFormatsStorage));
m_supportedInternalFormatsStorage.insert(kCompressedTextureFormatsETC2EAC, kCompressedTextureFormatsETC2EAC + WTF_ARRAY_LENGTH(kCompressedTextureFormatsETC2EAC));
diff --git a/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.h b/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.h
index 736866e..7b9630f 100644
--- a/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.h
+++ b/third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.h
@@ -218,7 +218,7 @@ public:
DECLARE_VIRTUAL_TRACE();
protected:
- WebGL2RenderingContextBase(HTMLCanvasElement*, PassOwnPtr<WebGraphicsContext3D>, const WebGLContextAttributes& requestedAttributes);
+ WebGL2RenderingContextBase(HTMLCanvasElement*, PassOwnPtr<WebGraphicsContext3DProvider>, const WebGLContextAttributes& requestedAttributes);
// Helper function to validate target and the attachment combination for getFramebufferAttachmentParameters.
// Generate GL error and return false if parameters are illegal.
diff --git a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContext.cpp b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContext.cpp
index 52b6984..c1f3dbf 100644
--- a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContext.cpp
+++ b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContext.cpp
@@ -61,24 +61,25 @@
#include "platform/CheckedInt.h"
#include "platform/graphics/gpu/DrawingBuffer.h"
#include "public/platform/Platform.h"
+#include "public/platform/WebGraphicsContext3DProvider.h"
namespace blink {
PassOwnPtrWillBeRawPtr<CanvasRenderingContext> WebGLRenderingContext::Factory::create(HTMLCanvasElement* canvas, const CanvasContextCreationAttributes& attrs, Document&)
{
WebGLContextAttributes attributes = toWebGLContextAttributes(attrs);
- OwnPtr<WebGraphicsContext3D> context(createWebGraphicsContext3D(canvas, attributes, 1));
- if (!context)
+ OwnPtr<WebGraphicsContext3DProvider> contextProvider(createWebGraphicsContext3DProvider(canvas, attributes, 1));
+ if (!contextProvider)
return nullptr;
- OwnPtr<Extensions3DUtil> extensionsUtil = Extensions3DUtil::create(context.get(), context->getGLES2Interface());
+ OwnPtr<Extensions3DUtil> extensionsUtil = Extensions3DUtil::create(contextProvider->context3d(), contextProvider->contextGL());
if (!extensionsUtil)
return nullptr;
if (extensionsUtil->supportsExtension("GL_EXT_debug_marker")) {
- String contextLabel(String::format("WebGLRenderingContext-%p", context.get()));
- context->pushGroupMarkerEXT(contextLabel.ascii().data());
+ String contextLabel(String::format("WebGLRenderingContext-%p", contextProvider.get()));
+ contextProvider->context3d()->pushGroupMarkerEXT(contextLabel.ascii().data());
}
- OwnPtrWillBeRawPtr<WebGLRenderingContext> renderingContext = adoptPtrWillBeNoop(new WebGLRenderingContext(canvas, context.release(), attributes));
+ OwnPtrWillBeRawPtr<WebGLRenderingContext> renderingContext = adoptPtrWillBeNoop(new WebGLRenderingContext(canvas, contextProvider.release(), attributes));
if (!renderingContext->drawingBuffer()) {
canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcontextcreationerror, false, true, "Could not create a WebGL context."));
@@ -96,8 +97,8 @@ void WebGLRenderingContext::Factory::onError(HTMLCanvasElement* canvas, const St
canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcontextcreationerror, false, true, error));
}
-WebGLRenderingContext::WebGLRenderingContext(HTMLCanvasElement* passedCanvas, PassOwnPtr<WebGraphicsContext3D> context, const WebGLContextAttributes& requestedAttributes)
- : WebGLRenderingContextBase(passedCanvas, context, requestedAttributes)
+WebGLRenderingContext::WebGLRenderingContext(HTMLCanvasElement* passedCanvas, PassOwnPtr<WebGraphicsContext3DProvider> contextProvider, const WebGLContextAttributes& requestedAttributes)
+ : WebGLRenderingContextBase(passedCanvas, contextProvider, requestedAttributes)
{
}
diff --git a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContext.h b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContext.h
index 0f823b2..cd41c3b6 100644
--- a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContext.h
+++ b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContext.h
@@ -59,7 +59,7 @@ public:
DECLARE_VIRTUAL_TRACE();
private:
- WebGLRenderingContext(HTMLCanvasElement*, PassOwnPtr<WebGraphicsContext3D>, const WebGLContextAttributes&);
+ WebGLRenderingContext(HTMLCanvasElement*, PassOwnPtr<WebGraphicsContext3DProvider>, const WebGLContextAttributes&);
// Enabled extension objects.
PersistentWillBeMember<ANGLEInstancedArrays> m_angleInstancedArrays;
diff --git a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp
index cc97dc8..7db9951 100644
--- a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp
+++ b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp
@@ -94,6 +94,8 @@
#include "platform/graphics/gpu/AcceleratedImageBufferSurface.h"
#include "platform/graphics/gpu/DrawingBuffer.h"
#include "public/platform/Platform.h"
+#include "public/platform/WebGraphicsContext3D.h"
+#include "public/platform/WebGraphicsContext3DProvider.h"
#include "wtf/ArrayBufferContents.h"
#include "wtf/PassOwnPtr.h"
#include "wtf/text/StringBuilder.h"
@@ -563,7 +565,7 @@ static String extractWebGLContextCreationError(const WebGraphicsContext3D::WebGr
return statusMessage;
}
-PassOwnPtr<WebGraphicsContext3D> WebGLRenderingContextBase::createWebGraphicsContext3D(HTMLCanvasElement* canvas, WebGLContextAttributes attributes, unsigned webGLVersion)
+PassOwnPtr<WebGraphicsContext3DProvider> WebGLRenderingContextBase::createWebGraphicsContext3DProvider(HTMLCanvasElement* canvas, WebGLContextAttributes attributes, unsigned webGLVersion)
{
Document& document = canvas->document();
LocalFrame* frame = document.frame();
@@ -583,18 +585,18 @@ PassOwnPtr<WebGraphicsContext3D> WebGLRenderingContextBase::createWebGraphicsCon
WebGraphicsContext3D::Attributes wgc3dAttributes = toWebGraphicsContext3DAttributes(attributes, document.topDocument().url().getString(), settings, webGLVersion);
WebGraphicsContext3D::WebGraphicsInfo glInfo;
glInfo.testFailContext = shouldFailContextCreationForTesting;
- OwnPtr<WebGraphicsContext3D> context = adoptPtr(Platform::current()->createOffscreenGraphicsContext3D(wgc3dAttributes, 0, &glInfo));
- if (!context || shouldFailContextCreationForTesting) {
+ OwnPtr<WebGraphicsContext3DProvider> contextProvider = adoptPtr(Platform::current()->createOffscreenGraphicsContext3DProvider(wgc3dAttributes, 0, &glInfo));
+ if (!contextProvider || shouldFailContextCreationForTesting) {
shouldFailContextCreationForTesting = false;
canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcontextcreationerror, false, true, extractWebGLContextCreationError(glInfo)));
return nullptr;
}
- if (context->getString(GL_EXTENSIONS).utf8().find("GL_OES_packed_depth_stencil") == std::string::npos) {
+ if (contextProvider->context3d()->getString(GL_EXTENSIONS).utf8().find("GL_OES_packed_depth_stencil") == std::string::npos) {
canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcontextcreationerror, false, true, "OES_packed_depth_stencil support is required."));
return nullptr;
}
- return context.release();
+ return contextProvider.release();
}
void WebGLRenderingContextBase::forceNextWebGLContextCreationToFail()
@@ -839,7 +841,7 @@ bool isSRGBFormat(GLenum internalformat)
} // namespace
-WebGLRenderingContextBase::WebGLRenderingContextBase(HTMLCanvasElement* passedCanvas, PassOwnPtr<WebGraphicsContext3D> context, const WebGLContextAttributes& requestedAttributes)
+WebGLRenderingContextBase::WebGLRenderingContextBase(HTMLCanvasElement* passedCanvas, PassOwnPtr<WebGraphicsContext3DProvider> contextProvider, const WebGLContextAttributes& requestedAttributes)
: CanvasRenderingContext(passedCanvas)
, m_isHidden(false)
, m_contextLostMode(NotLostContext)
@@ -865,16 +867,15 @@ WebGLRenderingContextBase::WebGLRenderingContextBase(HTMLCanvasElement* passedCa
, m_weakPtrFactory(this)
#endif
{
- ASSERT(context);
- gpu::gles2::GLES2Interface* gl = context->getGLES2Interface();
+ ASSERT(contextProvider);
m_contextGroup = WebGLContextGroup::create();
m_contextGroup->addContext(this);
m_maxViewportDims[0] = m_maxViewportDims[1] = 0;
- gl->GetIntegerv(GL_MAX_VIEWPORT_DIMS, m_maxViewportDims);
+ contextProvider->contextGL()->GetIntegerv(GL_MAX_VIEWPORT_DIMS, m_maxViewportDims);
- RefPtr<DrawingBuffer> buffer = createDrawingBuffer(context);
+ RefPtr<DrawingBuffer> buffer = createDrawingBuffer(contextProvider);
if (!buffer) {
m_contextLostMode = SyntheticLostContext;
return;
@@ -896,7 +897,7 @@ WebGLRenderingContextBase::WebGLRenderingContextBase(HTMLCanvasElement* passedCa
ADD_VALUES_TO_SET(m_supportedTypes, kSupportedTypesES2);
}
-PassRefPtr<DrawingBuffer> WebGLRenderingContextBase::createDrawingBuffer(PassOwnPtr<WebGraphicsContext3D> context)
+PassRefPtr<DrawingBuffer> WebGLRenderingContextBase::createDrawingBuffer(PassOwnPtr<WebGraphicsContext3DProvider> contextProvider)
{
WebGraphicsContext3D::Attributes attrs;
attrs.alpha = m_requestedAttributes.alpha();
@@ -905,7 +906,7 @@ PassRefPtr<DrawingBuffer> WebGLRenderingContextBase::createDrawingBuffer(PassOwn
attrs.antialias = m_requestedAttributes.antialias();
attrs.premultipliedAlpha = m_requestedAttributes.premultipliedAlpha();
DrawingBuffer::PreserveDrawingBuffer preserve = m_requestedAttributes.preserveDrawingBuffer() ? DrawingBuffer::Preserve : DrawingBuffer::Discard;
- return DrawingBuffer::create(context, clampedCanvasSize(), preserve, attrs);
+ return DrawingBuffer::create(contextProvider, clampedCanvasSize(), preserve, attrs);
}
void WebGLRenderingContextBase::initializeNewContext()
@@ -5987,11 +5988,12 @@ void WebGLRenderingContextBase::maybeRestoreContext(Timer<WebGLRenderingContextB
}
WebGraphicsContext3D::Attributes attributes = toWebGraphicsContext3DAttributes(m_requestedAttributes, canvas()->document().topDocument().url().getString(), settings, version());
- OwnPtr<WebGraphicsContext3D> context = adoptPtr(Platform::current()->createOffscreenGraphicsContext3D(attributes, 0));
+ blink::WebGraphicsContext3D::WebGraphicsInfo glInfo;
+ OwnPtr<WebGraphicsContext3DProvider> contextProvider = adoptPtr(Platform::current()->createOffscreenGraphicsContext3DProvider(attributes, 0, &glInfo));
RefPtr<DrawingBuffer> buffer;
- if (context) {
+ if (contextProvider) {
// Construct a new drawing buffer with the new WebGraphicsContext3D.
- buffer = createDrawingBuffer(context.release());
+ buffer = createDrawingBuffer(contextProvider.release());
// If DrawingBuffer::create() fails to allocate a fbo, |drawingBuffer| is set to null.
}
if (!buffer) {
diff --git a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.h b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.h
index 457cea5..34afc49 100644
--- a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.h
+++ b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.h
@@ -155,7 +155,7 @@ public:
static unsigned getWebGLVersion(const CanvasRenderingContext*);
- static PassOwnPtr<WebGraphicsContext3D> createWebGraphicsContext3D(HTMLCanvasElement*, WebGLContextAttributes, unsigned webGLVersion);
+ static PassOwnPtr<WebGraphicsContext3DProvider> createWebGraphicsContext3DProvider(HTMLCanvasElement*, WebGLContextAttributes, unsigned webGLVersion);
static void forceNextWebGLContextCreationToFail();
int drawingBufferWidth() const;
@@ -448,8 +448,8 @@ protected:
friend class ScopedTexture2DRestorer;
friend class ScopedFramebufferRestorer;
- WebGLRenderingContextBase(HTMLCanvasElement*, PassOwnPtr<WebGraphicsContext3D>, const WebGLContextAttributes&);
- PassRefPtr<DrawingBuffer> createDrawingBuffer(PassOwnPtr<WebGraphicsContext3D>);
+ WebGLRenderingContextBase(HTMLCanvasElement*, PassOwnPtr<WebGraphicsContext3DProvider>, const WebGLContextAttributes&);
+ PassRefPtr<DrawingBuffer> createDrawingBuffer(PassOwnPtr<WebGraphicsContext3DProvider>);
void setupFlags();
// CanvasRenderingContext implementation.
diff --git a/third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp b/third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp
index ca5aa84..e6864d4 100644
--- a/third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp
+++ b/third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp
@@ -89,19 +89,18 @@ static bool shouldFailDrawingBufferCreationForTesting = false;
} // namespace
-PassRefPtr<DrawingBuffer> DrawingBuffer::create(PassOwnPtr<WebGraphicsContext3D> context, const IntSize& size, PreserveDrawingBuffer preserve, WebGraphicsContext3D::Attributes requestedAttributes)
+PassRefPtr<DrawingBuffer> DrawingBuffer::create(PassOwnPtr<WebGraphicsContext3DProvider> contextProvider, const IntSize& size, PreserveDrawingBuffer preserve, WebGraphicsContext3D::Attributes requestedAttributes)
{
- ASSERT(context);
+ ASSERT(contextProvider);
if (shouldFailDrawingBufferCreationForTesting) {
shouldFailDrawingBufferCreationForTesting = false;
return nullptr;
}
- gpu::gles2::GLES2Interface* gl = context->getGLES2Interface();
- OwnPtr<Extensions3DUtil> extensionsUtil = Extensions3DUtil::create(context.get(), gl);
+ OwnPtr<Extensions3DUtil> extensionsUtil = Extensions3DUtil::create(contextProvider->context3d(), contextProvider->contextGL());
if (!extensionsUtil->isValid()) {
- // This might be the first time we notice that the WebGraphicsContext3D is lost.
+ // This might be the first time we notice that the GL context is lost.
return nullptr;
}
ASSERT(extensionsUtil->supportsExtension("GL_OES_packed_depth_stencil"));
@@ -120,7 +119,7 @@ PassRefPtr<DrawingBuffer> DrawingBuffer::create(PassOwnPtr<WebGraphicsContext3D>
if (discardFramebufferSupported)
extensionsUtil->ensureExtensionEnabled("GL_EXT_discard_framebuffer");
- RefPtr<DrawingBuffer> drawingBuffer = adoptRef(new DrawingBuffer(std::move(context), gl, extensionsUtil.release(), multisampleSupported, discardFramebufferSupported, preserve, requestedAttributes));
+ RefPtr<DrawingBuffer> drawingBuffer = adoptRef(new DrawingBuffer(std::move(contextProvider), extensionsUtil.release(), multisampleSupported, discardFramebufferSupported, preserve, requestedAttributes));
if (!drawingBuffer->initialize(size)) {
drawingBuffer->beginDestruction();
return PassRefPtr<DrawingBuffer>();
@@ -133,15 +132,16 @@ void DrawingBuffer::forceNextDrawingBufferCreationToFail()
shouldFailDrawingBufferCreationForTesting = true;
}
-DrawingBuffer::DrawingBuffer(PassOwnPtr<WebGraphicsContext3D> context, gpu::gles2::GLES2Interface* gl, PassOwnPtr<Extensions3DUtil> extensionsUtil, bool multisampleExtensionSupported, bool discardFramebufferSupported, PreserveDrawingBuffer preserve, WebGraphicsContext3D::Attributes requestedAttributes)
+DrawingBuffer::DrawingBuffer(PassOwnPtr<WebGraphicsContext3DProvider> contextProvider, PassOwnPtr<Extensions3DUtil> extensionsUtil, bool multisampleExtensionSupported, bool discardFramebufferSupported, PreserveDrawingBuffer preserve, WebGraphicsContext3D::Attributes requestedAttributes)
: m_preserveDrawingBuffer(preserve)
, m_scissorEnabled(false)
, m_texture2DBinding(0)
, m_drawFramebufferBinding(0)
, m_readFramebufferBinding(0)
, m_activeTextureUnit(GL_TEXTURE0)
- , m_context(std::move(context))
- , m_gl(gl)
+ , m_contextProvider(std::move(contextProvider))
+ , m_context(m_contextProvider->context3d())
+ , m_gl(m_contextProvider->contextGL())
, m_extensionsUtil(std::move(extensionsUtil))
, m_size(-1, -1)
, m_requestedAttributes(requestedAttributes)
@@ -174,7 +174,7 @@ DrawingBuffer::~DrawingBuffer()
ASSERT(m_destructionInProgress);
ASSERT(m_textureMailboxes.isEmpty());
m_layer.clear();
- m_context.clear();
+ m_contextProvider.clear();
#ifndef NDEBUG
drawingBufferCounter().decrement();
#endif
@@ -202,7 +202,7 @@ void DrawingBuffer::setBufferClearNeeded(bool flag)
WebGraphicsContext3D* DrawingBuffer::context()
{
- return m_context.get();
+ return m_context;
}
gpu::gles2::GLES2Interface* DrawingBuffer::contextGL()
diff --git a/third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.h b/third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.h
index 856619c..1e70fa5 100644
--- a/third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.h
+++ b/third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.h
@@ -63,6 +63,7 @@ class ImageBuffer;
class WebExternalBitmap;
class WebExternalTextureLayer;
class WebGraphicsContext3D;
+class WebGraphicsContext3DProvider;
class WebLayer;
// Manages a rendering target (framebuffer + attachment) for a canvas. Can publish its rendering
@@ -75,7 +76,7 @@ public:
Discard
};
- static PassRefPtr<DrawingBuffer> create(PassOwnPtr<WebGraphicsContext3D>, const IntSize&, PreserveDrawingBuffer, WebGraphicsContext3D::Attributes requestedAttributes);
+ static PassRefPtr<DrawingBuffer> create(PassOwnPtr<WebGraphicsContext3DProvider>, const IntSize&, PreserveDrawingBuffer, WebGraphicsContext3D::Attributes requestedAttributes);
static void forceNextDrawingBufferCreationToFail();
~DrawingBuffer() override;
@@ -179,8 +180,7 @@ public:
protected: // For unittests
DrawingBuffer(
- PassOwnPtr<WebGraphicsContext3D>,
- gpu::gles2::GLES2Interface*,
+ PassOwnPtr<WebGraphicsContext3DProvider>,
PassOwnPtr<Extensions3DUtil>,
bool multisampleExtensionSupported,
bool discardFramebufferSupported,
@@ -304,8 +304,9 @@ private:
Platform3DObject m_readFramebufferBinding;
GLenum m_activeTextureUnit;
- OwnPtr<WebGraphicsContext3D> m_context;
- gpu::gles2::GLES2Interface* m_gl; // Lifetime is tied to the m_context.
+ OwnPtr<WebGraphicsContext3DProvider> m_contextProvider;
+ WebGraphicsContext3D* m_context; // Lifetime is tied to the m_contextProvider.
+ gpu::gles2::GLES2Interface* m_gl; // Lifetime is tied to the m_contextProvider.
OwnPtr<Extensions3DUtil> m_extensionsUtil;
IntSize m_size;
WebGraphicsContext3D::Attributes m_requestedAttributes;
diff --git a/third_party/WebKit/Source/platform/graphics/gpu/DrawingBufferTest.cpp b/third_party/WebKit/Source/platform/graphics/gpu/DrawingBufferTest.cpp
index 44fa3e3..7df1db7 100644
--- a/third_party/WebKit/Source/platform/graphics/gpu/DrawingBufferTest.cpp
+++ b/third_party/WebKit/Source/platform/graphics/gpu/DrawingBufferTest.cpp
@@ -38,6 +38,8 @@
#include "platform/graphics/test/MockWebGraphicsContext3D.h"
#include "public/platform/Platform.h"
#include "public/platform/WebExternalTextureMailbox.h"
+#include "public/platform/WebGraphicsContext3D.h"
+#include "public/platform/WebGraphicsContext3DProvider.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "wtf/RefPtr.h"
@@ -192,8 +194,8 @@ private:
class WebGraphicsContext3DForTests : public MockWebGraphicsContext3D {
public:
- WebGraphicsContext3DForTests(PassOwnPtr<GLES2InterfaceForTests> contextGL)
- : m_contextGL(std::move(contextGL))
+ WebGraphicsContext3DForTests(GLES2InterfaceForTests* contextGL)
+ : m_contextGL(contextGL)
{
}
@@ -215,11 +217,11 @@ public:
gpu::gles2::GLES2Interface* getGLES2Interface() override
{
- return m_contextGL.get();
+ return m_contextGL;
}
private:
- OwnPtr<GLES2InterfaceForTests> m_contextGL;
+ GLES2InterfaceForTests* m_contextGL;
};
static const int initialWidth = 100;
@@ -228,10 +230,10 @@ static const int alternateHeight = 50;
class DrawingBufferForTests : public DrawingBuffer {
public:
- static PassRefPtr<DrawingBufferForTests> create(PassOwnPtr<WebGraphicsContext3D> context, gpu::gles2::GLES2Interface* gl, const IntSize& size, PreserveDrawingBuffer preserve)
+ static PassRefPtr<DrawingBufferForTests> create(PassOwnPtr<WebGraphicsContext3DProvider> contextProvider, const IntSize& size, PreserveDrawingBuffer preserve)
{
- OwnPtr<Extensions3DUtil> extensionsUtil = Extensions3DUtil::create(context.get(), gl);
- RefPtr<DrawingBufferForTests> drawingBuffer = adoptRef(new DrawingBufferForTests(context, gl, extensionsUtil.release(), preserve));
+ OwnPtr<Extensions3DUtil> extensionsUtil = Extensions3DUtil::create(contextProvider->context3d(), contextProvider->contextGL());
+ RefPtr<DrawingBufferForTests> drawingBuffer = adoptRef(new DrawingBufferForTests(contextProvider, extensionsUtil.release(), preserve));
if (!drawingBuffer->initialize(size)) {
drawingBuffer->beginDestruction();
return PassRefPtr<DrawingBufferForTests>();
@@ -239,8 +241,8 @@ public:
return drawingBuffer.release();
}
- DrawingBufferForTests(PassOwnPtr<WebGraphicsContext3D> context, gpu::gles2::GLES2Interface* gl, PassOwnPtr<Extensions3DUtil> extensionsUtil, PreserveDrawingBuffer preserve)
- : DrawingBuffer(context, gl, extensionsUtil, false /* multisampleExtensionSupported */, false /* discardFramebufferSupported */, preserve, WebGraphicsContext3D::Attributes())
+ DrawingBufferForTests(PassOwnPtr<WebGraphicsContext3DProvider> contextProvider, PassOwnPtr<Extensions3DUtil> extensionsUtil, PreserveDrawingBuffer preserve)
+ : DrawingBuffer(contextProvider, extensionsUtil, false /* multisampleExtensionSupported */, false /* discardFramebufferSupported */, preserve, WebGraphicsContext3D::Attributes())
, m_live(0)
{ }
@@ -253,16 +255,34 @@ public:
bool* m_live;
};
+class WebGraphicsContext3DProviderForTests : public WebGraphicsContext3DProvider {
+public:
+ WebGraphicsContext3DProviderForTests(PassOwnPtr<WebGraphicsContext3D> context, PassOwnPtr<gpu::gles2::GLES2Interface> gl)
+ : m_context(std::move(context))
+ , m_gl(std::move(gl))
+ {
+ }
+
+ WebGraphicsContext3D* context3d() override { return m_context.get(); }
+ gpu::gles2::GLES2Interface* contextGL() override { return m_gl.get(); }
+ // Not used by WebGL code.
+ GrContext* grContext() override { return nullptr; }
+
+private:
+ OwnPtr<WebGraphicsContext3D> m_context;
+ OwnPtr<gpu::gles2::GLES2Interface> m_gl;
+};
+
class DrawingBufferTest : public Test {
protected:
void SetUp() override
{
OwnPtr<GLES2InterfaceForTests> gl = adoptPtr(new GLES2InterfaceForTests);
m_gl = gl.get();
- OwnPtr<WebGraphicsContext3DForTests> context = adoptPtr(new WebGraphicsContext3DForTests(gl.release()));
+ OwnPtr<WebGraphicsContext3DForTests> context = adoptPtr(new WebGraphicsContext3DForTests(m_gl));
m_context = context.get();
- m_drawingBuffer = DrawingBufferForTests::create(context.release(), m_gl,
- IntSize(initialWidth, initialHeight), DrawingBuffer::Preserve);
+ OwnPtr<WebGraphicsContext3DProviderForTests> provider = adoptPtr(new WebGraphicsContext3DProviderForTests(context.release(), gl.release()));
+ m_drawingBuffer = DrawingBufferForTests::create(provider.release(), IntSize(initialWidth, initialHeight), DrawingBuffer::Preserve);
}
WebGraphicsContext3DForTests* webContext()
@@ -488,12 +508,13 @@ protected:
{
OwnPtr<GLES2InterfaceForTests> gl = adoptPtr(new GLES2InterfaceForTests);
m_gl = gl.get();
- OwnPtr<WebGraphicsContext3DForTests> context = adoptPtr(new WebGraphicsContext3DForTests(gl.release()));
+ OwnPtr<WebGraphicsContext3DForTests> context = adoptPtr(new WebGraphicsContext3DForTests(m_gl));
m_context = context.get();
+ OwnPtr<WebGraphicsContext3DProviderForTests> provider = adoptPtr(new WebGraphicsContext3DProviderForTests(context.release(), gl.release()));
RuntimeEnabledFeatures::setWebGLImageChromiumEnabled(true);
m_imageId0 = webContext()->nextImageIdToBeCreated();
EXPECT_CALL(*m_gl, BindTexImage2DMock(m_imageId0)).Times(1);
- m_drawingBuffer = DrawingBufferForTests::create(context.release(), m_gl,
+ m_drawingBuffer = DrawingBufferForTests::create(provider.release(),
IntSize(initialWidth, initialHeight), DrawingBuffer::Preserve);
testing::Mock::VerifyAndClearExpectations(webContext());
}
@@ -630,13 +651,17 @@ private:
class DepthStencilTrackingContext : public MockWebGraphicsContext3D {
public:
- DepthStencilTrackingContext() : m_nextRenderBufferId(1) {}
+ DepthStencilTrackingContext(DepthStencilTrackingGLES2Interface* gl)
+ : m_nextRenderBufferId(1)
+ , m_contextGL(gl)
+ {
+ }
~DepthStencilTrackingContext() override {}
int numAllocatedRenderBuffer() const { return m_nextRenderBufferId - 1; }
- WebGLId stencilAttachment() const { return m_contextGL.stencilAttachment(); }
- WebGLId depthAttachment() const { return m_contextGL.depthAttachment(); }
- WebGLId depthStencilAttachment() const { return m_contextGL.depthStencilAttachment(); }
+ WebGLId stencilAttachment() const { return m_contextGL->stencilAttachment(); }
+ WebGLId depthAttachment() const { return m_contextGL->depthAttachment(); }
+ WebGLId depthStencilAttachment() const { return m_contextGL->depthStencilAttachment(); }
WebString getString(WGC3Denum type) override
{
@@ -651,11 +676,11 @@ public:
return ++m_nextRenderBufferId;
}
- gpu::gles2::GLES2Interface* getGLES2Interface() override { return &m_contextGL; }
+ gpu::gles2::GLES2Interface* getGLES2Interface() override { return m_contextGL; }
private:
WebGLId m_nextRenderBufferId;
- DepthStencilTrackingGLES2Interface m_contextGL;
+ DepthStencilTrackingGLES2Interface* m_contextGL;
};
struct DepthStencilTestCase {
@@ -687,14 +712,17 @@ TEST(DrawingBufferDepthStencilTest, packedDepthStencilSupported)
for (size_t i = 0; i < WTF_ARRAY_LENGTH(cases); i++) {
SCOPED_TRACE(cases[i].testCaseName);
- OwnPtr<DepthStencilTrackingContext> context = adoptPtr(new DepthStencilTrackingContext);
+ OwnPtr<DepthStencilTrackingGLES2Interface> gl = adoptPtr(new DepthStencilTrackingGLES2Interface);
+ DepthStencilTrackingGLES2Interface* trackingGL = gl.get();
+ OwnPtr<DepthStencilTrackingContext> context = adoptPtr(new DepthStencilTrackingContext(trackingGL));
DepthStencilTrackingContext* trackingContext = context.get();
+ OwnPtr<WebGraphicsContext3DProviderForTests> provider = adoptPtr(new WebGraphicsContext3DProviderForTests(context.release(), gl.release()));
DrawingBuffer::PreserveDrawingBuffer preserve = DrawingBuffer::Preserve;
WebGraphicsContext3D::Attributes requestedAttributes;
requestedAttributes.stencil = cases[i].requestStencil;
requestedAttributes.depth = cases[i].requestDepth;
- RefPtr<DrawingBuffer> drawingBuffer = DrawingBuffer::create(context.release(), IntSize(10, 10), preserve, requestedAttributes);
+ RefPtr<DrawingBuffer> drawingBuffer = DrawingBuffer::create(provider.release(), IntSize(10, 10), preserve, requestedAttributes);
EXPECT_EQ(cases[i].requestDepth, drawingBuffer->getActualAttributes().depth);
EXPECT_EQ(cases[i].requestStencil, drawingBuffer->getActualAttributes().stencil);
@@ -755,10 +783,11 @@ protected:
OwnPtr<GLES2InterfaceForTests> gl = adoptPtr(new GLES2InterfaceForTests);
gl->setAllowImageChromium(false);
m_gl = gl.get();
- OwnPtr<WebGraphicsContext3DForTests> context = adoptPtr(new WebGraphicsContext3DForTests(gl.release()));
+ OwnPtr<WebGraphicsContext3DForTests> context = adoptPtr(new WebGraphicsContext3DForTests(m_gl));
m_context = context.get();
+ OwnPtr<WebGraphicsContext3DProviderForTests> provider = adoptPtr(new WebGraphicsContext3DProviderForTests(context.release(), gl.release()));
RuntimeEnabledFeatures::setWebGLImageChromiumEnabled(true);
- m_drawingBuffer = DrawingBufferForTests::create(context.release(), m_gl,
+ m_drawingBuffer = DrawingBufferForTests::create(provider.release(),
IntSize(initialWidth, initialHeight), DrawingBuffer::Preserve);
}
diff --git a/third_party/WebKit/public/platform/Platform.h b/third_party/WebKit/public/platform/Platform.h
index 0ecf774..453c4e9 100644
--- a/third_party/WebKit/public/platform/Platform.h
+++ b/third_party/WebKit/public/platform/Platform.h
@@ -451,15 +451,16 @@ public:
// GPU ----------------------------------------------------------------
//
- // May return null if GPU is not supported.
- // Returns newly allocated and initialized offscreen WebGraphicsContext3D instance.
- // Passing an existing context to shareContext will create the new context in the same share group as the passed context.
- virtual WebGraphicsContext3D* createOffscreenGraphicsContext3D(const WebGraphicsContext3D::Attributes&, WebGraphicsContext3D* shareContext) { return nullptr; }
- virtual WebGraphicsContext3D* createOffscreenGraphicsContext3D(const WebGraphicsContext3D::Attributes&, WebGraphicsContext3D* shareContext, WebGraphicsContext3D::WebGraphicsInfo* glInfo) { return nullptr; }
- virtual WebGraphicsContext3D* createOffscreenGraphicsContext3D(const WebGraphicsContext3D::Attributes&) { return nullptr; }
-
- // Returns a newly allocated and initialized offscreen context provider. The provider may return a null
- // graphics context if GPU is not supported.
+ // Returns a newly allocated and initialized offscreen context provider,
+ // backed by an independent context. Returns null if the context cannot be
+ // created or initialized.
+ // Passing an existing provider to shareContext will create the new context
+ // in the same share group as the one passed.
+ virtual WebGraphicsContext3DProvider* createOffscreenGraphicsContext3DProvider(const WebGraphicsContext3D::Attributes&, WebGraphicsContext3DProvider* shareContext, WebGraphicsContext3D::WebGraphicsInfo* glInfo) { return nullptr; }
+
+ // Returns a newly allocated and initialized offscreen context provider,
+ // backed by the process-wide shared main thread context. Returns null if
+ // the context cannot be created or initialized.
virtual WebGraphicsContext3DProvider* createSharedOffscreenGraphicsContext3DProvider() { return nullptr; }
// Returns true if the platform is capable of producing an offscreen context suitable for accelerating 2d canvas.