OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SampleApp.h" | 8 #include "SampleApp.h" |
9 | 9 |
10 #include "OverView.h" | 10 #include "OverView.h" |
11 #include "Resources.h" | 11 #include "Resources.h" |
12 #include "SampleCode.h" | 12 #include "SampleCode.h" |
13 #include "SkAnimTimer.h" | 13 #include "SkAnimTimer.h" |
14 #include "SkCanvas.h" | 14 #include "SkCanvas.h" |
15 #include "SkCommandLineFlags.h" | 15 #include "SkCommandLineFlags.h" |
16 #include "SkData.h" | 16 #include "SkData.h" |
17 #include "SkDocument.h" | 17 #include "SkDocument.h" |
18 #include "SkGammaColorFilter.h" | |
18 #include "SkGraphics.h" | 19 #include "SkGraphics.h" |
19 #include "SkImage_Base.h" | 20 #include "SkImage_Base.h" |
20 #include "SkImageEncoder.h" | 21 #include "SkImageEncoder.h" |
21 #include "SkOSFile.h" | 22 #include "SkOSFile.h" |
22 #include "SkPaint.h" | 23 #include "SkPaint.h" |
23 #include "SkPaintFilterCanvas.h" | 24 #include "SkPaintFilterCanvas.h" |
24 #include "SkPicture.h" | 25 #include "SkPicture.h" |
25 #include "SkPictureRecorder.h" | 26 #include "SkPictureRecorder.h" |
26 #include "SkPM4fPriv.h" | 27 #include "SkPM4fPriv.h" |
27 #include "SkStream.h" | 28 #include "SkStream.h" |
28 #include "SkSurface.h" | 29 #include "SkSurface.h" |
29 #include "SkTemplates.h" | 30 #include "SkTemplates.h" |
30 #include "SkTSort.h" | 31 #include "SkTSort.h" |
31 #include "SkTime.h" | 32 #include "SkTime.h" |
32 #include "SkTypeface.h" | 33 #include "SkTypeface.h" |
33 #include "SkWindow.h" | 34 #include "SkWindow.h" |
34 #include "sk_tool_utils.h" | 35 #include "sk_tool_utils.h" |
35 | 36 |
36 #if SK_SUPPORT_GPU | 37 #if SK_SUPPORT_GPU |
37 # include "gl/GrGLInterface.h" | 38 # include "gl/GrGLInterface.h" |
38 # include "gl/GrGLUtil.h" | 39 # include "gl/GrGLUtil.h" |
39 # include "GrDrawContext.h" | |
40 # include "GrRenderTarget.h" | |
41 # include "GrContext.h" | 40 # include "GrContext.h" |
42 # include "SkGr.h" | 41 # include "SkGr.h" |
43 # if SK_ANGLE | 42 # if SK_ANGLE |
44 # include "gl/angle/GLTestContext_angle.h" | 43 # include "gl/angle/GLTestContext_angle.h" |
45 # endif | 44 # endif |
46 #else | 45 #else |
47 class GrContext; | 46 class GrContext; |
48 #endif | 47 #endif |
49 | 48 |
50 const struct { | 49 const struct { |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
328 SkBitmap bm; | 327 SkBitmap bm; |
329 bm.allocPixels(win->info()); | 328 bm.allocPixels(win->info()); |
330 canvas->readPixels(&bm, 0, 0); | 329 canvas->readPixels(&bm, 0, 0); |
331 SkPixmap pm; | 330 SkPixmap pm; |
332 bm.peekPixels(&pm); | 331 bm.peekPixels(&pm); |
333 sk_sp<SkImage> image(SkImage::MakeTextureFromPixmap(fCurContext, pm, | 332 sk_sp<SkImage> image(SkImage::MakeTextureFromPixmap(fCurContext, pm, |
334 SkBudgeted::kNo) ); | 333 SkBudgeted::kNo) ); |
335 | 334 |
336 SkCanvas* canvas = fGpuSurface->getCanvas(); | 335 SkCanvas* canvas = fGpuSurface->getCanvas(); |
337 | 336 |
338 // Temporary code until applyGamma is replaced | |
339 GrDrawContext* dc = canvas->internal_private_accessTopLayerDrawConte xt(); | |
340 GrRenderTarget* rt = dc->accessRenderTarget(); | |
341 GrTexture* texture = image->getTexture(); | |
342 SkASSERT(texture); | |
343 | |
344 // With ten-bit output, we need to manually apply the gamma of the o utput device | 337 // With ten-bit output, we need to manually apply the gamma of the o utput device |
345 // (unless we're in non-gamma correct mode, in which case our data i s already | 338 // (unless we're in non-gamma correct mode, in which case our data i s already |
346 // fake-sRGB, like we're expected to put in the 10-bit buffer): | 339 // fake-sRGB, like we're expected to put in the 10-bit buffer): |
347 bool doGamma = (fActualColorBits == 30) && SkImageInfoIsGammaCorrect (win->info()); | 340 bool doGamma = (fActualColorBits == 30) && SkImageInfoIsGammaCorrect (win->info()); |
348 fCurContext->applyGamma(rt, texture, doGamma ? 1.0f / 2.2f : 1.0f); | 341 |
342 SkPaint gammaPaint; | |
343 gammaPaint.setXfermodeMode(SkXfermode::kSrc_Mode); | |
344 if (doGamma) { | |
345 gammaPaint.setColorFilter(SkGammaColorFilter::Make(1.0f / 2.2f)) ; | |
346 } | |
347 | |
348 canvas->drawImage(image, 0, 0, &gammaPaint); | |
349 canvas->flush(); | |
bsalomon
2016/07/29 14:15:07
Move this canvas->flush() above win->present() at
robertphillips
2016/07/29 14:39:28
Done.
| |
349 } | 350 } |
350 #endif | 351 #endif |
351 | 352 |
352 win->present(); | 353 win->present(); |
353 } | 354 } |
354 | 355 |
355 void windowSizeChanged(SampleWindow* win) override { | 356 void windowSizeChanged(SampleWindow* win) override { |
356 #if SK_SUPPORT_GPU | 357 #if SK_SUPPORT_GPU |
357 if (fCurContext) { | 358 if (fCurContext) { |
358 AttachmentInfo attachmentInfo; | 359 AttachmentInfo attachmentInfo; |
(...skipping 1916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2275 #ifdef SK_BUILD_FOR_MAC | 2276 #ifdef SK_BUILD_FOR_MAC |
2276 setenv("ANDROID_ROOT", "/android/device/data", 0); | 2277 setenv("ANDROID_ROOT", "/android/device/data", 0); |
2277 #endif | 2278 #endif |
2278 SkGraphics::Init(); | 2279 SkGraphics::Init(); |
2279 SkEvent::Init(); | 2280 SkEvent::Init(); |
2280 } | 2281 } |
2281 | 2282 |
2282 void application_term() { | 2283 void application_term() { |
2283 SkEvent::Term(); | 2284 SkEvent::Term(); |
2284 } | 2285 } |
OLD | NEW |