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

Side by Side Diff: content/renderer/gpu/gpu_benchmarking_extension.cc

Issue 10823129: skia expects to be initialized before it can be used. This must be done if serializing SkPicture, w… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "content/renderer/gpu/gpu_benchmarking_extension.h" 5 #include "content/renderer/gpu/gpu_benchmarking_extension.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/at_exit.h"
9 #include "base/file_path.h" 10 #include "base/file_path.h"
10 #include "base/file_util.h" 11 #include "base/file_util.h"
11 #include "base/memory/scoped_vector.h" 12 #include "base/memory/scoped_vector.h"
12 #include "base/string_number_conversions.h" 13 #include "base/string_number_conversions.h"
13 #include "content/public/renderer/render_thread.h" 14 #include "content/public/renderer/render_thread.h"
14 #include "content/renderer/all_rendering_benchmarks.h" 15 #include "content/renderer/all_rendering_benchmarks.h"
15 #include "content/renderer/render_view_impl.h" 16 #include "content/renderer/render_view_impl.h"
16 #include "content/renderer/rendering_benchmark.h" 17 #include "content/renderer/rendering_benchmark.h"
17 #include "content/renderer/rendering_benchmark_results.h" 18 #include "content/renderer/rendering_benchmark_results.h"
19 #include "third_party/skia/include/core/SkGraphics.h"
18 #include "third_party/skia/include/core/SkPicture.h" 20 #include "third_party/skia/include/core/SkPicture.h"
19 #include "third_party/skia/include/core/SkStream.h" 21 #include "third_party/skia/include/core/SkStream.h"
20 #include "third_party/WebKit/Source/Platform/chromium/public/WebRenderingStats.h " 22 #include "third_party/WebKit/Source/Platform/chromium/public/WebRenderingStats.h "
21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebViewBenchmarkSuppo rt.h" 25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebViewBenchmarkSuppo rt.h"
24 #include "v8/include/v8.h" 26 #include "v8/include/v8.h"
25 27
26 using WebKit::WebCanvas; 28 using WebKit::WebCanvas;
27 using WebKit::WebFrame; 29 using WebKit::WebFrame;
28 using WebKit::WebPrivatePtr; 30 using WebKit::WebPrivatePtr;
29 using WebKit::WebRenderingStats; 31 using WebKit::WebRenderingStats;
30 using WebKit::WebSize; 32 using WebKit::WebSize;
31 using WebKit::WebView; 33 using WebKit::WebView;
32 using WebKit::WebViewBenchmarkSupport; 34 using WebKit::WebViewBenchmarkSupport;
33 35
34 const char kGpuBenchmarkingExtensionName[] = "v8/GpuBenchmarking"; 36 const char kGpuBenchmarkingExtensionName[] = "v8/GpuBenchmarking";
35 37
36 namespace { 38 namespace {
37 39
40 void TermSkGraphics(void* /* unused */) {
41 SkGraphics::Term();
jamesr 2012/08/07 20:51:26 this doesn't appear to actually be related to SkGr
reed1 2012/08/07 21:14:52 Term() is useful if you're tracking memory leaks,
42 }
43
44 void InitSkGraphics() {
45 static bool init = false;
46 if (!init) {
jamesr 2012/08/07 20:51:26 do we only ever call this from one thread?
alokp 2012/08/08 17:24:34 Yes - added comment.
47 SkGraphics::Init();
48 base::AtExitManager::RegisterCallback(TermSkGraphics, NULL);
49 init = true;
50 }
51 }
52
38 class SkPictureRecorder : public WebViewBenchmarkSupport::PaintClient { 53 class SkPictureRecorder : public WebViewBenchmarkSupport::PaintClient {
39 public: 54 public:
40 explicit SkPictureRecorder(const FilePath& dirpath) 55 explicit SkPictureRecorder(const FilePath& dirpath)
41 : dirpath_(dirpath), 56 : dirpath_(dirpath),
42 layer_id_(0) { 57 layer_id_(0) {
58 // Let skia register known effect subclasses. This basically enables
59 // reflection on those subclasses required for picture serialization.
60 InitSkGraphics();
43 } 61 }
44 62
45 virtual WebCanvas* willPaint(const WebSize& size) { 63 virtual WebCanvas* willPaint(const WebSize& size) {
46 return picture_.beginRecording(size.width, size.height); 64 return picture_.beginRecording(size.width, size.height);
47 } 65 }
48 66
49 virtual void didPaint(WebCanvas* canvas) { 67 virtual void didPaint(WebCanvas* canvas) {
50 DCHECK(canvas == picture_.getRecordingCanvas()); 68 DCHECK(canvas == picture_.getRecordingCanvas());
51 picture_.endRecording(); 69 picture_.endRecording();
52 // Serialize picture to file. 70 // Serialize picture to file.
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 312
295 return results.results_array(); 313 return results.results_array();
296 } 314 }
297 }; 315 };
298 316
299 v8::Extension* GpuBenchmarkingExtension::Get() { 317 v8::Extension* GpuBenchmarkingExtension::Get() {
300 return new GpuBenchmarkingWrapper(); 318 return new GpuBenchmarkingWrapper();
301 } 319 }
302 320
303 } // namespace content 321 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698