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

Side by Side Diff: content/browser/devtools/protocol/color_picker.cc

Issue 2702093002: Consistent CopyFromSurface() API, consolidated to RWHV (Closed)
Patch Set: REBASE Created 3 years, 9 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/protocol/color_picker.h" 5 #include "content/browser/devtools/protocol/color_picker.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #include "content/browser/renderer_host/render_view_host_impl.h" 9 #include "content/browser/renderer_host/render_view_host_impl.h"
10 #include "content/browser/renderer_host/render_widget_host_view_base.h" 10 #include "content/browser/renderer_host/render_widget_host_view_base.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 } 76 }
77 77
78 void ColorPicker::UpdateFrame() { 78 void ColorPicker::UpdateFrame() {
79 if (!host_) 79 if (!host_)
80 return; 80 return;
81 RenderWidgetHostViewBase* view = 81 RenderWidgetHostViewBase* view =
82 static_cast<RenderWidgetHostViewBase*>(host_->GetView()); 82 static_cast<RenderWidgetHostViewBase*>(host_->GetView());
83 if (!view) 83 if (!view)
84 return; 84 return;
85 85
86 gfx::Size size = view->GetViewBounds().size(); 86 // TODO(miu): This is the wrong size. It's the size of the view on-screen, and
87 view->CopyFromCompositingSurface( 87 // not the rendering size of the view. The latter is what is wanted here, so
88 gfx::Rect(size), size, 88 // that the resulting bitmap's pixel coordinates line-up with the
89 base::Bind(&ColorPicker::FrameUpdated, 89 // blink::WebMouseEvent coordinates. http://crbug.com/73362
90 weak_factory_.GetWeakPtr()), 90 gfx::Size should_be_rendering_size = view->GetViewBounds().size();
91 view->CopyFromSurface(
92 gfx::Rect(), should_be_rendering_size,
93 base::Bind(&ColorPicker::FrameUpdated, weak_factory_.GetWeakPtr()),
91 kN32_SkColorType); 94 kN32_SkColorType);
92 } 95 }
93 96
94 void ColorPicker::ResetFrame() { 97 void ColorPicker::ResetFrame() {
95 frame_.reset(); 98 frame_.reset();
96 last_cursor_x_ = -1; 99 last_cursor_x_ = -1;
97 last_cursor_y_ = -1; 100 last_cursor_y_ = -1;
98 } 101 }
99 102
100 void ColorPicker::FrameUpdated(const SkBitmap& bitmap, 103 void ColorPicker::FrameUpdated(const SkBitmap& bitmap,
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 gfx::Point(kHotspotOffset * device_scale_factor, 256 gfx::Point(kHotspotOffset * device_scale_factor,
254 kHotspotOffset * device_scale_factor); 257 kHotspotOffset * device_scale_factor);
255 258
256 cursor.InitFromCursorInfo(cursor_info); 259 cursor.InitFromCursorInfo(cursor_info);
257 DCHECK(host_); 260 DCHECK(host_);
258 host_->SetCursor(cursor); 261 host_->SetCursor(cursor);
259 } 262 }
260 263
261 } // namespace protocol 264 } // namespace protocol
262 } // namespace content 265 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/devtools/protocol/color_picker.h ('k') | content/browser/devtools/protocol/page_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698