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

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

Issue 2523673004: [NOT FOR COMMIT] Fully replace SkCanvas uses.
Patch Set: Support Android build. Created 4 years 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/Canvas2DLayerBridge.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp b/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp
index 6a5716a24d348fc9837ebfed31807d3dadfad0b2..df45de450a463772a98003433cf9f1bfa42b5b01 100644
--- a/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp
+++ b/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp
@@ -44,9 +44,11 @@
#include "public/platform/WebGraphicsContext3DProvider.h"
#include "public/platform/WebScheduler.h"
#include "public/platform/WebTraceLocation.h"
+#include "skia/ext/cdl_canvas.h"
+#include "skia/ext/cdl_surface.h"
#include "skia/ext/texture_handle.h"
#include "third_party/skia/include/core/SkData.h"
-#include "third_party/skia/include/core/SkPictureRecorder.h"
+#include "skia/ext/cdl_picture_recorder.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"
@@ -81,13 +83,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<CdlSurface> createSkSurface(GrContext* gr,
+ const IntSize& size,
+ int msaaSampleCount,
+ OpacityMode opacityMode,
+ sk_sp<SkColorSpace> colorSpace,
+ SkColorType colorType,
+ bool* surfaceIsAccelerated) {
if (gr)
gr->resetContext();
@@ -96,18 +98,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<CdlSurface> surface;
if (gr) {
*surfaceIsAccelerated = true;
- surface = SkSurface::MakeRenderTarget(
+ surface = CdlSurface::MakeRenderTarget(
gr, SkBudgeted::kNo, info, msaaSampleCount,
Opaque == opacityMode ? 0 : &disableLCDProps);
}
if (!surface) {
*surfaceIsAccelerated = false;
- surface = SkSurface::MakeRaster(
+ surface = CdlSurface::MakeRaster(
info, Opaque == opacityMode ? 0 : &disableLCDProps);
}
@@ -170,8 +172,8 @@ Canvas2DLayerBridge::~Canvas2DLayerBridge() {
void Canvas2DLayerBridge::startRecording() {
DCHECK(m_isDeferralEnabled);
- m_recorder = wrapUnique(new SkPictureRecorder);
- SkCanvas* canvas =
+ m_recorder = wrapUnique(new CdlPictureRecorder);
+ CdlCanvas* 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.
@@ -500,8 +502,8 @@ void Canvas2DLayerBridge::hibernate() {
}
TRACE_EVENT0("cc", "Canvas2DLayerBridge::hibernate");
- sk_sp<SkSurface> tempHibernationSurface =
- SkSurface::MakeRasterN32Premul(m_size.width(), m_size.height());
+ sk_sp<CdlSurface> tempHibernationSurface =
+ CdlSurface::MakeRasterN32Premul(m_size.width(), m_size.height());
if (!tempHibernationSurface) {
m_logger->reportHibernationEvent(HibernationAbortedDueToAllocationFailure);
return;
@@ -515,7 +517,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;
+ CdlPaint copyPaint;
copyPaint.setBlendMode(SkBlendMode::kSrc);
m_surface->draw(tempHibernationSurface->getCanvas(), 0, 0,
&copyPaint); // GPU readback
@@ -539,7 +541,7 @@ void Canvas2DLayerBridge::reportSurfaceCreationFailure() {
}
}
-SkSurface* Canvas2DLayerBridge::getOrCreateSurface(AccelerationHint hint) {
+CdlSurface* Canvas2DLayerBridge::getOrCreateSurface(AccelerationHint hint) {
if (m_surface)
return m_surface.get();
@@ -590,7 +592,7 @@ SkSurface* Canvas2DLayerBridge::getOrCreateSurface(AccelerationHint hint) {
m_logger->reportHibernationEvent(HibernationEndedWithFallbackToSW);
}
- SkPaint copyPaint;
+ CdlPaint copyPaint;
copyPaint.setBlendMode(SkBlendMode::kSrc);
m_surface->getCanvas()->drawImage(m_hibernationImage.get(), 0, 0,
&copyPaint);
@@ -606,9 +608,9 @@ SkSurface* Canvas2DLayerBridge::getOrCreateSurface(AccelerationHint hint) {
return m_surface.get();
}
-SkCanvas* Canvas2DLayerBridge::canvas() {
+CdlCanvas* Canvas2DLayerBridge::canvas() {
if (!m_isDeferralEnabled) {
- SkSurface* s = getOrCreateSurface();
+ CdlSurface* s = getOrCreateSurface();
return s ? s->getCanvas() : nullptr;
}
return m_recorder->getRecordingCanvas();
@@ -641,7 +643,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();
+ CdlSurface* surface = getOrCreateSurface();
if (m_imageBuffer && surface)
m_imageBuffer->resetCanvas(surface->getCanvas());
}
@@ -717,14 +719,14 @@ void Canvas2DLayerBridge::setIsHidden(bool hidden) {
}
if (!isHidden() && m_softwareRenderingWhileHidden) {
flushRecordingOnly();
- SkPaint copyPaint;
+ CdlPaint copyPaint;
copyPaint.setBlendMode(SkBlendMode::kSrc);
- sk_sp<SkSurface> oldSurface = std::move(m_surface);
+ sk_sp<CdlSurface> oldSurface = std::move(m_surface);
m_surface.reset();
m_softwareRenderingWhileHidden = false;
- SkSurface* newSurface =
+ CdlSurface* newSurface =
getOrCreateSurface(PreferAccelerationAfterVisibilityChange);
if (newSurface) {
if (oldSurface)
@@ -858,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<CdlSurface> surface(
createSkSurface(grCtx, m_size, m_msaaSampleCount, m_opacityMode,
m_colorSpace, m_colorType, &surfaceIsAccelerated));

Powered by Google App Engine
This is Rietveld 408576698