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

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

Issue 2300633004: Allow canvases to be GPU-accelerated in Workers (Closed)
Patch Set: Created 4 years, 4 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: third_party/WebKit/Source/platform/graphics/gpu/AcceleratedImageBufferSurface.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/gpu/AcceleratedImageBufferSurface.cpp b/third_party/WebKit/Source/platform/graphics/gpu/AcceleratedImageBufferSurface.cpp
index 8339235e3de007d2c1d649a03a1d214230a51bb1..c3d9a3ba71e636583338d672d2c947ab52162d2b 100644
--- a/third_party/WebKit/Source/platform/graphics/gpu/AcceleratedImageBufferSurface.cpp
+++ b/third_party/WebKit/Source/platform/graphics/gpu/AcceleratedImageBufferSurface.cpp
@@ -30,9 +30,8 @@
#include "platform/graphics/gpu/AcceleratedImageBufferSurface.h"
+#include "platform/graphics/gpu/SharedGpuContext.h"
#include "platform/graphics/skia/SkiaUtils.h"
-#include "public/platform/Platform.h"
-#include "public/platform/WebGraphicsContext3DProvider.h"
#include "skia/ext/texture_handle.h"
#include "third_party/skia/include/gpu/GrContext.h"
#include "wtf/PtrUtil.h"
@@ -43,12 +42,11 @@ namespace blink {
AcceleratedImageBufferSurface::AcceleratedImageBufferSurface(const IntSize& size, OpacityMode opacityMode, sk_sp<SkColorSpace> colorSpace)
: ImageBufferSurface(size, opacityMode, colorSpace)
{
- m_contextProvider = wrapUnique(Platform::current()->createSharedOffscreenGraphicsContext3DProvider());
- if (!m_contextProvider)
- return;
- GrContext* grContext = m_contextProvider->grContext();
- if (!grContext)
+ if (!SharedGpuContext::isValid())
return;
+ GrContext* grContext = SharedGpuContext::gr();
+ m_contextId = SharedGpuContext::contextId();
+ CHECK(grContext);
SkAlphaType alphaType = (Opaque == opacityMode) ? kOpaque_SkAlphaType : kPremul_SkAlphaType;
SkImageInfo info = SkImageInfo::MakeN32(size.width(), size.height(), alphaType);
@@ -60,6 +58,11 @@ AcceleratedImageBufferSurface::AcceleratedImageBufferSurface(const IntSize& size
clear();
}
+bool AcceleratedImageBufferSurface::isValid() const
+{
+ return m_surface && SharedGpuContext::isValid() && m_contextId == SharedGpuContext::contextId();
+}
+
PassRefPtr<SkImage> AcceleratedImageBufferSurface::newImageSnapshot(AccelerationHint, SnapshotReason)
{
return fromSkSp(m_surface->makeImageSnapshot());

Powered by Google App Engine
This is Rietveld 408576698