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

Unified Diff: Source/platform/graphics/ImageBuffer.cpp

Issue 1195513002: Use SkImage snapshots for ImageBufferSurface texture access (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: review comments Created 5 years, 6 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
Index: Source/platform/graphics/ImageBuffer.cpp
diff --git a/Source/platform/graphics/ImageBuffer.cpp b/Source/platform/graphics/ImageBuffer.cpp
index b85322effef6821e99dd8cb9d4f5b67e8b1d7bb4..fc8b628f5296cccf1cf002047157c4fc571542a4 100644
--- a/Source/platform/graphics/ImageBuffer.cpp
+++ b/Source/platform/graphics/ImageBuffer.cpp
@@ -172,12 +172,22 @@ WebLayer* ImageBuffer::platformLayer() const
bool ImageBuffer::copyToPlatformTexture(WebGraphicsContext3D* context, Platform3DObject texture, GLenum internalFormat, GLenum destType, GLint level, bool premultiplyAlpha, bool flipY)
{
- if (!m_surface->isAccelerated() || !getBackingTexture() || !isSurfaceValid())
+ if (!m_surface->isAccelerated() || !isSurfaceValid())
return false;
if (!Extensions3DUtil::canUseCopyTextureCHROMIUM(GL_TEXTURE_2D, internalFormat, destType, level))
return false;
+ RefPtr<const SkImage> textureImage = m_surface->getBackingTextureImage();
+ if (!textureImage)
+ return false;
+
+ ASSERT(textureImage->isTextureBacked());
+ // Get the texture ID, flushing pending operations if needed.
+ Platform3DObject textureId = textureImage->getTextureHandle(true);
+ if (!textureId)
+ return false;
+
OwnPtr<WebGraphicsContext3DProvider> provider = adoptPtr(Platform::current()->createSharedOffscreenGraphicsContext3DProvider());
if (!provider)
return false;
@@ -189,7 +199,7 @@ 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(getBackingTexture(), GL_TEXTURE_2D, mailbox->name);
+ sharedContext->produceTextureDirectCHROMIUM(textureId, GL_TEXTURE_2D, mailbox->name);
sharedContext->flush();
mailbox->syncPoint = sharedContext->insertSyncPoint();
@@ -218,16 +228,6 @@ bool ImageBuffer::copyToPlatformTexture(WebGraphicsContext3D* context, Platform3
return true;
}
-Platform3DObject ImageBuffer::getBackingTexture()
-{
- return m_surface->getBackingTexture();
-}
-
-void ImageBuffer::didModifyBackingTexture()
-{
- m_surface->didModifyBackingTexture();
-}
-
bool ImageBuffer::copyRenderingResultsFromDrawingBuffer(DrawingBuffer* drawingBuffer, SourceDrawingBuffer sourceBuffer)
{
if (!drawingBuffer)
@@ -236,12 +236,17 @@ bool ImageBuffer::copyRenderingResultsFromDrawingBuffer(DrawingBuffer* drawingBu
if (!provider)
return false;
WebGraphicsContext3D* context3D = provider->context3d();
- Platform3DObject tex = m_surface->getBackingTexture();
- if (!context3D || !tex)
+ RefPtr<SkImage> textureImage = m_surface->getBackingTextureImage();
+ if (!context3D || !textureImage)
+ return false;
+ ASSERT(textureImage->isTextureBacked());
+ // Get the texture ID, flushing pending operations if needed.
+ Platform3DObject textureId = textureImage->getTextureHandle(true);
+ if (!textureId)
return false;
m_surface->invalidateCachedBitmap();
- bool result = drawingBuffer->copyToPlatformTexture(context3D, tex, GL_RGBA,
+ bool result = drawingBuffer->copyToPlatformTexture(context3D, textureId, GL_RGBA,
GL_UNSIGNED_BYTE, 0, true, false, sourceBuffer);
if (result) {

Powered by Google App Engine
This is Rietveld 408576698