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

Side by Side Diff: gm/gamma.cpp

Issue 2029373004: respect srgb gamma when building mips (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix warning Created 4 years, 6 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 unified diff | Download patch
« no previous file with comments | « bench/MipMapBench.cpp ('k') | gm/mipmap.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 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 "gm.h" 8 #include "gm.h"
9 9
10 #include "Resources.h" 10 #include "Resources.h"
11 #include "SkGradientShader.h" 11 #include "SkGradientShader.h"
12 #include "SkPM4fPriv.h"
12 13
13 DEF_SIMPLE_GM(gamma, canvas, 560, 200) { 14 DEF_SIMPLE_GM(gamma, canvas, 560, 200) {
14 SkPaint p; 15 SkPaint p;
15 const SkScalar sz = 50.0f; 16 const SkScalar sz = 50.0f;
16 const int szInt = SkScalarTruncToInt(sz); 17 const int szInt = SkScalarTruncToInt(sz);
17 const SkScalar tx = sz + 5.0f; 18 const SkScalar tx = sz + 5.0f;
18 const SkRect r = SkRect::MakeXYWH(0, 0, sz, sz); 19 const SkRect r = SkRect::MakeXYWH(0, 0, sz, sz);
19 SkShader::TileMode rpt = SkShader::kRepeat_TileMode; 20 SkShader::TileMode rpt = SkShader::kRepeat_TileMode;
20 21
21 SkBitmap ditherBmp; 22 SkBitmap ditherBmp;
22 ditherBmp.allocN32Pixels(2, 2); 23 ditherBmp.allocN32Pixels(2, 2);
23 SkPMColor* pixels = reinterpret_cast<SkPMColor*>(ditherBmp.getPixels()); 24 SkPMColor* pixels = reinterpret_cast<SkPMColor*>(ditherBmp.getPixels());
24 pixels[0] = pixels[3] = SkPackARGB32(0xFF, 0xFF, 0xFF, 0xFF); 25 pixels[0] = pixels[3] = SkPackARGB32(0xFF, 0xFF, 0xFF, 0xFF);
25 pixels[1] = pixels[2] = SkPackARGB32(0xFF, 0, 0, 0); 26 pixels[1] = pixels[2] = SkPackARGB32(0xFF, 0, 0, 0);
26 27
27 SkBitmap linearGreyBmp; 28 SkBitmap linearGreyBmp;
28 SkImageInfo linearGreyInfo = SkImageInfo::MakeN32(szInt, szInt, kOpaque_SkAl phaType, 29 SkImageInfo linearGreyInfo = SkImageInfo::MakeN32(szInt, szInt, kOpaque_SkAl phaType,
29 kLinear_SkColorProfileType ); 30 kLinear_SkColorProfileType );
30 linearGreyBmp.allocPixels(linearGreyInfo); 31 linearGreyBmp.allocPixels(linearGreyInfo);
31 linearGreyBmp.eraseARGB(0xFF, 0x7F, 0x7F, 0x7F); 32 linearGreyBmp.eraseARGB(0xFF, 0x7F, 0x7F, 0x7F);
32 33
33 SkBitmap srgbGreyBmp; 34 SkBitmap srgbGreyBmp;
34 SkImageInfo srgbGreyInfo = SkImageInfo::MakeN32(szInt, szInt, kOpaque_SkAlph aType, 35 SkImageInfo srgbGreyInfo = SkImageInfo::MakeN32(szInt, szInt, kOpaque_SkAlph aType,
35 kSRGB_SkColorProfileType); 36 kSRGB_SkColorProfileType);
36 srgbGreyBmp.allocPixels(srgbGreyInfo); 37 srgbGreyBmp.allocPixels(srgbGreyInfo);
37 // 0xBC = 255 * linear_to_srgb(0.5f) 38 // 0xBC = 255 * linear_to_srgb(0.5f)
38 srgbGreyBmp.eraseARGB(0xFF, 0xBC, 0xBC, 0xBC); 39 srgbGreyBmp.eraseARGB(0xFF, 0xBC, 0xBC, 0xBC);
39 40
40 SkBitmap mipmapBmp; 41 SkBitmap mipmapBmp;
41 SkImageInfo mipmapInfo = SkImageInfo::MakeN32(2, 2, kOpaque_SkAlphaType, 42 SkImageInfo mipmapInfo = SkImageInfo::Make(2, 2, kN32_SkColorType, kOpaque_S kAlphaType,
42 kSRGB_SkColorProfileType); 43 SkColorSpace::NewNamed(SkColorSpa ce::kSRGB_Named));
43 mipmapBmp.allocPixels(mipmapInfo); 44 mipmapBmp.allocPixels(mipmapInfo);
44 SkPMColor* mipmapPixels = reinterpret_cast<SkPMColor*>(mipmapBmp.getPixels() ); 45 SkPMColor* mipmapPixels = reinterpret_cast<SkPMColor*>(mipmapBmp.getPixels() );
45 // 0x89 = 255 * linear_to_srgb(0.25f) 46 unsigned s25 = 0x89; // 255 * linear_to_srgb(0.25f)
46 mipmapPixels[0] = mipmapPixels[3] = SkPackARGB32(0xFF, 0x89, 0x89, 0x89); 47 unsigned s75 = 0xE1; // 255 * linear_to_srgb(0.75f)
47 // 0xE1 = 255 * linear_to_srgb(0.75f) 48 mipmapPixels[0] = mipmapPixels[3] = SkPackARGB32(0xFF, s25, s25, s25);
48 mipmapPixels[1] = mipmapPixels[2] = SkPackARGB32(0xFF, 0xE1, 0xE1, 0xE1); 49 mipmapPixels[1] = mipmapPixels[2] = SkPackARGB32(0xFF, s75, s75, s75);
49 50
50 SkPaint textPaint; 51 SkPaint textPaint;
51 textPaint.setColor(SK_ColorWHITE); 52 textPaint.setColor(SK_ColorWHITE);
52 53
53 // Helpers: 54 // Helpers:
54 auto advance = [&]() { 55 auto advance = [&]() {
55 canvas->translate(tx, 0); 56 canvas->translate(tx, 0);
56 p.reset(); 57 p.reset();
57 }; 58 };
58 59
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 nextXferRect(SK_ColorWHITE, SkXfermode::kSrcIn_Mode, 0x7fff00ff); 175 nextXferRect(SK_ColorWHITE, SkXfermode::kSrcIn_Mode, 0x7fff00ff);
175 nextXferRect(0x7fff00ff, SkXfermode::kDstIn_Mode, SK_ColorWHITE); 176 nextXferRect(0x7fff00ff, SkXfermode::kDstIn_Mode, SK_ColorWHITE);
176 nextXferRect(sqrtHalfWhite, SkXfermode::kSrcIn_Mode, sqrtHalfAlpha); 177 nextXferRect(sqrtHalfWhite, SkXfermode::kSrcIn_Mode, sqrtHalfAlpha);
177 nextXferRect(sqrtHalfAlpha, SkXfermode::kDstIn_Mode, sqrtHalfWhite); 178 nextXferRect(sqrtHalfAlpha, SkXfermode::kDstIn_Mode, sqrtHalfWhite);
178 179
179 nextXferRect(0xff3f3f3f, SkXfermode::kPlus_Mode, 0xff3f3f3f); 180 nextXferRect(0xff3f3f3f, SkXfermode::kPlus_Mode, 0xff3f3f3f);
180 nextXferRect(sqrtHalfWhite, SkXfermode::kModulate_Mode, sqrtHalfWhite); 181 nextXferRect(sqrtHalfWhite, SkXfermode::kModulate_Mode, sqrtHalfWhite);
181 182
182 canvas->restore(); 183 canvas->restore();
183 } 184 }
OLDNEW
« no previous file with comments | « bench/MipMapBench.cpp ('k') | gm/mipmap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698