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

Side by Side Diff: gm/surface.cpp

Issue 2188463002: Remove SkSurfaceProps gamma-correctness flag entirely. (Closed) Base URL: https://skia.googlesource.com/skia.git@remove-is-gamma-correct
Patch Set: Created 4 years, 4 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 | « gm/dftext.cpp ('k') | gm/textblobgeometrychange.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 2014 Google Inc. 2 * Copyright 2014 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 "SkGradientShader.h" 9 #include "SkGradientShader.h"
10 #include "SkSurface.h" 10 #include "SkSurface.h"
11 #include "SkSurfaceProps.h" 11 #include "SkSurfaceProps.h"
12 12
13 #define W 200 13 #define W 200
14 #define H 100 14 #define H 100
15 15
16 static sk_sp<SkShader> make_shader() { 16 static sk_sp<SkShader> make_shader() {
17 int a = 0x99; 17 int a = 0x99;
18 int b = 0xBB; 18 int b = 0xBB;
19 SkPoint pts[] = { { 0, 0 }, { W, H } }; 19 SkPoint pts[] = { { 0, 0 }, { W, H } };
20 SkColor colors[] = { SkColorSetRGB(a, a, a), SkColorSetRGB(b, b, b) }; 20 SkColor colors[] = { SkColorSetRGB(a, a, a), SkColorSetRGB(b, b, b) };
21 return SkGradientShader::MakeLinear(pts, colors, nullptr, 2, SkShader::kClam p_TileMode); 21 return SkGradientShader::MakeLinear(pts, colors, nullptr, 2, SkShader::kClam p_TileMode);
22 } 22 }
23 23
24 static sk_sp<SkSurface> make_surface(GrContext* ctx, const SkImageInfo& info, Sk PixelGeometry geo, 24 static sk_sp<SkSurface> make_surface(GrContext* ctx, const SkImageInfo& info, Sk PixelGeometry geo,
25 int disallowAA, int disallowDither, bool ga mmaCorrect) { 25 int disallowAA, int disallowDither) {
26 uint32_t flags = 0; 26 uint32_t flags = 0;
27 if (disallowAA) { 27 if (disallowAA) {
28 flags |= SkSurfaceProps::kDisallowAntiAlias_Flag; 28 flags |= SkSurfaceProps::kDisallowAntiAlias_Flag;
29 } 29 }
30 if (disallowDither) { 30 if (disallowDither) {
31 flags |= SkSurfaceProps::kDisallowDither_Flag; 31 flags |= SkSurfaceProps::kDisallowDither_Flag;
32 } 32 }
33 if (gammaCorrect) {
34 flags |= SkSurfaceProps::kGammaCorrect_Flag;
35 }
36 33
37 SkSurfaceProps props(flags, geo); 34 SkSurfaceProps props(flags, geo);
38 if (ctx) { 35 if (ctx) {
39 return SkSurface::MakeRenderTarget(ctx, SkBudgeted::kNo, info, 0, &props ); 36 return SkSurface::MakeRenderTarget(ctx, SkBudgeted::kNo, info, 0, &props );
40 } else { 37 } else {
41 return SkSurface::MakeRaster(info, &props); 38 return SkSurface::MakeRaster(info, &props);
42 } 39 }
43 } 40 }
44 41
45 static void test_draw(SkCanvas* canvas, const char label[]) { 42 static void test_draw(SkCanvas* canvas, const char label[]) {
(...skipping 26 matching lines...) Expand all
72 SkISize onISize() override { 69 SkISize onISize() override {
73 return SkISize::Make(W * 4, H * 5); 70 return SkISize::Make(W * 4, H * 5);
74 } 71 }
75 72
76 void onDraw(SkCanvas* canvas) override { 73 void onDraw(SkCanvas* canvas) override {
77 GrContext* ctx = canvas->getGrContext(); 74 GrContext* ctx = canvas->getGrContext();
78 75
79 // must be opaque to have a hope of testing LCD text 76 // must be opaque to have a hope of testing LCD text
80 const SkImageInfo info = SkImageInfo::MakeN32(W, H, kOpaque_SkAlphaType, 77 const SkImageInfo info = SkImageInfo::MakeN32(W, H, kOpaque_SkAlphaType,
81 sk_ref_sp(canvas->imageInf o().colorSpace())); 78 sk_ref_sp(canvas->imageInf o().colorSpace()));
82 SkSurfaceProps canvasProps(SkSurfaceProps::kLegacyFontHost_InitType);
83 bool gammaCorrect = canvas->getProps(&canvasProps) && canvasProps.isGamm aCorrect();
84 79
85 const struct { 80 const struct {
86 SkPixelGeometry fGeo; 81 SkPixelGeometry fGeo;
87 const char* fLabel; 82 const char* fLabel;
88 } recs[] = { 83 } recs[] = {
89 { kUnknown_SkPixelGeometry, "Unknown" }, 84 { kUnknown_SkPixelGeometry, "Unknown" },
90 { kRGB_H_SkPixelGeometry, "RGB_H" }, 85 { kRGB_H_SkPixelGeometry, "RGB_H" },
91 { kBGR_H_SkPixelGeometry, "BGR_H" }, 86 { kBGR_H_SkPixelGeometry, "BGR_H" },
92 { kRGB_V_SkPixelGeometry, "RGB_V" }, 87 { kRGB_V_SkPixelGeometry, "RGB_V" },
93 { kBGR_V_SkPixelGeometry, "BGR_V" }, 88 { kBGR_V_SkPixelGeometry, "BGR_V" },
94 }; 89 };
95 90
96 SkScalar x = 0; 91 SkScalar x = 0;
97 for (int disallowAA = 0; disallowAA <= 1; ++disallowAA) { 92 for (int disallowAA = 0; disallowAA <= 1; ++disallowAA) {
98 for (int disallowDither = 0; disallowDither <= 1; ++disallowDither) { 93 for (int disallowDither = 0; disallowDither <= 1; ++disallowDither) {
99 SkScalar y = 0; 94 SkScalar y = 0;
100 for (const auto& rec : recs) { 95 for (const auto& rec : recs) {
101 auto surface(make_surface(ctx, info, rec.fGeo, disallowAA, d isallowDither, 96 auto surface(make_surface(ctx, info, rec.fGeo, disallowAA, d isallowDither));
102 gammaCorrect));
103 if (!surface) { 97 if (!surface) {
104 SkDebugf("failed to create surface! label: %s AA: %s dit her: %s\n", 98 SkDebugf("failed to create surface! label: %s AA: %s dit her: %s\n",
105 rec.fLabel, (disallowAA == 1 ? "disallowed" : " allowed"), 99 rec.fLabel, (disallowAA == 1 ? "disallowed" : " allowed"),
106 (disallowDither == 1 ? "disallowed" : "allowed" )); 100 (disallowDither == 1 ? "disallowed" : "allowed" ));
107 continue; 101 continue;
108 } 102 }
109 test_draw(surface->getCanvas(), rec.fLabel); 103 test_draw(surface->getCanvas(), rec.fLabel);
110 surface->draw(canvas, x, y, nullptr); 104 surface->draw(canvas, x, y, nullptr);
111 y += H; 105 y += H;
112 } 106 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 SkASSERT(equal(surf->props(), surf2->props())); 156 SkASSERT(equal(surf->props(), surf2->props()));
163 157
164 sk_sp<SkImage> image2(surf2->makeImageSnapshot()); 158 sk_sp<SkImage> image2(surf2->makeImageSnapshot());
165 canvas->drawImage(image2.get(), 10 + SkIntToScalar(image->width()) + 10, 10, nullptr); 159 canvas->drawImage(image2.get(), 10 + SkIntToScalar(image->width()) + 10, 10, nullptr);
166 } 160 }
167 161
168 private: 162 private:
169 typedef GM INHERITED; 163 typedef GM INHERITED;
170 }; 164 };
171 DEF_GM( return new NewSurfaceGM ) 165 DEF_GM( return new NewSurfaceGM )
OLDNEW
« no previous file with comments | « gm/dftext.cpp ('k') | gm/textblobgeometrychange.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698