Remove use of MakeRenderTargetDirect from view system
Here is the CL that sent me down the SkGammaColorFilter path
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2178353005
Review-Url: https://codereview.chromium.org/2178353005
diff --git a/src/views/SkWindow.cpp b/src/views/SkWindow.cpp
index a1af704..e578b1a 100644
--- a/src/views/SkWindow.cpp
+++ b/src/views/SkWindow.cpp
@@ -30,10 +30,9 @@
fMenus.deleteAll();
}
-SkSurface* SkWindow::createSurface() {
+sk_sp<SkSurface> SkWindow::makeSurface() {
const SkBitmap& bm = this->getBitmap();
- return SkSurface::MakeRasterDirect(bm.info(), bm.getPixels(), bm.rowBytes(),
- &fSurfaceProps).release();
+ return SkSurface::MakeRasterDirect(bm.info(), bm.getPixels(), bm.rowBytes(), &fSurfaceProps);
}
void SkWindow::setMatrix(const SkMatrix& matrix) {
@@ -106,7 +105,7 @@
bool SkWindow::update(SkIRect* updateArea) {
if (!fDirtyRgn.isEmpty()) {
- SkAutoTUnref<SkSurface> surface(this->createSurface());
+ sk_sp<SkSurface> surface(this->makeSurface());
SkCanvas* canvas = surface->getCanvas();
canvas->clipRegion(fDirtyRgn);
@@ -322,11 +321,16 @@
#include "gl/GrGLUtil.h"
#include "SkGr.h"
-GrRenderTarget* SkWindow::renderTarget(const AttachmentInfo& attachmentInfo,
- const GrGLInterface* interface, GrContext* grContext) {
+sk_sp<SkSurface> SkWindow::makeGpuBackedSurface(const AttachmentInfo& attachmentInfo,
+ const GrGLInterface* interface,
+ GrContext* grContext) {
GrBackendRenderTargetDesc desc;
desc.fWidth = SkScalarRoundToInt(this->width());
desc.fHeight = SkScalarRoundToInt(this->height());
+ if (0 == desc.fWidth || 0 == desc.fHeight) {
+ return nullptr;
+ }
+
// TODO: Query the actual framebuffer for sRGB capable. However, to
// preserve old (fake-linear) behavior, we don't do this. Instead, rely
// on the flag (currently driven via 'C' mode in SampleApp).
@@ -347,7 +351,8 @@
GrGLint buffer;
GR_GL_GetIntegerv(interface, GR_GL_FRAMEBUFFER_BINDING, &buffer);
desc.fRenderTargetHandle = buffer;
- return grContext->textureProvider()->wrapBackendRenderTarget(desc);
+
+ return SkSurface::MakeFromBackendRenderTarget(grContext, desc, &fSurfaceProps);
}
#endif