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

Unified Diff: samplecode/SampleApp.cpp

Issue 2191323002: Remove GrContext::applyGamma (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix flushing in publishCanvas 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 | « include/gpu/GrContext.h ('k') | src/gpu/GrContext.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 0c9c3f0276d6005cfb4345051b77f845c00f2f68..39ee44da7e5397efe382a8db4dfea9de6d00d729 100644
--- a/samplecode/SampleApp.cpp
+++ b/samplecode/SampleApp.cpp
@@ -15,6 +15,7 @@
#include "SkCommandLineFlags.h"
#include "SkData.h"
#include "SkDocument.h"
+#include "SkGammaColorFilter.h"
#include "SkGraphics.h"
#include "SkImage_Base.h"
#include "SkImageEncoder.h"
@@ -36,8 +37,6 @@
#if SK_SUPPORT_GPU
# include "gl/GrGLInterface.h"
# include "gl/GrGLUtil.h"
-# include "GrDrawContext.h"
-# include "GrRenderTarget.h"
# include "GrContext.h"
# include "SkGr.h"
# if SK_ANGLE
@@ -314,39 +313,37 @@ public:
}
void publishCanvas(SampleWindow::DeviceType dType,
- SkCanvas* canvas, SampleWindow* win) override {
+ SkCanvas* renderingCanvas, SampleWindow* win) override {
#if SK_SUPPORT_GPU
- if (fCurContext) {
- // in case we have queued drawing calls
- fCurContext->flush();
- }
-
if (!IsGpuDeviceType(dType) ||
kRGBA_F16_SkColorType == win->info().colorType() ||
fActualColorBits > 24) {
// We made/have an off-screen surface. Get the contents as an SkImage:
SkBitmap bm;
bm.allocPixels(win->info());
- canvas->readPixels(&bm, 0, 0);
+ renderingCanvas->readPixels(&bm, 0, 0);
SkPixmap pm;
bm.peekPixels(&pm);
sk_sp<SkImage> image(SkImage::MakeTextureFromPixmap(fCurContext, pm,
SkBudgeted::kNo));
- 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);
+ SkCanvas* gpuCanvas = fGpuSurface->getCanvas();
// 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(rt, texture, doGamma ? 1.0f / 2.2f : 1.0f);
+
+ SkPaint gammaPaint;
+ gammaPaint.setXfermodeMode(SkXfermode::kSrc_Mode);
+ if (doGamma) {
+ gammaPaint.setColorFilter(SkGammaColorFilter::Make(1.0f / 2.2f));
+ }
+
+ gpuCanvas->drawImage(image, 0, 0, &gammaPaint);
}
+
+ fGpuSurface->prepareForExternalIO();
#endif
win->present();
« no previous file with comments | « include/gpu/GrContext.h ('k') | src/gpu/GrContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698