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

Side by Side Diff: content/browser/devtools/devtools_frame_trace_recorder.cc

Issue 1980673003: DevTools: fix screenshot size when emulated viewport is smaller than root view (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: simplified area calculation Created 4 years, 7 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
« 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) 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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 84
85 void CaptureFrame(RenderFrameHostImpl* host, 85 void CaptureFrame(RenderFrameHostImpl* host,
86 const cc::CompositorFrameMetadata& metadata) { 86 const cc::CompositorFrameMetadata& metadata) {
87 RenderWidgetHostViewBase* view = 87 RenderWidgetHostViewBase* view =
88 static_cast<RenderWidgetHostViewBase*>(host->GetView()); 88 static_cast<RenderWidgetHostViewBase*>(host->GetView());
89 if (!view) 89 if (!view)
90 return; 90 return;
91 int current_frame_count = base::subtle::NoBarrier_Load(&frame_data_count); 91 int current_frame_count = base::subtle::NoBarrier_Load(&frame_data_count);
92 if (current_frame_count >= kMaximumFrameDataCount) 92 if (current_frame_count >= kMaximumFrameDataCount)
93 return; 93 return;
94
94 float scale = metadata.page_scale_factor; 95 float scale = metadata.page_scale_factor;
95 float area = metadata.scrollable_viewport_size.GetArea(); 96 gfx::Size src_size = gfx::ToCeiledSize(gfx::ScaleSize(
96 if (area * scale * scale > kFrameAreaLimit) 97 metadata.scrollable_viewport_size, scale));
98 float area = src_size.GetArea();
99 if (area > kFrameAreaLimit)
97 scale = sqrt(kFrameAreaLimit / area); 100 scale = sqrt(kFrameAreaLimit / area);
98 gfx::Size snapshot_size(gfx::ToRoundedSize(gfx::ScaleSize( 101 gfx::Size snapshot_size(gfx::ToRoundedSize(gfx::ScaleSize(
dgozman 2016/05/13 22:55:41 Looks to be equal to src_size, let's reuse it.
99 metadata.scrollable_viewport_size, scale))); 102 metadata.scrollable_viewport_size, scale)));
100 view->CopyFromCompositingSurface( 103 view->CopyFromCompositingSurface(
101 gfx::Rect(), snapshot_size, 104 gfx::Rect(gfx::Point(), src_size), snapshot_size,
102 base::Bind(FrameCaptured, base::TimeTicks::Now()), 105 base::Bind(FrameCaptured, base::TimeTicks::Now()),
103 kN32_SkColorType); 106 kN32_SkColorType);
104 } 107 }
105 108
106 bool ScreenshotCategoryEnabled() { 109 bool ScreenshotCategoryEnabled() {
107 bool enabled; 110 bool enabled;
108 TRACE_EVENT_CATEGORY_GROUP_ENABLED( 111 TRACE_EVENT_CATEGORY_GROUP_ENABLED(
109 TRACE_DISABLED_BY_DEFAULT("devtools.screenshot"), &enabled); 112 TRACE_DISABLED_BY_DEFAULT("devtools.screenshot"), &enabled);
110 return enabled; 113 return enabled;
111 } 114 }
(...skipping 21 matching lines...) Expand all
133 } 136 }
134 137
135 bool is_new_trace; 138 bool is_new_trace;
136 TRACE_EVENT_IS_NEW_TRACE(&is_new_trace); 139 TRACE_EVENT_IS_NEW_TRACE(&is_new_trace);
137 if (!is_new_trace && last_metadata_) 140 if (!is_new_trace && last_metadata_)
138 CaptureFrame(host, *last_metadata_); 141 CaptureFrame(host, *last_metadata_);
139 last_metadata_.reset(new cc::CompositorFrameMetadata(frame_metadata)); 142 last_metadata_.reset(new cc::CompositorFrameMetadata(frame_metadata));
140 } 143 }
141 144
142 } // namespace content 145 } // 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