OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "gpu/command_buffer/service/gpu_state_tracer.h" | 5 #include "gpu/command_buffer/service/gpu_state_tracer.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/trace_event/trace_event.h" | 8 #include "base/trace_event/trace_event.h" |
9 #include "context_state.h" | 9 #include "context_state.h" |
10 #include "ui/gfx/codec/png_codec.h" | 10 #include "ui/gfx/codec/png_codec.h" |
11 #include "ui/gl/gl_bindings.h" | 11 #include "ui/gl/gl_bindings.h" |
12 | 12 |
13 namespace gpu { | 13 namespace gpu { |
14 namespace gles2 { | 14 namespace gles2 { |
15 namespace { | 15 namespace { |
16 | 16 |
17 const int kBytesPerPixel = 4; | 17 const int kBytesPerPixel = 4; |
18 | 18 |
19 class Snapshot : public base::debug::ConvertableToTraceFormat { | 19 class Snapshot : public base::trace_event::ConvertableToTraceFormat { |
20 public: | 20 public: |
21 static scoped_refptr<Snapshot> Create(const ContextState* state); | 21 static scoped_refptr<Snapshot> Create(const ContextState* state); |
22 | 22 |
23 // Save a screenshot of the currently bound framebuffer. | 23 // Save a screenshot of the currently bound framebuffer. |
24 bool SaveScreenshot(const gfx::Size& size); | 24 bool SaveScreenshot(const gfx::Size& size); |
25 | 25 |
26 // base::debug::ConvertableToTraceFormat implementation. | 26 // base::trace_event::ConvertableToTraceFormat implementation. |
27 void AppendAsTraceFormat(std::string* out) const override; | 27 void AppendAsTraceFormat(std::string* out) const override; |
28 | 28 |
29 private: | 29 private: |
30 explicit Snapshot(const ContextState* state); | 30 explicit Snapshot(const ContextState* state); |
31 ~Snapshot() override {} | 31 ~Snapshot() override {} |
32 | 32 |
33 const ContextState* state_; | 33 const ContextState* state_; |
34 | 34 |
35 std::vector<unsigned char> screenshot_pixels_; | 35 std::vector<unsigned char> screenshot_pixels_; |
36 gfx::Size screenshot_size_; | 36 gfx::Size screenshot_size_; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 scoped_refptr<Snapshot> snapshot(Snapshot::Create(state_)); | 118 scoped_refptr<Snapshot> snapshot(Snapshot::Create(state_)); |
119 | 119 |
120 // Only save a screenshot for now. | 120 // Only save a screenshot for now. |
121 if (!snapshot->SaveScreenshot(size)) | 121 if (!snapshot->SaveScreenshot(size)) |
122 return; | 122 return; |
123 | 123 |
124 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID( | 124 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID( |
125 TRACE_DISABLED_BY_DEFAULT("gpu.debug"), | 125 TRACE_DISABLED_BY_DEFAULT("gpu.debug"), |
126 "gpu::State", | 126 "gpu::State", |
127 state_, | 127 state_, |
128 scoped_refptr<base::debug::ConvertableToTraceFormat>(snapshot)); | 128 scoped_refptr<base::trace_event::ConvertableToTraceFormat>(snapshot)); |
129 } | 129 } |
130 | 130 |
131 } // namespace gles2 | 131 } // namespace gles2 |
132 } // namespace gpu | 132 } // namespace gpu |
OLD | NEW |