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

Unified Diff: third_party/WebKit/Source/platform/graphics/StaticBitmapImage.cpp

Issue 1962413002: Implement transferToImageBitmap() in WebGLRenderingContext (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add new test case, cache SkIMage 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/platform/graphics/StaticBitmapImage.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/platform/graphics/StaticBitmapImage.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/StaticBitmapImage.cpp b/third_party/WebKit/Source/platform/graphics/StaticBitmapImage.cpp
index 0d596995fbf8df72a8cd4bc9efdb6ec61d948881..ac88b3d3d8c066136131b2f7aa9719f45976c96e 100644
--- a/third_party/WebKit/Source/platform/graphics/StaticBitmapImage.cpp
+++ b/third_party/WebKit/Source/platform/graphics/StaticBitmapImage.cpp
@@ -4,8 +4,12 @@
#include "platform/graphics/StaticBitmapImage.h"
+#include "gpu/command_buffer/client/gles2_interface.h"
#include "platform/graphics/GraphicsContext.h"
#include "platform/graphics/ImageObserver.h"
+#include "public/platform/Platform.h"
+#include "public/platform/WebGraphicsContext3DProvider.h"
+#include "skia/ext/texture_handle.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkImage.h"
#include "third_party/skia/include/core/SkPaint.h"
@@ -20,11 +24,20 @@ PassRefPtr<StaticBitmapImage> StaticBitmapImage::create(PassRefPtr<SkImage> imag
return adoptRef(new StaticBitmapImage(image));
}
+PassRefPtr<StaticBitmapImage> StaticBitmapImage::create(WebExternalTextureMailbox& mailbox)
+{
+ return adoptRef(new StaticBitmapImage(mailbox));
+}
+
StaticBitmapImage::StaticBitmapImage(PassRefPtr<SkImage> image) : m_image(image)
{
ASSERT(m_image);
}
+StaticBitmapImage::StaticBitmapImage(WebExternalTextureMailbox& mailbox) : m_mailbox(mailbox)
+{
+}
+
StaticBitmapImage::~StaticBitmapImage() { }
IntSize StaticBitmapImage::size() const
@@ -55,6 +68,34 @@ void StaticBitmapImage::draw(SkCanvas* canvas, const SkPaint& paint, const Float
PassRefPtr<SkImage> StaticBitmapImage::imageForCurrentFrame()
{
+ if (m_image)
+ return m_image;
+ DCHECK(isMainThread());
+ // In the place when we consume an ImageBitmap that is gpu texture backed,
+ // create a new SkImage from that texture.
+ // TODO(xidachen): make this work on a worker thread.
+ OwnPtr<WebGraphicsContext3DProvider> provider = adoptPtr(Platform::current()->createSharedOffscreenGraphicsContext3DProvider());
+ if (!provider)
+ return nullptr;
+ GrContext* grContext = provider->grContext();
+ if (!grContext)
+ return nullptr;
+ gpu::gles2::GLES2Interface* gl = provider->contextGL();
+ if (!gl)
+ return nullptr;
+ gl->WaitSyncTokenCHROMIUM(m_mailbox.syncToken);
+ GLuint textureId = gl->CreateAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, m_mailbox.name);
+ GrGLTextureInfo textureInfo;
+ textureInfo.fTarget = GL_TEXTURE_2D;
+ textureInfo.fID = textureId;
+ GrBackendTextureDesc backendTexture;
+ backendTexture.fOrigin = kBottomLeft_GrSurfaceOrigin;
+ backendTexture.fWidth = m_mailbox.textureSize.width;
+ backendTexture.fHeight = m_mailbox.textureSize.height;
+ backendTexture.fConfig = kSkia8888_GrPixelConfig;
+ backendTexture.fTextureHandle = skia::GrGLTextureInfoToGrBackendObject(textureInfo);
+ sk_sp<SkImage> skImage = SkImage::MakeFromAdoptedTexture(grContext, backendTexture);
+ m_image = fromSkSp(skImage);
xidachen 2016/05/19 20:43:51 Here we cache this SkImage, so the next time when
Ken Russell (switch to Gerrit) 2016/05/19 21:38:42 I don't think so. The same ImageBitmap might be co
return m_image;
}
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/StaticBitmapImage.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698