OLD | NEW |
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" |
11 #include "SkPixelSerializer.h" | 11 #include "SkPixelSerializer.h" |
| 12 #include "SkPM4fPriv.h" |
12 #include "picture_utils.h" | 13 #include "picture_utils.h" |
13 | 14 |
14 using namespace sk_gpu_test; | 15 using namespace sk_gpu_test; |
15 | 16 |
16 static int kDefaultWidth = 1920; | 17 static int kDefaultWidth = 1920; |
17 static int kDefaultHeight = 1080; | 18 static int kDefaultHeight = 1080; |
18 | 19 |
19 | 20 |
20 Request::Request(SkString rootUrl) | 21 Request::Request(SkString rootUrl) |
21 : fUploadContext(nullptr) | 22 : fUploadContext(nullptr) |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 SkSurface* surface = SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, i
nfo, 0, | 180 SkSurface* surface = SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, i
nfo, 0, |
180 &props).release(); | 181 &props).release(); |
181 return surface; | 182 return surface; |
182 } | 183 } |
183 | 184 |
184 bool Request::setColorMode(int mode) { | 185 bool Request::setColorMode(int mode) { |
185 fColorMode = mode; | 186 fColorMode = mode; |
186 return enableGPU(fGPUEnabled); | 187 return enableGPU(fGPUEnabled); |
187 } | 188 } |
188 | 189 |
| 190 bool Request::setSRGBMode(bool enable) { |
| 191 gTreatSkColorAsSRGB = enable; |
| 192 return true; |
| 193 } |
| 194 |
189 bool Request::enableGPU(bool enable) { | 195 bool Request::enableGPU(bool enable) { |
190 if (enable) { | 196 if (enable) { |
191 SkSurface* surface = this->createGPUSurface(); | 197 SkSurface* surface = this->createGPUSurface(); |
192 if (surface) { | 198 if (surface) { |
193 fSurface.reset(surface); | 199 fSurface.reset(surface); |
194 fGPUEnabled = true; | 200 fGPUEnabled = true; |
195 | 201 |
196 // When we switch to GPU, there seems to be some mystery draws in th
e canvas. So we | 202 // When we switch to GPU, there seems to be some mystery draws in th
e canvas. So we |
197 // draw once to flush the pipe | 203 // draw once to flush the pipe |
198 // TODO understand what is actually happening here | 204 // TODO understand what is actually happening here |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 this->getCanvas()->flush(); | 237 this->getCanvas()->flush(); |
232 return true; | 238 return true; |
233 } | 239 } |
234 | 240 |
235 SkData* Request::getJsonOps(int n) { | 241 SkData* Request::getJsonOps(int n) { |
236 SkCanvas* canvas = this->getCanvas(); | 242 SkCanvas* canvas = this->getCanvas(); |
237 Json::Value root = fDebugCanvas->toJSON(fUrlDataManager, n, canvas); | 243 Json::Value root = fDebugCanvas->toJSON(fUrlDataManager, n, canvas); |
238 root["mode"] = Json::Value(fGPUEnabled ? "gpu" : "cpu"); | 244 root["mode"] = Json::Value(fGPUEnabled ? "gpu" : "cpu"); |
239 root["drawGpuBatchBounds"] = Json::Value(fDebugCanvas->getDrawGpuBatchBounds
()); | 245 root["drawGpuBatchBounds"] = Json::Value(fDebugCanvas->getDrawGpuBatchBounds
()); |
240 root["colorMode"] = Json::Value(fColorMode); | 246 root["colorMode"] = Json::Value(fColorMode); |
| 247 root["srgbMode"] = Json::Value(gTreatSkColorAsSRGB); |
241 SkDynamicMemoryWStream stream; | 248 SkDynamicMemoryWStream stream; |
242 stream.writeText(Json::FastWriter().write(root).c_str()); | 249 stream.writeText(Json::FastWriter().write(root).c_str()); |
243 | 250 |
244 return stream.copyToData(); | 251 return stream.copyToData(); |
245 } | 252 } |
246 | 253 |
247 SkData* Request::getJsonBatchList(int n) { | 254 SkData* Request::getJsonBatchList(int n) { |
248 SkCanvas* canvas = this->getCanvas(); | 255 SkCanvas* canvas = this->getCanvas(); |
249 SkASSERT(fGPUEnabled); | 256 SkASSERT(fGPUEnabled); |
250 | 257 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 SkASSERT(bitmap); | 291 SkASSERT(bitmap); |
285 | 292 |
286 // Convert to format suitable for inspection | 293 // Convert to format suitable for inspection |
287 sk_sp<SkData> encodedBitmap = sk_tools::encode_bitmap_for_png(*bitmap); | 294 sk_sp<SkData> encodedBitmap = sk_tools::encode_bitmap_for_png(*bitmap); |
288 SkASSERT(encodedBitmap.get()); | 295 SkASSERT(encodedBitmap.get()); |
289 | 296 |
290 const uint8_t* start = encodedBitmap->bytes() + ((y * bitmap->width() + x) *
4); | 297 const uint8_t* start = encodedBitmap->bytes() + ((y * bitmap->width() + x) *
4); |
291 SkColor result = SkColorSetARGB(start[3], start[0], start[1], start[2]); | 298 SkColor result = SkColorSetARGB(start[3], start[0], start[1], start[2]); |
292 return result; | 299 return result; |
293 } | 300 } |
OLD | NEW |