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

Unified Diff: samplecode/SampleApp.cpp

Issue 2178353005: Remove use of MakeRenderTargetDirect from view system (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix Mac Created 4 years, 5 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
« no previous file with comments | « samplecode/SampleApp.h ('k') | src/views/SkWindow.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samplecode/SampleApp.cpp
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp
index 64d460fd9d9829dab851ccb0a1d18daa13bbaff8..0c9c3f0276d6005cfb4345051b77f845c00f2f68 100644
--- a/samplecode/SampleApp.cpp
+++ b/samplecode/SampleApp.cpp
@@ -36,6 +36,7 @@
#if SK_SUPPORT_GPU
# include "gl/GrGLInterface.h"
# include "gl/GrGLUtil.h"
+# include "GrDrawContext.h"
# include "GrRenderTarget.h"
# include "GrContext.h"
# include "SkGr.h"
@@ -187,7 +188,6 @@ public:
#if SK_SUPPORT_GPU
fCurContext = nullptr;
fCurIntf = nullptr;
- fCurRenderTarget = nullptr;
fMSAASampleCount = 0;
fDeepColor = false;
fActualColorBits = 0;
@@ -199,7 +199,6 @@ public:
#if SK_SUPPORT_GPU
SkSafeUnref(fCurContext);
SkSafeUnref(fCurIntf);
- SkSafeUnref(fCurRenderTarget);
#endif
}
@@ -272,7 +271,7 @@ public:
win->release();
}
#endif // SK_SUPPORT_GPU
- // call windowSizeChanged to create the render target
+ // call windowSizeChanged to create the gpu-backed Surface
this->windowSizeChanged(win);
}
@@ -288,14 +287,13 @@ public:
SkSafeUnref(fCurIntf);
fCurIntf = nullptr;
- SkSafeUnref(fCurRenderTarget);
- fCurRenderTarget = nullptr;
+ fGpuSurface = nullptr;
#endif
win->release();
fBackend = kNone_BackEndType;
}
- SkSurface* createSurface(SampleWindow::DeviceType dType, SampleWindow* win) override {
+ sk_sp<SkSurface> makeSurface(SampleWindow::DeviceType dType, SampleWindow* win) override {
#if SK_SUPPORT_GPU
if (IsGpuDeviceType(dType) && fCurContext) {
SkSurfaceProps props(win->getSurfaceProps());
@@ -306,11 +304,9 @@ public:
// If we're using a deep (10-bit or higher) surface, we probably need an off-screen
// surface. 10-bit, in particular, has strange gamma behavior.
return SkSurface::MakeRenderTarget(fCurContext, SkBudgeted::kNo, win->info(),
- fMSAASampleCount, &props).release();
+ fMSAASampleCount, &props);
} else {
- return SkSurface::MakeRenderTargetDirect(fCurRenderTarget,
- sk_ref_sp(win->info().colorSpace()),
- &props).release();
+ return fGpuSurface;
}
}
#endif
@@ -336,14 +332,20 @@ public:
bm.peekPixels(&pm);
sk_sp<SkImage> image(SkImage::MakeTextureFromPixmap(fCurContext, pm,
SkBudgeted::kNo));
- GrTexture* texture = as_IB(image)->peekTexture();
+
+ SkCanvas* canvas = fGpuSurface->getCanvas();
+
+ // Temporary code until applyGamma is replaced
+ GrDrawContext* dc = canvas->internal_private_accessTopLayerDrawContext();
+ GrRenderTarget* rt = dc->accessRenderTarget();
+ GrTexture* texture = image->getTexture();
SkASSERT(texture);
// With ten-bit output, we need to manually apply the gamma of the output device
// (unless we're in non-gamma correct mode, in which case our data is already
// fake-sRGB, like we're expected to put in the 10-bit buffer):
bool doGamma = (fActualColorBits == 30) && SkImageInfoIsGammaCorrect(win->info());
- fCurContext->applyGamma(fCurRenderTarget, texture, doGamma ? 1.0f / 2.2f : 1.0f);
+ fCurContext->applyGamma(rt, texture, doGamma ? 1.0f / 2.2f : 1.0f);
}
#endif
@@ -355,9 +357,8 @@ public:
if (fCurContext) {
AttachmentInfo attachmentInfo;
win->attach(fBackend, fMSAASampleCount, fDeepColor, &attachmentInfo);
- SkSafeUnref(fCurRenderTarget);
fActualColorBits = SkTMax(attachmentInfo.fColorBits, 24);
- fCurRenderTarget = win->renderTarget(attachmentInfo, fCurIntf, fCurContext);
+ fGpuSurface = win->makeGpuBackedSurface(attachmentInfo, fCurIntf, fCurContext);
}
#endif
}
@@ -370,12 +371,8 @@ public:
#endif
}
- GrRenderTarget* getGrRenderTarget() override {
-#if SK_SUPPORT_GPU
- return fCurRenderTarget;
-#else
- return nullptr;
-#endif
+ int numColorSamples() const override {
+ return fMSAASampleCount;
}
int getColorBits() override {
@@ -391,7 +388,7 @@ private:
#if SK_SUPPORT_GPU
GrContext* fCurContext;
const GrGLInterface* fCurIntf;
- GrRenderTarget* fCurRenderTarget;
+ sk_sp<SkSurface> fGpuSurface;
int fMSAASampleCount;
bool fDeepColor;
int fActualColorBits;
@@ -2085,10 +2082,9 @@ void SampleWindow::updateTitle() {
#if SK_SUPPORT_GPU
if (IsGpuDeviceType(fDeviceType) &&
fDevManager &&
- fDevManager->getGrRenderTarget() &&
- fDevManager->getGrRenderTarget()->numColorSamples() > 0) {
+ fDevManager->numColorSamples() > 0) {
title.appendf(" [MSAA: %d]",
- fDevManager->getGrRenderTarget()->numColorSamples());
+ fDevManager->numColorSamples());
}
#endif
« no previous file with comments | « samplecode/SampleApp.h ('k') | src/views/SkWindow.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698