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

Side by Side Diff: gm/colorspacexform.cpp

Issue 2377763002: Added kSRGBLinear_Named color space, along with tests (Closed)
Patch Set: Update some call sites Created 4 years, 2 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 | « no previous file | include/core/SkColorSpace.h » ('j') | include/core/SkColorSpace.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 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 #include "SkColor.h" 9 #include "SkColor.h"
10 #include "SkColorSpaceXform.h" 10 #include "SkColorSpaceXform.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 SkISize onISize() override { 53 SkISize onISize() override {
54 return SkISize::Make(500, 200); 54 return SkISize::Make(500, 200);
55 } 55 }
56 56
57 void onDraw(SkCanvas* canvas) override { 57 void onDraw(SkCanvas* canvas) override {
58 auto drawColors = [canvas](SkColor4f* colors) { 58 auto drawColors = [canvas](SkColor4f* colors) {
59 SkRect r = SkRect::MakeXYWH(0.0f, 0.0f, 50.0f, 100.0f); 59 SkRect r = SkRect::MakeXYWH(0.0f, 0.0f, 50.0f, 100.0f);
60 60
61 canvas->save(); 61 canvas->save();
62 for (int i = 0; i < kNumColors; i++) { 62 for (int i = 0; i < kNumColors; i++) {
63 sk_sp<SkColorSpace> space = 63 sk_sp<SkColorSpace> space = SkColorSpace::NewNamed(SkColorSpace: :kSRGBLinear_Named);
64 SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named)->makeL inearGamma();
65 sk_sp<SkShader> s = SkShader::MakeColorShader(colors[i], space); 64 sk_sp<SkShader> s = SkShader::MakeColorShader(colors[i], space);
66 SkPaint paint; 65 SkPaint paint;
67 paint.setShader(s); 66 paint.setShader(s);
68 canvas->drawRect(r, paint); 67 canvas->drawRect(r, paint);
69 canvas->translate(50.0f, 0.0f); 68 canvas->translate(50.0f, 0.0f);
70 } 69 }
71 canvas->restore(); 70 canvas->restore();
72 }; 71 };
73 72
74 // Wide gamut colors should appear darker - we are simulating a more int ense display. 73 // Wide gamut colors should appear darker - we are simulating a more int ense display.
75 drawColors(fSRGBColors); 74 drawColors(fSRGBColors);
76 canvas->translate(0.0f, 100.0f); 75 canvas->translate(0.0f, 100.0f);
77 drawColors(fWideGamutColors); 76 drawColors(fWideGamutColors);
78 } 77 }
79 78
80 private: 79 private:
81 static constexpr int kNumColors = 10; 80 static constexpr int kNumColors = 10;
82 81
83 SkColor4f fSRGBColors[kNumColors]; 82 SkColor4f fSRGBColors[kNumColors];
84 SkColor4f fWideGamutColors[kNumColors]; 83 SkColor4f fWideGamutColors[kNumColors];
85 84
86 typedef skiagm::GM INHERITED; 85 typedef skiagm::GM INHERITED;
87 }; 86 };
88 87
89 DEF_GM(return new ColorSpaceXformGM;) 88 DEF_GM(return new ColorSpaceXformGM;)
OLDNEW
« no previous file with comments | « no previous file | include/core/SkColorSpace.h » ('j') | include/core/SkColorSpace.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698