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

Side by Side Diff: third_party/WebKit/Source/platform/testing/ImageDecodeBench.cpp

Issue 2609093002: Revert of Use consistent types for ICC profiles (Closed)
Patch Set: Created 3 years, 11 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Provides a minimal wrapping of the Blink image decoders. Used to perform 5 // Provides a minimal wrapping of the Blink image decoders. Used to perform
6 // a non-threaded, memory-to-memory image decode using micro second accuracy 6 // a non-threaded, memory-to-memory image decode using micro second accuracy
7 // clocks to measure image decode time. Optionally applies color correction 7 // clocks to measure image decode time. Optionally applies color correction
8 // during image decoding on supported platforms (default off). Usage: 8 // during image decoding on supported platforms (default off). Usage:
9 // 9 //
10 // % ninja -C out/Release image_decode_bench && 10 // % ninja -C out/Release image_decode_bench &&
11 // ./out/Release/image_decode_bench file [iterations] 11 // ./out/Release/image_decode_bench file [iterations]
12 // 12 //
13 // TODO(noel): Consider adding md5 checksum support to WTF. Use it to compute 13 // TODO(noel): Consider adding md5 checksum support to WTF. Use it to compute
14 // the decoded image frame md5 and output that value. 14 // the decoded image frame md5 and output that value.
15 // 15 //
16 // TODO(noel): Consider integrating this tool in Chrome telemetry for realz, 16 // TODO(noel): Consider integrating this tool in Chrome telemetry for realz,
17 // using the image corpii used to assess Blink image decode performance. Refer 17 // using the image corpii used to assess Blink image decode performance. Refer
18 // to http://crbug.com/398235#c103 and http://crbug.com/258324#c5 18 // to http://crbug.com/398235#c103 and http://crbug.com/258324#c5
19 19
20 #include "base/command_line.h" 20 #include "base/command_line.h"
21 #include "platform/SharedBuffer.h" 21 #include "platform/SharedBuffer.h"
22 #include "platform/image-decoders/ImageDecoder.h" 22 #include "platform/image-decoders/ImageDecoder.h"
23 #include "public/platform/Platform.h" 23 #include "public/platform/Platform.h"
24 #include "ui/gfx/test/icc_profiles.h"
25 #include "wtf/PassRefPtr.h" 24 #include "wtf/PassRefPtr.h"
26 #include "wtf/PtrUtil.h" 25 #include "wtf/PtrUtil.h"
27 #include <memory> 26 #include <memory>
28 27
29 #if defined(_WIN32) 28 #if defined(_WIN32)
30 #include <mmsystem.h> 29 #include <mmsystem.h>
31 #include <sys/stat.h> 30 #include <sys/stat.h>
32 #include <time.h> 31 #include <time.h>
33 #define stat(x, y) _stat(x, y) 32 #define stat(x, y) _stat(x, y)
34 typedef struct _stat sttype; 33 typedef struct _stat sttype;
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 #else 168 #else
170 169
171 static double getCurrentTime() { 170 static double getCurrentTime() {
172 struct timeval now; 171 struct timeval now;
173 gettimeofday(&now, 0); 172 gettimeofday(&now, 0);
174 return now.tv_sec + now.tv_usec * (1.0 / 1000000.0); 173 return now.tv_sec + now.tv_usec * (1.0 / 1000000.0);
175 } 174 }
176 175
177 #endif 176 #endif
178 177
178 void getScreenColorProfile(WebVector<char>* profile) {
179 static unsigned char profileData[] = {
180 0x00, 0x00, 0x01, 0xea, 0x54, 0x45, 0x53, 0x54, 0x00, 0x00, 0x00, 0x00,
181 0x6d, 0x6e, 0x74, 0x72, 0x52, 0x47, 0x42, 0x20, 0x58, 0x59, 0x5a, 0x20,
182 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
183 0x61, 0x63, 0x73, 0x70, 0x74, 0x65, 0x73, 0x74, 0x00, 0x00, 0x00, 0x00,
184 0x74, 0x65, 0x73, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
185 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf6, 0xd6,
186 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xd3, 0x2d, 0x74, 0x65, 0x73, 0x74,
187 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
188 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
189 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
190 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09,
191 0x63, 0x70, 0x72, 0x74, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x0d,
192 0x64, 0x65, 0x73, 0x63, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x8c,
193 0x77, 0x74, 0x70, 0x74, 0x00, 0x00, 0x01, 0x8c, 0x00, 0x00, 0x00, 0x14,
194 0x72, 0x58, 0x59, 0x5a, 0x00, 0x00, 0x01, 0xa0, 0x00, 0x00, 0x00, 0x14,
195 0x67, 0x58, 0x59, 0x5a, 0x00, 0x00, 0x01, 0xb4, 0x00, 0x00, 0x00, 0x14,
196 0x62, 0x58, 0x59, 0x5a, 0x00, 0x00, 0x01, 0xc8, 0x00, 0x00, 0x00, 0x14,
197 0x72, 0x54, 0x52, 0x43, 0x00, 0x00, 0x01, 0xdc, 0x00, 0x00, 0x00, 0x0e,
198 0x67, 0x54, 0x52, 0x43, 0x00, 0x00, 0x01, 0xdc, 0x00, 0x00, 0x00, 0x0e,
199 0x62, 0x54, 0x52, 0x43, 0x00, 0x00, 0x01, 0xdc, 0x00, 0x00, 0x00, 0x0e,
200 0x74, 0x65, 0x78, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
201 0x00, 0x00, 0x00, 0x00, 0x64, 0x65, 0x73, 0x63, 0x00, 0x00, 0x00, 0x00,
202 0x00, 0x00, 0x00, 0x10, 0x77, 0x68, 0x61, 0x63, 0x6b, 0x65, 0x64, 0x2e,
203 0x69, 0x63, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
204 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
205 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
206 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
207 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
208 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
209 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
210 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
211 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
212 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
213 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf3, 0x52,
214 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x16, 0xcc, 0x58, 0x59, 0x5a, 0x20,
215 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x8d, 0x00, 0x00, 0xa0, 0x2c,
216 0x00, 0x00, 0x0f, 0x95, 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00,
217 0x00, 0x00, 0x26, 0x31, 0x00, 0x00, 0x10, 0x2f, 0x00, 0x00, 0xbe, 0x9b,
218 0x58, 0x59, 0x5a, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9c, 0x18,
219 0x00, 0x00, 0x4f, 0xa5, 0x00, 0x00, 0x04, 0xfc, 0x63, 0x75, 0x72, 0x76,
220 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x33};
221
222 static struct WhackedColorProfile {
223 char* data() { return reinterpret_cast<char*>(profileData); }
224
225 const size_t profileSize = 490u;
226
227 size_t size() { return profileSize; }
228
229 } screenProfile;
230
231 profile->assign(screenProfile.data(), screenProfile.size());
232 }
233
179 PassRefPtr<SharedBuffer> readFile(const char* fileName) { 234 PassRefPtr<SharedBuffer> readFile(const char* fileName) {
180 FILE* fp = fopen(fileName, "rb"); 235 FILE* fp = fopen(fileName, "rb");
181 if (!fp) { 236 if (!fp) {
182 fprintf(stderr, "Can't open file %s\n", fileName); 237 fprintf(stderr, "Can't open file %s\n", fileName);
183 exit(2); 238 exit(2);
184 } 239 }
185 240
186 sttype s; 241 sttype s;
187 stat(fileName, &s); 242 stat(fileName, &s);
188 size_t fileSize = s.st_size; 243 size_t fileSize = s.st_size;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 303
249 int main(int argc, char* argv[]) { 304 int main(int argc, char* argv[]) {
250 base::CommandLine::Init(argc, argv); 305 base::CommandLine::Init(argc, argv);
251 306
252 // If the platform supports color correction, allow it to be controlled. 307 // If the platform supports color correction, allow it to be controlled.
253 308
254 bool applyColorCorrection = false; 309 bool applyColorCorrection = false;
255 310
256 if (argc >= 2 && strcmp(argv[1], "--color-correct") == 0) { 311 if (argc >= 2 && strcmp(argv[1], "--color-correct") == 0) {
257 applyColorCorrection = (--argc, ++argv, true); 312 applyColorCorrection = (--argc, ++argv, true);
258 gfx::ICCProfile iccProfile = gfx::ICCProfileForTestingColorSpin(); 313 WebVector<char> profile;
259 ColorBehavior::setGlobalTargetColorSpace( 314 getScreenColorProfile(&profile); // Returns a color spin color profile.
260 iccProfile.GetColorSpace().ToSkColorSpace()); 315 ColorBehavior::setGlobalTargetColorProfile(profile);
261 } 316 }
262 317
263 if (argc < 2) { 318 if (argc < 2) {
264 fprintf(stderr, 319 fprintf(stderr,
265 "Usage: %s [--color-correct] file [iterations] [packetSize]\n", 320 "Usage: %s [--color-correct] file [iterations] [packetSize]\n",
266 argv[0]); 321 argv[0]);
267 exit(1); 322 exit(1);
268 } 323 }
269 324
270 // Control decode bench iterations and packet size. 325 // Control decode bench iterations and packet size.
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 exit(3); 391 exit(3);
337 } 392 }
338 } 393 }
339 394
340 // Results to stdout. 395 // Results to stdout.
341 396
342 double averageTime = totalTime / static_cast<double>(iterations); 397 double averageTime = totalTime / static_cast<double>(iterations);
343 printf("%f %f\n", totalTime, averageTime); 398 printf("%f %f\n", totalTime, averageTime);
344 return 0; 399 return 0;
345 } 400 }
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/ColorBehavior.cpp ('k') | third_party/WebKit/Source/web/WebViewImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698