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

Side by Side Diff: tools/skiaserve/Request.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 | « tests/SRGBMipMapTest.cpp ('k') | tools/viewer/sk_app/WindowContext.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 2016 Google Inc. 2 * Copyright 2016 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 "Request.h" 8 #include "Request.h"
9 9
10 #include "SkPictureRecorder.h" 10 #include "SkPictureRecorder.h"
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 bounds = SkIRect::MakeWH(SkTMin(bounds.width(), kMaxWidth), 154 bounds = SkIRect::MakeWH(SkTMin(bounds.width(), kMaxWidth),
155 SkTMin(bounds.height(), kMaxHeight)); 155 SkTMin(bounds.height(), kMaxHeight));
156 return bounds; 156 return bounds;
157 } 157 }
158 158
159 namespace { 159 namespace {
160 160
161 struct ColorAndProfile { 161 struct ColorAndProfile {
162 SkColorType fColorType; 162 SkColorType fColorType;
163 bool fSRGB; 163 bool fSRGB;
164 bool fGammaCorrect;
165 }; 164 };
166 165
167 ColorAndProfile ColorModes[] = { 166 ColorAndProfile ColorModes[] = {
168 { kN32_SkColorType, false, false }, 167 { kN32_SkColorType, false },
169 { kN32_SkColorType, true, true }, 168 { kN32_SkColorType, true },
170 { kRGBA_F16_SkColorType, true, true }, 169 { kRGBA_F16_SkColorType, true },
171 }; 170 };
172 171
173 } 172 }
174 173
175 SkSurface* Request::createCPUSurface() { 174 SkSurface* Request::createCPUSurface() {
176 SkIRect bounds = this->getBounds(); 175 SkIRect bounds = this->getBounds();
177 ColorAndProfile cap = ColorModes[fColorMode]; 176 ColorAndProfile cap = ColorModes[fColorMode];
178 auto srgbColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); 177 auto srgbColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named);
179 SkImageInfo info = SkImageInfo::Make(bounds.width(), bounds.height(), cap.fC olorType, 178 SkImageInfo info = SkImageInfo::Make(bounds.width(), bounds.height(), cap.fC olorType,
180 kPremul_SkAlphaType, cap.fSRGB ? srgbCo lorSpace : nullptr); 179 kPremul_SkAlphaType, cap.fSRGB ? srgbCo lorSpace : nullptr);
181 uint32_t flags = cap.fGammaCorrect ? SkSurfaceProps::kGammaCorrect_Flag : 0; 180 return SkSurface::MakeRaster(info).release();
182 SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType);
183 return SkSurface::MakeRaster(info, &props).release();
184 } 181 }
185 182
186 SkSurface* Request::createGPUSurface() { 183 SkSurface* Request::createGPUSurface() {
187 GrContext* context = this->getContext(); 184 GrContext* context = this->getContext();
188 SkIRect bounds = this->getBounds(); 185 SkIRect bounds = this->getBounds();
189 ColorAndProfile cap = ColorModes[fColorMode]; 186 ColorAndProfile cap = ColorModes[fColorMode];
190 auto srgbColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); 187 auto srgbColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named);
191 SkImageInfo info = SkImageInfo::Make(bounds.width(), bounds.height(), cap.fC olorType, 188 SkImageInfo info = SkImageInfo::Make(bounds.width(), bounds.height(), cap.fC olorType,
192 kPremul_SkAlphaType, cap.fSRGB ? srgbCo lorSpace : nullptr); 189 kPremul_SkAlphaType, cap.fSRGB ? srgbCo lorSpace : nullptr);
193 uint32_t flags = cap.fGammaCorrect ? SkSurfaceProps::kGammaCorrect_Flag : 0; 190 SkSurface* surface = SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, i nfo).release();
194 SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType);
195 SkSurface* surface = SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, i nfo, 0,
196 &props).release();
197 return surface; 191 return surface;
198 } 192 }
199 193
200 bool Request::setColorMode(int mode) { 194 bool Request::setColorMode(int mode) {
201 fColorMode = mode; 195 fColorMode = mode;
202 return enableGPU(fGPUEnabled); 196 return enableGPU(fGPUEnabled);
203 } 197 }
204 198
205 bool Request::enableGPU(bool enable) { 199 bool Request::enableGPU(bool enable) {
206 if (enable) { 200 if (enable) {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 SkASSERT(bitmap); 294 SkASSERT(bitmap);
301 295
302 // Convert to format suitable for inspection 296 // Convert to format suitable for inspection
303 sk_sp<SkData> encodedBitmap = sk_tools::encode_bitmap_for_png(*bitmap); 297 sk_sp<SkData> encodedBitmap = sk_tools::encode_bitmap_for_png(*bitmap);
304 SkASSERT(encodedBitmap.get()); 298 SkASSERT(encodedBitmap.get());
305 299
306 const uint8_t* start = encodedBitmap->bytes() + ((y * bitmap->width() + x) * 4); 300 const uint8_t* start = encodedBitmap->bytes() + ((y * bitmap->width() + x) * 4);
307 SkColor result = SkColorSetARGB(start[3], start[0], start[1], start[2]); 301 SkColor result = SkColorSetARGB(start[3], start[0], start[1], start[2]);
308 return result; 302 return result;
309 } 303 }
OLDNEW
« no previous file with comments | « tests/SRGBMipMapTest.cpp ('k') | tools/viewer/sk_app/WindowContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698