OLD | NEW |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #include "content/browser/devtools/devtools_frame_trace_recorder.h" | 5 #include "content/browser/devtools/devtools_frame_trace_recorder.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/atomicops.h" | 10 #include "base/atomicops.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 } | 57 } |
58 | 58 |
59 private: | 59 private: |
60 ~TraceableDevToolsScreenshot() override { | 60 ~TraceableDevToolsScreenshot() override { |
61 base::subtle::NoBarrier_AtomicIncrement(&frame_data_count, -1); | 61 base::subtle::NoBarrier_AtomicIncrement(&frame_data_count, -1); |
62 } | 62 } |
63 | 63 |
64 SkBitmap frame_; | 64 SkBitmap frame_; |
65 }; | 65 }; |
66 | 66 |
67 void FrameCaptured(base::TraceTicks timestamp, const SkBitmap& bitmap, | 67 void FrameCaptured(base::TimeTicks timestamp, const SkBitmap& bitmap, |
68 ReadbackResponse response) { | 68 ReadbackResponse response) { |
69 if (response != READBACK_SUCCESS) | 69 if (response != READBACK_SUCCESS) |
70 return; | 70 return; |
71 int current_frame_count = base::subtle::NoBarrier_Load(&frame_data_count); | 71 int current_frame_count = base::subtle::NoBarrier_Load(&frame_data_count); |
72 if (current_frame_count >= kMaximumFrameDataCount) | 72 if (current_frame_count >= kMaximumFrameDataCount) |
73 return; | 73 return; |
74 if (bitmap.drawsNothing()) | 74 if (bitmap.drawsNothing()) |
75 return; | 75 return; |
76 base::subtle::NoBarrier_AtomicIncrement(&frame_data_count, 1); | 76 base::subtle::NoBarrier_AtomicIncrement(&frame_data_count, 1); |
77 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID_AND_TIMESTAMP( | 77 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID_AND_TIMESTAMP( |
(...skipping 13 matching lines...) Expand all Loading... |
91 if (current_frame_count >= kMaximumFrameDataCount) | 91 if (current_frame_count >= kMaximumFrameDataCount) |
92 return; | 92 return; |
93 float scale = metadata.page_scale_factor; | 93 float scale = metadata.page_scale_factor; |
94 float area = metadata.scrollable_viewport_size.GetArea(); | 94 float area = metadata.scrollable_viewport_size.GetArea(); |
95 if (area * scale * scale > kFrameAreaLimit) | 95 if (area * scale * scale > kFrameAreaLimit) |
96 scale = sqrt(kFrameAreaLimit / area); | 96 scale = sqrt(kFrameAreaLimit / area); |
97 gfx::Size snapshot_size(gfx::ToRoundedSize(gfx::ScaleSize( | 97 gfx::Size snapshot_size(gfx::ToRoundedSize(gfx::ScaleSize( |
98 metadata.scrollable_viewport_size, scale))); | 98 metadata.scrollable_viewport_size, scale))); |
99 view->CopyFromCompositingSurface( | 99 view->CopyFromCompositingSurface( |
100 gfx::Rect(), snapshot_size, | 100 gfx::Rect(), snapshot_size, |
101 base::Bind(FrameCaptured, base::TraceTicks::Now()), | 101 base::Bind(FrameCaptured, base::TimeTicks::Now()), |
102 kN32_SkColorType); | 102 kN32_SkColorType); |
103 } | 103 } |
104 | 104 |
105 bool ScreenshotCategoryEnabled() { | 105 bool ScreenshotCategoryEnabled() { |
106 bool enabled; | 106 bool enabled; |
107 TRACE_EVENT_CATEGORY_GROUP_ENABLED( | 107 TRACE_EVENT_CATEGORY_GROUP_ENABLED( |
108 TRACE_DISABLED_BY_DEFAULT("devtools.screenshot"), &enabled); | 108 TRACE_DISABLED_BY_DEFAULT("devtools.screenshot"), &enabled); |
109 return enabled; | 109 return enabled; |
110 } | 110 } |
111 | 111 |
(...skipping 20 matching lines...) Expand all Loading... |
132 } | 132 } |
133 | 133 |
134 bool is_new_trace; | 134 bool is_new_trace; |
135 TRACE_EVENT_IS_NEW_TRACE(&is_new_trace); | 135 TRACE_EVENT_IS_NEW_TRACE(&is_new_trace); |
136 if (!is_new_trace && last_metadata_) | 136 if (!is_new_trace && last_metadata_) |
137 CaptureFrame(host, *last_metadata_); | 137 CaptureFrame(host, *last_metadata_); |
138 last_metadata_.reset(new cc::CompositorFrameMetadata(frame_metadata)); | 138 last_metadata_.reset(new cc::CompositorFrameMetadata(frame_metadata)); |
139 } | 139 } |
140 | 140 |
141 } // namespace content | 141 } // namespace content |
OLD | NEW |