Commit 667568d3 authored by miu@chromium.org's avatar miu@chromium.org

Fix set_area sizes for RequestCopyOfOutput, and related tests.

NOTE: This is a revival/continuation of https://codereview.chromium.org/333723004, which was started by another developer.

The cc:CopyOutputRequest object assumes the src_subrect region is
in DIP space.  Thus, all calling code should provide the same.

Fixed tests in render_widget_host_view_browsertest.cc that were
completing successfully, even though the implementation was broken
for the high DPI scenarios.

In addition, I updated a number of interface comments to clarify the
difference between src_subrect being in DIP coordinates versus the
dest_size being in physical pixel coordinates.

Dependent on: https://codereview.chromium.org/311253004 (landed at r276139)

BUG=397708,399349

Review URL: https://codereview.chromium.org/462173002

Cr-Commit-Position: refs/heads/master@{#289509}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@289509 0039d316-1c4b-4281-b951-d872f2087c98
parent 183e1b95
...@@ -183,9 +183,7 @@ void DelegatedFrameHost::CopyFromCompositingSurfaceToVideoFrame( ...@@ -183,9 +183,7 @@ void DelegatedFrameHost::CopyFromCompositingSurfaceToVideoFrame(
subscriber_texture, subscriber_texture,
target, target,
callback)); callback));
gfx::Rect src_subrect_in_pixel = request->set_area(src_subrect);
ConvertRectToPixel(client_->CurrentDeviceScaleFactor(), src_subrect);
request->set_area(src_subrect_in_pixel);
if (subscriber_texture.get()) { if (subscriber_texture.get()) {
request->SetTextureMailbox( request->SetTextureMailbox(
cc::TextureMailbox(subscriber_texture->mailbox(), cc::TextureMailbox(subscriber_texture->mailbox(),
......
...@@ -278,10 +278,8 @@ void DesktopVideoCaptureMachine::Capture(bool dirty) { ...@@ -278,10 +278,8 @@ void DesktopVideoCaptureMachine::Capture(bool dirty) {
cc::CopyOutputRequest::CreateRequest( cc::CopyOutputRequest::CreateRequest(
base::Bind(&DesktopVideoCaptureMachine::DidCopyOutput, base::Bind(&DesktopVideoCaptureMachine::DidCopyOutput,
AsWeakPtr(), frame, start_time, capture_frame_cb)); AsWeakPtr(), frame, start_time, capture_frame_cb));
gfx::Rect window_rect = gfx::Rect window_rect = gfx::Rect(desktop_window_->bounds().width(),
ui::ConvertRectToPixel(desktop_window_->layer(), desktop_window_->bounds().height());
gfx::Rect(desktop_window_->bounds().width(),
desktop_window_->bounds().height()));
request->set_area(window_rect); request->set_area(window_rect);
desktop_window_->layer()->RequestCopyOfOutput(request.Pass()); desktop_window_->layer()->RequestCopyOfOutput(request.Pass());
} }
......
...@@ -243,27 +243,27 @@ class CONTENT_EXPORT RenderWidgetHostViewBase : public RenderWidgetHostView, ...@@ -243,27 +243,27 @@ class CONTENT_EXPORT RenderWidgetHostViewBase : public RenderWidgetHostView,
// Notifies the view that the scroll offset has changed. // Notifies the view that the scroll offset has changed.
virtual void ScrollOffsetChanged() = 0; virtual void ScrollOffsetChanged() = 0;
// Copies the contents of the compositing surface into the given // Copies the contents of the compositing surface, providing a new SkBitmap
// (uninitialized) PlatformCanvas if any. // result via an asynchronously-run |callback|. |src_subrect| is specified in
// The rectangle region specified with |src_subrect| is copied from the // layer space coordinates for the current platform (e.g., DIP for Aura/Mac,
// contents, scaled to |dst_size|, and written to |output|. // physical for Android), and is the region to be copied from this view. The
// |callback| is invoked with true on success, false otherwise. |output| can // copy is then scaled to a SkBitmap of size |dst_size|. |callback| is run
// be initialized even on failure. // with true on success, false otherwise. A smaller region than |src_subrect|
// A smaller region than |src_subrect| may be copied if the underlying surface // may be copied if the underlying surface is smaller than |src_subrect|.
// is smaller than |src_subrect|.
// NOTE: |callback| is called asynchronously.
virtual void CopyFromCompositingSurface( virtual void CopyFromCompositingSurface(
const gfx::Rect& src_subrect, const gfx::Rect& src_subrect,
const gfx::Size& dst_size, const gfx::Size& dst_size,
const base::Callback<void(bool, const SkBitmap&)>& callback, const base::Callback<void(bool, const SkBitmap&)>& callback,
const SkColorType color_type) = 0; const SkColorType color_type) = 0;
// Copies a given subset of the compositing surface's content into a YV12 // Copies the contents of the compositing surface, populating the given
// VideoFrame, and invokes a callback with a success/fail parameter. |target| // |target| with YV12 image data. |src_subrect| is specified in layer space
// must contain an allocated, YV12 video frame of the intended size. If the // coordinates for the current platform (e.g., DIP for Aura/Mac, physical for
// copy rectangle does not match |target|'s size, the copied content will be // Android), and is the region to be copied from this view. The copy is then
// scaled and letterboxed with black borders. The copy will happen // scaled and letterboxed with black borders to fit |target|. Finally,
// asynchronously. This operation will fail if there is no available // |callback| is asynchronously run with true/false for
// success/failure. |target| must point to an allocated, YV12 video frame of
// the intended size. This operation will fail if there is no available
// compositing surface. // compositing surface.
virtual void CopyFromCompositingSurfaceToVideoFrame( virtual void CopyFromCompositingSurfaceToVideoFrame(
const gfx::Rect& src_subrect, const gfx::Rect& src_subrect,
......
...@@ -41,10 +41,12 @@ SNAPSHOT_EXPORT bool GrabViewSnapshot( ...@@ -41,10 +41,12 @@ SNAPSHOT_EXPORT bool GrabViewSnapshot(
std::vector<unsigned char>* png_representation, std::vector<unsigned char>* png_representation,
const gfx::Rect& snapshot_bounds); const gfx::Rect& snapshot_bounds);
// These functions take a snapshot of |source_rect|, specified in layer space
// coordinates (DIP for desktop, physical pixels for Android), and scale the
// snapshot to |target_size| (in physical pixels), asynchronously.
typedef base::Callback<void(const gfx::Image& snapshot)> typedef base::Callback<void(const gfx::Image& snapshot)>
GrabWindowSnapshotAsyncCallback; GrabWindowSnapshotAsyncCallback;
// GrabWindowSnapshotAndScaleAsync() copies snapshot of |source_rect| from
// window and scales it to |target_size| asynchronously.
SNAPSHOT_EXPORT void GrabWindowSnapshotAndScaleAsync( SNAPSHOT_EXPORT void GrabWindowSnapshotAndScaleAsync(
gfx::NativeWindow window, gfx::NativeWindow window,
const gfx::Rect& source_rect, const gfx::Rect& source_rect,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment