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(
subscriber_texture,
target,
callback));
gfx::Rect src_subrect_in_pixel =
ConvertRectToPixel(client_->CurrentDeviceScaleFactor(), src_subrect);
request->set_area(src_subrect_in_pixel);
request->set_area(src_subrect);
if (subscriber_texture.get()) {
request->SetTextureMailbox(
cc::TextureMailbox(subscriber_texture->mailbox(),
......
......@@ -278,10 +278,8 @@ void DesktopVideoCaptureMachine::Capture(bool dirty) {
cc::CopyOutputRequest::CreateRequest(
base::Bind(&DesktopVideoCaptureMachine::DidCopyOutput,
AsWeakPtr(), frame, start_time, capture_frame_cb));
gfx::Rect window_rect =
ui::ConvertRectToPixel(desktop_window_->layer(),
gfx::Rect(desktop_window_->bounds().width(),
desktop_window_->bounds().height()));
gfx::Rect window_rect = gfx::Rect(desktop_window_->bounds().width(),
desktop_window_->bounds().height());
request->set_area(window_rect);
desktop_window_->layer()->RequestCopyOfOutput(request.Pass());
}
......
......@@ -243,27 +243,27 @@ class CONTENT_EXPORT RenderWidgetHostViewBase : public RenderWidgetHostView,
// Notifies the view that the scroll offset has changed.
virtual void ScrollOffsetChanged() = 0;
// Copies the contents of the compositing surface into the given
// (uninitialized) PlatformCanvas if any.
// The rectangle region specified with |src_subrect| is copied from the
// contents, scaled to |dst_size|, and written to |output|.
// |callback| is invoked with true on success, false otherwise. |output| can
// be initialized even on failure.
// A smaller region than |src_subrect| may be copied if the underlying surface
// is smaller than |src_subrect|.
// NOTE: |callback| is called asynchronously.
// Copies the contents of the compositing surface, providing a new SkBitmap
// result via an asynchronously-run |callback|. |src_subrect| is specified in
// layer space coordinates for the current platform (e.g., DIP for Aura/Mac,
// physical for Android), and is the region to be copied from this view. The
// copy is then scaled to a SkBitmap of size |dst_size|. |callback| is run
// with true on success, false otherwise. A smaller region than |src_subrect|
// may be copied if the underlying surface is smaller than |src_subrect|.
virtual void CopyFromCompositingSurface(
const gfx::Rect& src_subrect,
const gfx::Size& dst_size,
const base::Callback<void(bool, const SkBitmap&)>& callback,
const SkColorType color_type) = 0;
// Copies a given subset of the compositing surface's content into a YV12
// VideoFrame, and invokes a callback with a success/fail parameter. |target|
// must contain an allocated, YV12 video frame of the intended size. If the
// copy rectangle does not match |target|'s size, the copied content will be
// scaled and letterboxed with black borders. The copy will happen
// asynchronously. This operation will fail if there is no available
// Copies the contents of the compositing surface, populating the given
// |target| with YV12 image data. |src_subrect| is specified in layer space
// coordinates for the current platform (e.g., DIP for Aura/Mac, physical for
// Android), and is the region to be copied from this view. The copy is then
// scaled and letterboxed with black borders to fit |target|. Finally,
// |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.
virtual void CopyFromCompositingSurfaceToVideoFrame(
const gfx::Rect& src_subrect,
......
......@@ -41,10 +41,12 @@ SNAPSHOT_EXPORT bool GrabViewSnapshot(
std::vector<unsigned char>* png_representation,
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)>
GrabWindowSnapshotAsyncCallback;
// GrabWindowSnapshotAndScaleAsync() copies snapshot of |source_rect| from
// window and scales it to |target_size| asynchronously.
SNAPSHOT_EXPORT void GrabWindowSnapshotAndScaleAsync(
gfx::NativeWindow window,
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