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

Unified Diff: third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp

Issue 2455983005: Refactor AcceleratedStaticBitmapImage (Closed)
Patch Set: Keep a unique_ptr<WebGraphicsContext3DProvider>, otherwise crashes Created 4 years, 1 month 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/gpu/DrawingBuffer.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/gpu/DrawingBuffer.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp b/third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp
index 15c0d7d160ec6683b95ff31e533008b179c5e04a..ea452ae747adb9a8e0457ed6de85f77db5de6c32 100644
--- a/third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp
+++ b/third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp
@@ -38,13 +38,13 @@
#include "platform/graphics/AcceleratedStaticBitmapImage.h"
#include "platform/graphics/GraphicsLayer.h"
#include "platform/graphics/ImageBuffer.h"
+#include "platform/graphics/WebGraphicsContext3DProviderWrapper.h"
#include "platform/graphics/gpu/Extensions3DUtil.h"
#include "platform/tracing/TraceEvent.h"
#include "public/platform/Platform.h"
#include "public/platform/WebCompositorSupport.h"
#include "public/platform/WebExternalBitmap.h"
#include "public/platform/WebExternalTextureLayer.h"
-#include "public/platform/WebGraphicsContext3DProvider.h"
#include "skia/ext/texture_handle.h"
#include "third_party/skia/include/gpu/GrContext.h"
#include "third_party/skia/include/gpu/gl/GrGLTypes.h"
@@ -142,13 +142,14 @@ DrawingBuffer::DrawingBuffer(
: m_client(client),
m_preserveDrawingBuffer(preserve),
m_webGLVersion(webGLVersion),
- m_contextProvider(std::move(contextProvider)),
- m_gl(m_contextProvider->contextGL()),
+ m_contextProvider(wrapUnique(
+ new WebGraphicsContext3DProviderWrapper(std::move(contextProvider)))),
+ m_gl(this->contextProvider()->contextGL()),
m_extensionsUtil(std::move(extensionsUtil)),
m_discardFramebufferSupported(discardFramebufferSupported),
m_wantAlphaChannel(wantAlphaChannel),
m_premultipliedAlpha(premultipliedAlpha),
- m_softwareRendering(m_contextProvider->isSoftwareRendering()),
+ m_softwareRendering(this->contextProvider()->isSoftwareRendering()),
m_wantDepth(wantDepth),
m_wantStencil(wantStencil),
m_chromiumImageUsage(chromiumImageUsage) {
@@ -185,7 +186,7 @@ gpu::gles2::GLES2Interface* DrawingBuffer::contextGL() {
}
WebGraphicsContext3DProvider* DrawingBuffer::contextProvider() {
- return m_contextProvider.get();
+ return m_contextProvider->contextProvider();
}
void DrawingBuffer::setIsHidden(bool hidden) {
@@ -442,7 +443,7 @@ PassRefPtr<StaticBitmapImage> DrawingBuffer::transferToStaticBitmapImage() {
// This can be null if the context is lost before the first call to
// grContext().
- GrContext* grContext = m_contextProvider->grContext();
+ GrContext* grContext = contextProvider()->grContext();
cc::TextureMailbox textureMailbox;
std::unique_ptr<cc::SingleReleaseCallback> releaseCallback;
@@ -481,20 +482,6 @@ PassRefPtr<StaticBitmapImage> DrawingBuffer::transferToStaticBitmapImage() {
// reference to the backing via our |textureId|.
releaseCallback->Run(gpu::SyncToken(), true /* lostResource */);
- // Store that texture id as the backing for an SkImage.
- GrGLTextureInfo textureInfo;
- textureInfo.fTarget = GL_TEXTURE_2D;
- textureInfo.fID = textureId;
- GrBackendTextureDesc backendTexture;
- backendTexture.fOrigin = kBottomLeft_GrSurfaceOrigin;
- backendTexture.fWidth = m_size.width();
- backendTexture.fHeight = m_size.height();
- backendTexture.fConfig = kSkia8888_GrPixelConfig;
- backendTexture.fTextureHandle =
- skia::GrGLTextureInfoToGrBackendObject(textureInfo);
- sk_sp<SkImage> skImage =
- SkImage::MakeFromAdoptedTexture(grContext, backendTexture);
-
// We reuse the same mailbox name from above since our texture id was consumed
// from it.
const auto& skImageMailbox = textureMailbox.mailbox();
@@ -509,7 +496,8 @@ PassRefPtr<StaticBitmapImage> DrawingBuffer::transferToStaticBitmapImage() {
// ImageBitmapRenderingContext's transferFromImageBitmap, and try to use them
// in DrawingBuffer.
return AcceleratedStaticBitmapImage::createFromWebGLContextImage(
- std::move(skImage), skImageMailbox, skImageSyncToken);
+ skImageMailbox, skImageSyncToken, textureId,
+ m_contextProvider->createWeakPtr(), m_size);
}
DrawingBuffer::ColorBufferParameters
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698