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

Unified Diff: third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp

Issue 1962413002: Implement transferToImageBitmap() in WebGLRenderingContext (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: works Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp
diff --git a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp
index fa3c89ad6a4fc331300398ce239e901a47cd533d..e042e922fc2b0b661c3607996983b004ca1edde7 100644
--- a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp
+++ b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp
@@ -92,6 +92,7 @@
#include "platform/graphics/gpu/AcceleratedImageBufferSurface.h"
#include "public/platform/Platform.h"
#include "public/platform/functional/WebFunction.h"
+#include "skia/ext/texture_handle.h"
#include "wtf/Functional.h"
#include "wtf/PassOwnPtr.h"
#include "wtf/text/StringBuilder.h"
@@ -634,6 +635,29 @@ void WebGLRenderingContextBase::forceNextWebGLContextCreationToFail()
shouldFailContextCreationForTesting = true;
}
+ImageBitmap* WebGLRenderingContextBase::transferToImageBitmapBase()
+{
+ if (!drawingBuffer())
+ return nullptr;
+ GrContext* grContext = drawingBuffer()->contextProvider()->grContext();
+ if (!grContext)
+ return nullptr;
+ SkAlphaType alphaType = (m_requestedAttributes.premultipliedAlpha()) ? kPremul_SkAlphaType : kOpaque_SkAlphaType;
+ SkImageInfo info = SkImageInfo::MakeN32(drawingBufferWidth(), drawingBufferHeight(), alphaType);
+ SkSurfaceProps disableLCDProps(0, kUnknown_SkPixelGeometry);
+ sk_sp<SkSurface> surface = SkSurface::MakeRenderTarget(grContext, SkBudgeted::kYes, info, 0, (m_requestedAttributes.premultipliedAlpha()) ? &disableLCDProps : nullptr);
+ gpu::gles2::GLES2Interface* gl = drawingBuffer()->contextProvider()->contextGL();
+ GLuint textureId = skia::GrBackendObjectToGrGLTextureInfo(surface->getTextureHandle(SkSurface::kDiscardWrite_TextureHandleAccess))->fID;
+ if (!textureId)
+ return nullptr;
+ gl->Flush();
+ if (!(drawingBuffer()->copyToPlatformTexture(gl, textureId, GL_RGBA, GL_UNSIGNED_BYTE, 0, true, false, BackBuffer)))
xidachen 2016/05/17 17:02:00 It turns out that we can consume the texture in he
Ken Russell (switch to Gerrit) 2016/05/18 01:20:41 DrawingBuffer::copyToPlatformTexture, as the name
xidachen 2016/05/18 15:13:36 Sorry for the delay. I should have used mailbox fr
+ return nullptr;
+ RefPtr<StaticBitmapImage> image = StaticBitmapImage::create(fromSkSp(surface->makeImageSnapshot()));
+ ImageBitmap* imageBitmap = ImageBitmap::create(image.release());
+ return imageBitmap;
+}
+
namespace {
// ES2 enums
@@ -1165,6 +1189,9 @@ void WebGLRenderingContextBase::markContextChanged(ContentChangeType changeType)
drawingBuffer()->markContentsChanged();
+ if (!canvas())
+ return;
+
LayoutBox* layoutBox = canvas()->layoutBox();
if (layoutBox && layoutBox->hasAcceleratedCompositing()) {
m_markedCanvasDirty = true;
« no previous file with comments | « third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698