Index: third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp |
diff --git a/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp b/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp |
index b647e3d782519c592943685ea996cf57947fc24e..966cd8efeeadfe80af9cb47de2aab7eee5ea69e0 100644 |
--- a/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp |
+++ b/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp |
@@ -38,6 +38,8 @@ |
#include "platform/graphics/GraphicsLayer.h" |
#include "platform/graphics/ImageBuffer.h" |
#include "platform/graphics/gpu/SharedContextRateLimiter.h" |
+#include "platform/graphics/paint/PaintCanvas.h" |
+#include "platform/graphics/paint/PaintSurface.h" |
#include "platform/instrumentation/tracing/TraceEvent.h" |
#include "public/platform/Platform.h" |
#include "public/platform/WebCompositorSupport.h" |
@@ -46,8 +48,6 @@ |
#include "public/platform/WebTraceLocation.h" |
#include "skia/ext/texture_handle.h" |
#include "third_party/skia/include/core/SkData.h" |
-#include "third_party/skia/include/core/SkPictureRecorder.h" |
-#include "third_party/skia/include/core/SkSurface.h" |
#include "third_party/skia/include/gpu/GrContext.h" |
#include "third_party/skia/include/gpu/gl/GrGLTypes.h" |
#include "wtf/PtrUtil.h" |
@@ -81,13 +81,13 @@ struct Canvas2DLayerBridge::ImageInfo : public RefCounted<ImageInfo> { |
}; |
#endif // USE_IOSURFACE_FOR_2D_CANVAS |
-static sk_sp<SkSurface> createSkSurface(GrContext* gr, |
- const IntSize& size, |
- int msaaSampleCount, |
- OpacityMode opacityMode, |
- sk_sp<SkColorSpace> colorSpace, |
- SkColorType colorType, |
- bool* surfaceIsAccelerated) { |
+static sk_sp<PaintSurface> createSkSurface(GrContext* gr, |
+ const IntSize& size, |
+ int msaaSampleCount, |
+ OpacityMode opacityMode, |
+ sk_sp<SkColorSpace> colorSpace, |
+ SkColorType colorType, |
+ bool* surfaceIsAccelerated) { |
if (gr) |
gr->resetContext(); |
@@ -96,18 +96,18 @@ static sk_sp<SkSurface> createSkSurface(GrContext* gr, |
SkImageInfo info = SkImageInfo::Make(size.width(), size.height(), colorType, |
alphaType, colorSpace); |
SkSurfaceProps disableLCDProps(0, kUnknown_SkPixelGeometry); |
- sk_sp<SkSurface> surface; |
+ sk_sp<PaintSurface> surface; |
if (gr) { |
*surfaceIsAccelerated = true; |
- surface = SkSurface::MakeRenderTarget( |
+ surface = PaintSurface::MakeRenderTarget( |
gr, SkBudgeted::kNo, info, msaaSampleCount, |
Opaque == opacityMode ? 0 : &disableLCDProps); |
} |
if (!surface) { |
*surfaceIsAccelerated = false; |
- surface = SkSurface::MakeRaster( |
+ surface = PaintSurface::MakeRaster( |
info, Opaque == opacityMode ? 0 : &disableLCDProps); |
} |
@@ -170,8 +170,8 @@ Canvas2DLayerBridge::~Canvas2DLayerBridge() { |
void Canvas2DLayerBridge::startRecording() { |
DCHECK(m_isDeferralEnabled); |
- m_recorder = WTF::wrapUnique(new SkPictureRecorder); |
- SkCanvas* canvas = |
+ m_recorder = WTF::wrapUnique(new PaintRecorder); |
+ PaintCanvas* canvas = |
m_recorder->beginRecording(m_size.width(), m_size.height(), nullptr); |
// Always save an initial frame, to support resetting the top level matrix |
// and clip. |
@@ -497,8 +497,8 @@ void Canvas2DLayerBridge::hibernate() { |
} |
TRACE_EVENT0("cc", "Canvas2DLayerBridge::hibernate"); |
- sk_sp<SkSurface> tempHibernationSurface = |
- SkSurface::MakeRasterN32Premul(m_size.width(), m_size.height()); |
+ sk_sp<PaintSurface> tempHibernationSurface = |
+ PaintSurface::MakeRasterN32Premul(m_size.width(), m_size.height()); |
if (!tempHibernationSurface) { |
m_logger->reportHibernationEvent(HibernationAbortedDueToAllocationFailure); |
return; |
@@ -512,7 +512,7 @@ void Canvas2DLayerBridge::hibernate() { |
// a surface, and we have an early exit at the top of this function for when |
// 'this' does not already have a surface. |
DCHECK(!m_haveRecordedDrawCommands); |
- SkPaint copyPaint; |
+ PaintFlags copyPaint; |
copyPaint.setBlendMode(SkBlendMode::kSrc); |
m_surface->draw(tempHibernationSurface->getCanvas(), 0, 0, |
©Paint); // GPU readback |
@@ -536,7 +536,7 @@ void Canvas2DLayerBridge::reportSurfaceCreationFailure() { |
} |
} |
-SkSurface* Canvas2DLayerBridge::getOrCreateSurface(AccelerationHint hint) { |
+PaintSurface* Canvas2DLayerBridge::getOrCreateSurface(AccelerationHint hint) { |
if (m_surface) |
return m_surface.get(); |
@@ -587,7 +587,7 @@ SkSurface* Canvas2DLayerBridge::getOrCreateSurface(AccelerationHint hint) { |
m_logger->reportHibernationEvent(HibernationEndedWithFallbackToSW); |
} |
- SkPaint copyPaint; |
+ PaintFlags copyPaint; |
copyPaint.setBlendMode(SkBlendMode::kSrc); |
m_surface->getCanvas()->drawImage(m_hibernationImage.get(), 0, 0, |
©Paint); |
@@ -603,9 +603,9 @@ SkSurface* Canvas2DLayerBridge::getOrCreateSurface(AccelerationHint hint) { |
return m_surface.get(); |
} |
-SkCanvas* Canvas2DLayerBridge::canvas() { |
+PaintCanvas* Canvas2DLayerBridge::canvas() { |
if (!m_isDeferralEnabled) { |
- SkSurface* s = getOrCreateSurface(); |
+ PaintSurface* s = getOrCreateSurface(); |
return s ? s->getCanvas() : nullptr; |
} |
return m_recorder->getRecordingCanvas(); |
@@ -638,7 +638,7 @@ void Canvas2DLayerBridge::disableDeferral(DisableDeferralReason reason) { |
m_isDeferralEnabled = false; |
m_recorder.reset(); |
// install the current matrix/clip stack onto the immediate canvas |
- SkSurface* surface = getOrCreateSurface(); |
+ PaintSurface* surface = getOrCreateSurface(); |
if (m_imageBuffer && surface) |
m_imageBuffer->resetCanvas(surface->getCanvas()); |
} |
@@ -714,14 +714,14 @@ void Canvas2DLayerBridge::setIsHidden(bool hidden) { |
} |
if (!isHidden() && m_softwareRenderingWhileHidden) { |
flushRecordingOnly(); |
- SkPaint copyPaint; |
+ PaintFlags copyPaint; |
copyPaint.setBlendMode(SkBlendMode::kSrc); |
- sk_sp<SkSurface> oldSurface = std::move(m_surface); |
+ sk_sp<PaintSurface> oldSurface = std::move(m_surface); |
m_surface.reset(); |
m_softwareRenderingWhileHidden = false; |
- SkSurface* newSurface = |
+ PaintSurface* newSurface = |
getOrCreateSurface(PreferAccelerationAfterVisibilityChange); |
if (newSurface) { |
if (oldSurface) |
@@ -860,7 +860,7 @@ bool Canvas2DLayerBridge::restoreSurface() { |
if (sharedGL && sharedGL->GetGraphicsResetStatusKHR() == GL_NO_ERROR) { |
GrContext* grCtx = m_contextProvider->grContext(); |
bool surfaceIsAccelerated; |
- sk_sp<SkSurface> surface( |
+ sk_sp<PaintSurface> surface( |
createSkSurface(grCtx, m_size, m_msaaSampleCount, m_opacityMode, |
m_colorSpace, m_colorType, &surfaceIsAccelerated)); |