aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2016-07-28 15:17:34 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-07-28 15:17:34 -0700
commitecf3dbe8f2987a08b21be1aff61b7fbfbb69640a (patch)
tree99358f3174597d234b1fdba3528dfdc513a09101 /src
parent99fb670977b5566e901cb4b95531a000ed0ec8a9 (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/views/SkWindow.cpp19
-rw-r--r--src/views/mac/SkNSView.mm48
2 files changed, 36 insertions, 31 deletions
diff --git a/src/views/SkWindow.cpp b/src/views/SkWindow.cpp
index a1af704442..e578b1a01f 100644
--- a/src/views/SkWindow.cpp
+++ b/src/views/SkWindow.cpp
@@ -30,10 +30,9 @@ SkWindow::~SkWindow() {
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 @@ extern bool gEnableControlledThrow;
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 @@ bool SkWindow::onDispatchClick(int x, int y, Click::State state,
#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 @@ GrRenderTarget* SkWindow::renderTarget(const AttachmentInfo& attachmentInfo,
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
diff --git a/src/views/mac/SkNSView.mm b/src/views/mac/SkNSView.mm
index 73b353f15d..ce29382371 100644
--- a/src/views/mac/SkNSView.mm
+++ b/src/views/mac/SkNSView.mm
@@ -134,7 +134,7 @@ static_assert(SK_SUPPORT_GPU, "not_implemented_for_non_gpu_build");
- (void)drawSkia {
fRedrawRequestPending = false;
if (fWind) {
- SkAutoTUnref<SkSurface> surface(fWind->createSurface());
+ sk_sp<SkSurface> surface(fWind->makeSurface());
fWind->draw(surface->getCanvas());
#ifdef FORCE_REDRAW
fWind->inval(NULL);
@@ -171,13 +171,13 @@ static_assert(SK_SUPPORT_GPU, "not_implemented_for_non_gpu_build");
#include "SkKey.h"
enum {
- SK_MacReturnKey = 36,
- SK_MacDeleteKey = 51,
- SK_MacEndKey = 119,
- SK_MacLeftKey = 123,
- SK_MacRightKey = 124,
- SK_MacDownKey = 125,
- SK_MacUpKey = 126,
+ SK_MacReturnKey = 36,
+ SK_MacDeleteKey = 51,
+ SK_MacEndKey = 119,
+ SK_MacLeftKey = 123,
+ SK_MacRightKey = 124,
+ SK_MacDownKey = 125,
+ SK_MacUpKey = 126,
SK_Mac0Key = 0x52,
SK_Mac1Key = 0x53,
SK_Mac2Key = 0x54,
@@ -192,17 +192,17 @@ enum {
static SkKey raw2key(UInt32 raw)
{
- static const struct {
- UInt32 fRaw;
- SkKey fKey;
- } gKeys[] = {
- { SK_MacUpKey, kUp_SkKey },
- { SK_MacDownKey, kDown_SkKey },
- { SK_MacLeftKey, kLeft_SkKey },
- { SK_MacRightKey, kRight_SkKey },
- { SK_MacReturnKey, kOK_SkKey },
- { SK_MacDeleteKey, kBack_SkKey },
- { SK_MacEndKey, kEnd_SkKey },
+ static const struct {
+ UInt32 fRaw;
+ SkKey fKey;
+ } gKeys[] = {
+ { SK_MacUpKey, kUp_SkKey },
+ { SK_MacDownKey, kDown_SkKey },
+ { SK_MacLeftKey, kLeft_SkKey },
+ { SK_MacRightKey, kRight_SkKey },
+ { SK_MacReturnKey, kOK_SkKey },
+ { SK_MacDeleteKey, kBack_SkKey },
+ { SK_MacEndKey, kEnd_SkKey },
{ SK_Mac0Key, k0_SkKey },
{ SK_Mac1Key, k1_SkKey },
{ SK_Mac2Key, k2_SkKey },
@@ -213,12 +213,12 @@ static SkKey raw2key(UInt32 raw)
{ SK_Mac7Key, k7_SkKey },
{ SK_Mac8Key, k8_SkKey },
{ SK_Mac9Key, k9_SkKey }
- };
+ };
- for (unsigned i = 0; i < SK_ARRAY_COUNT(gKeys); i++)
- if (gKeys[i].fRaw == raw)
- return gKeys[i].fKey;
- return kNONE_SkKey;
+ for (unsigned i = 0; i < SK_ARRAY_COUNT(gKeys); i++)
+ if (gKeys[i].fRaw == raw)
+ return gKeys[i].fKey;
+ return kNONE_SkKey;
}
- (void)keyDown:(NSEvent *)event {