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

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

Issue 296493003: [Android WebView] Fix DevTools Screencast slowness (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: PS5 + changed discussed off-line Created 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "content/browser/devtools/renderer_overrides_handler.h" 5 #include "content/browser/devtools/renderer_overrides_handler.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/barrier_closure.h" 10 #include "base/barrier_closure.h"
(...skipping 25 matching lines...) Expand all
36 #include "content/public/browser/web_contents.h" 36 #include "content/public/browser/web_contents.h"
37 #include "content/public/browser/web_contents_delegate.h" 37 #include "content/public/browser/web_contents_delegate.h"
38 #include "content/public/common/content_client.h" 38 #include "content/public/common/content_client.h"
39 #include "content/public/common/page_transition_types.h" 39 #include "content/public/common/page_transition_types.h"
40 #include "content/public/common/referrer.h" 40 #include "content/public/common/referrer.h"
41 #include "ipc/ipc_sender.h" 41 #include "ipc/ipc_sender.h"
42 #include "net/base/net_util.h" 42 #include "net/base/net_util.h"
43 #include "third_party/WebKit/public/web/WebInputEvent.h" 43 #include "third_party/WebKit/public/web/WebInputEvent.h"
44 #include "ui/gfx/codec/jpeg_codec.h" 44 #include "ui/gfx/codec/jpeg_codec.h"
45 #include "ui/gfx/codec/png_codec.h" 45 #include "ui/gfx/codec/png_codec.h"
46 #include "ui/gfx/display.h"
47 #include "ui/gfx/screen.h"
46 #include "ui/gfx/size_conversions.h" 48 #include "ui/gfx/size_conversions.h"
47 #include "ui/snapshot/snapshot.h" 49 #include "ui/snapshot/snapshot.h"
48 #include "url/gurl.h" 50 #include "url/gurl.h"
49 #include "webkit/browser/quota/quota_manager.h" 51 #include "webkit/browser/quota/quota_manager.h"
50 52
51 using blink::WebGestureEvent; 53 using blink::WebGestureEvent;
52 using blink::WebInputEvent; 54 using blink::WebInputEvent;
53 using blink::WebMouseEvent; 55 using blink::WebMouseEvent;
54 56
55 namespace content { 57 namespace content {
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 RenderViewHost* host = agent_->GetRenderViewHost(); 199 RenderViewHost* host = agent_->GetRenderViewHost();
198 if (!host->GetView()) 200 if (!host->GetView())
199 return; 201 return;
200 202
201 last_frame_time_ = base::TimeTicks::Now(); 203 last_frame_time_ = base::TimeTicks::Now();
202 std::string format; 204 std::string format;
203 int quality = kDefaultScreenshotQuality; 205 int quality = kDefaultScreenshotQuality;
204 double scale = 1; 206 double scale = 1;
205 ParseCaptureParameters(screencast_command_.get(), &format, &quality, &scale); 207 ParseCaptureParameters(screencast_command_.get(), &format, &quality, &scale);
206 208
209 const gfx::Display& display =
210 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay();
211 float device_scale_factor = display.device_scale_factor();
212
213 gfx::Rect view_bounds = host->GetView()->GetViewBounds();
214 gfx::Size snapshot_size(gfx::ToCeiledSize(
215 gfx::ScaleSize(view_bounds.size(), scale / device_scale_factor)));
216
207 RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>( 217 RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>(
208 host->GetView()); 218 host->GetView());
209
210 gfx::Rect view_bounds = host->GetView()->GetViewBounds();
211 gfx::Size snapshot_size = gfx::ToFlooredSize(
212 gfx::ScaleSize(view_bounds.size(), scale));
213
214 view->CopyFromCompositingSurface( 219 view->CopyFromCompositingSurface(
215 view_bounds, snapshot_size, 220 view_bounds, snapshot_size,
216 base::Bind(&RendererOverridesHandler::ScreencastFrameCaptured, 221 base::Bind(&RendererOverridesHandler::ScreencastFrameCaptured,
217 weak_factory_.GetWeakPtr(), 222 weak_factory_.GetWeakPtr(),
218 format, quality, last_compositor_frame_metadata_), 223 format, quality, last_compositor_frame_metadata_),
219 SkBitmap::kARGB_8888_Config); 224 SkBitmap::kARGB_8888_Config);
220 } 225 }
221 226
222 void RendererOverridesHandler::ParseCaptureParameters( 227 void RendererOverridesHandler::ParseCaptureParameters(
223 DevToolsProtocol::Command* command, 228 DevToolsProtocol::Command* command,
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 return NULL; 998 return NULL;
994 } 999 }
995 event.data.pinchUpdate.scale = static_cast<float>(scale); 1000 event.data.pinchUpdate.scale = static_cast<float>(scale);
996 } 1001 }
997 1002
998 host->ForwardGestureEvent(event); 1003 host->ForwardGestureEvent(event);
999 return command->SuccessResponse(NULL); 1004 return command->SuccessResponse(NULL);
1000 } 1005 }
1001 1006
1002 } // namespace content 1007 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/compositor/delegated_frame_host.cc ('k') | content/browser/renderer_host/render_widget_host_view_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698