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

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

Issue 2072813002: Revert of Lots of progress switching to SkColorSpace rather than SkColorProfileType (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 bool fSRGB; 162 SkColorProfileType fProfileType;
163 bool fGammaCorrect; 163 bool fGammaCorrect;
164 }; 164 };
165 165
166 ColorAndProfile ColorModes[] = { 166 ColorAndProfile ColorModes[] = {
167 { kN32_SkColorType, false, false }, 167 { kN32_SkColorType, kLinear_SkColorProfileType, false },
168 { kN32_SkColorType, true, true }, 168 { kN32_SkColorType, kSRGB_SkColorProfileType, true },
169 { kRGBA_F16_SkColorType, false, true }, 169 { kRGBA_F16_SkColorType, kLinear_SkColorProfileType, 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);
178 SkImageInfo info = SkImageInfo::Make(bounds.width(), bounds.height(), cap.fC olorType, 177 SkImageInfo info = SkImageInfo::Make(bounds.width(), bounds.height(), cap.fC olorType,
179 kPremul_SkAlphaType, cap.fSRGB ? srgbCo lorSpace : nullptr); 178 kPremul_SkAlphaType, cap.fProfileType);
180 uint32_t flags = cap.fGammaCorrect ? SkSurfaceProps::kGammaCorrect_Flag : 0; 179 uint32_t flags = cap.fGammaCorrect ? SkSurfaceProps::kGammaCorrect_Flag : 0;
181 SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType); 180 SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType);
182 return SkSurface::MakeRaster(info, &props).release(); 181 return SkSurface::MakeRaster(info, &props).release();
183 } 182 }
184 183
185 SkSurface* Request::createGPUSurface() { 184 SkSurface* Request::createGPUSurface() {
186 GrContext* context = this->getContext(); 185 GrContext* context = this->getContext();
187 SkIRect bounds = this->getBounds(); 186 SkIRect bounds = this->getBounds();
188 ColorAndProfile cap = ColorModes[fColorMode]; 187 ColorAndProfile cap = ColorModes[fColorMode];
189 auto srgbColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named);
190 SkImageInfo info = SkImageInfo::Make(bounds.width(), bounds.height(), cap.fC olorType, 188 SkImageInfo info = SkImageInfo::Make(bounds.width(), bounds.height(), cap.fC olorType,
191 kPremul_SkAlphaType, cap.fSRGB ? srgbCo lorSpace : nullptr); 189 kPremul_SkAlphaType, cap.fProfileType);
192 uint32_t flags = cap.fGammaCorrect ? SkSurfaceProps::kGammaCorrect_Flag : 0; 190 uint32_t flags = cap.fGammaCorrect ? SkSurfaceProps::kGammaCorrect_Flag : 0;
193 SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType); 191 SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType);
194 SkSurface* surface = SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, i nfo, 0, 192 SkSurface* surface = SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, i nfo, 0,
195 &props).release(); 193 &props).release();
196 return surface; 194 return surface;
197 } 195 }
198 196
199 bool Request::setColorMode(int mode) { 197 bool Request::setColorMode(int mode) {
200 fColorMode = mode; 198 fColorMode = mode;
201 return enableGPU(fGPUEnabled); 199 return enableGPU(fGPUEnabled);
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 SkASSERT(bitmap); 303 SkASSERT(bitmap);
306 304
307 // Convert to format suitable for inspection 305 // Convert to format suitable for inspection
308 sk_sp<SkData> encodedBitmap = sk_tools::encode_bitmap_for_png(*bitmap); 306 sk_sp<SkData> encodedBitmap = sk_tools::encode_bitmap_for_png(*bitmap);
309 SkASSERT(encodedBitmap.get()); 307 SkASSERT(encodedBitmap.get());
310 308
311 const uint8_t* start = encodedBitmap->bytes() + ((y * bitmap->width() + x) * 4); 309 const uint8_t* start = encodedBitmap->bytes() + ((y * bitmap->width() + x) * 4);
312 SkColor result = SkColorSetARGB(start[3], start[0], start[1], start[2]); 310 SkColor result = SkColorSetARGB(start[3], start[0], start[1], start[2]);
313 return result; 311 return result;
314 } 312 }
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