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

Side by Side Diff: tools/skiaserve/Request.cpp

Issue 2069173002: Lots of progress switching to SkColorSpace rather than SkColorProfileType (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix bad assert 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 | « tools/picture_utils.cpp ('k') | tools/viewer/Viewer.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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 // TODO make this configurable 152 // TODO make this configurable
153 bounds = SkIRect::MakeWH(SkTMin(bounds.width(), kDefaultWidth), 153 bounds = SkIRect::MakeWH(SkTMin(bounds.width(), kDefaultWidth),
154 SkTMin(bounds.height(), kDefaultHeight)); 154 SkTMin(bounds.height(), kDefaultHeight));
155 return bounds; 155 return bounds;
156 } 156 }
157 157
158 namespace { 158 namespace {
159 159
160 struct ColorAndProfile { 160 struct ColorAndProfile {
161 SkColorType fColorType; 161 SkColorType fColorType;
162 SkColorProfileType fProfileType; 162 bool fSRGB;
163 bool fGammaCorrect; 163 bool fGammaCorrect;
164 }; 164 };
165 165
166 ColorAndProfile ColorModes[] = { 166 ColorAndProfile ColorModes[] = {
167 { kN32_SkColorType, kLinear_SkColorProfileType, false }, 167 { kN32_SkColorType, false, false },
168 { kN32_SkColorType, kSRGB_SkColorProfileType, true }, 168 { kN32_SkColorType, true, true },
169 { kRGBA_F16_SkColorType, kLinear_SkColorProfileType, true }, 169 { kRGBA_F16_SkColorType, false, true },
170 }; 170 };
171 171
172 } 172 }
173 173
174 SkSurface* Request::createCPUSurface() { 174 SkSurface* Request::createCPUSurface() {
175 SkIRect bounds = this->getBounds(); 175 SkIRect bounds = this->getBounds();
176 ColorAndProfile cap = ColorModes[fColorMode]; 176 ColorAndProfile cap = ColorModes[fColorMode];
177 auto srgbColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named);
177 SkImageInfo info = SkImageInfo::Make(bounds.width(), bounds.height(), cap.fC olorType, 178 SkImageInfo info = SkImageInfo::Make(bounds.width(), bounds.height(), cap.fC olorType,
178 kPremul_SkAlphaType, cap.fProfileType); 179 kPremul_SkAlphaType, cap.fSRGB ? srgbCo lorSpace : nullptr);
179 uint32_t flags = cap.fGammaCorrect ? SkSurfaceProps::kGammaCorrect_Flag : 0; 180 uint32_t flags = cap.fGammaCorrect ? SkSurfaceProps::kGammaCorrect_Flag : 0;
180 SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType); 181 SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType);
181 return SkSurface::MakeRaster(info, &props).release(); 182 return SkSurface::MakeRaster(info, &props).release();
182 } 183 }
183 184
184 SkSurface* Request::createGPUSurface() { 185 SkSurface* Request::createGPUSurface() {
185 GrContext* context = this->getContext(); 186 GrContext* context = this->getContext();
186 SkIRect bounds = this->getBounds(); 187 SkIRect bounds = this->getBounds();
187 ColorAndProfile cap = ColorModes[fColorMode]; 188 ColorAndProfile cap = ColorModes[fColorMode];
189 auto srgbColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named);
188 SkImageInfo info = SkImageInfo::Make(bounds.width(), bounds.height(), cap.fC olorType, 190 SkImageInfo info = SkImageInfo::Make(bounds.width(), bounds.height(), cap.fC olorType,
189 kPremul_SkAlphaType, cap.fProfileType); 191 kPremul_SkAlphaType, cap.fSRGB ? srgbCo lorSpace : nullptr);
190 uint32_t flags = cap.fGammaCorrect ? SkSurfaceProps::kGammaCorrect_Flag : 0; 192 uint32_t flags = cap.fGammaCorrect ? SkSurfaceProps::kGammaCorrect_Flag : 0;
191 SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType); 193 SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType);
192 SkSurface* surface = SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, i nfo, 0, 194 SkSurface* surface = SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, i nfo, 0,
193 &props).release(); 195 &props).release();
194 return surface; 196 return surface;
195 } 197 }
196 198
197 bool Request::setColorMode(int mode) { 199 bool Request::setColorMode(int mode) {
198 fColorMode = mode; 200 fColorMode = mode;
199 return enableGPU(fGPUEnabled); 201 return enableGPU(fGPUEnabled);
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 SkASSERT(bitmap); 305 SkASSERT(bitmap);
304 306
305 // Convert to format suitable for inspection 307 // Convert to format suitable for inspection
306 sk_sp<SkData> encodedBitmap = sk_tools::encode_bitmap_for_png(*bitmap); 308 sk_sp<SkData> encodedBitmap = sk_tools::encode_bitmap_for_png(*bitmap);
307 SkASSERT(encodedBitmap.get()); 309 SkASSERT(encodedBitmap.get());
308 310
309 const uint8_t* start = encodedBitmap->bytes() + ((y * bitmap->width() + x) * 4); 311 const uint8_t* start = encodedBitmap->bytes() + ((y * bitmap->width() + x) * 4);
310 SkColor result = SkColorSetARGB(start[3], start[0], start[1], start[2]); 312 SkColor result = SkColorSetARGB(start[3], start[0], start[1], start[2]);
311 return result; 313 return result;
312 } 314 }
OLDNEW
« no previous file with comments | « tools/picture_utils.cpp ('k') | tools/viewer/Viewer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698