Commit 115bf013 authored by jbauman's avatar jbauman Committed by Commit bot

Allow requesting a copy of a surface.

Instead of requesting a layer, a copy of the entire surface is requested. Actually handling the request isn't implemented yet.

BUG=397730

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

Cr-Commit-Position: refs/heads/master@{#292498}
parent fd0069d6
......@@ -5,6 +5,7 @@
#include "cc/surfaces/surface.h"
#include "cc/output/compositor_frame.h"
#include "cc/output/copy_output_request.h"
#include "cc/surfaces/surface_factory.h"
namespace cc {
......@@ -50,6 +51,11 @@ void Surface::QueueFrame(scoped_ptr<CompositorFrame> frame,
draw_callback_ = callback;
}
void Surface::RequestCopyOfOutput(scoped_ptr<CopyOutputRequest> copy_request) {
// TODO(jbauman): Make this work.
copy_request->SendEmptyResult();
}
const CompositorFrame* Surface::GetEligibleFrame() {
return current_frame_.get();
}
......
......@@ -15,6 +15,7 @@
namespace cc {
class CompositorFrame;
class CopyOutputRequest;
class SurfaceManager;
class SurfaceFactory;
class SurfaceResourceHolder;
......@@ -29,6 +30,7 @@ class CC_SURFACES_EXPORT Surface {
void QueueFrame(scoped_ptr<CompositorFrame> frame,
const base::Closure& draw_callback);
void RequestCopyOfOutput(scoped_ptr<CopyOutputRequest> copy_request);
// Returns the most recent frame that is eligible to be rendered.
const CompositorFrame* GetEligibleFrame();
......
......@@ -5,6 +5,7 @@
#include "cc/surfaces/surface_factory.h"
#include "cc/output/compositor_frame.h"
#include "cc/output/copy_output_request.h"
#include "cc/surfaces/surface.h"
#include "cc/surfaces/surface_manager.h"
#include "ui/gfx/geometry/size.h"
......@@ -44,6 +45,18 @@ void SurfaceFactory::SubmitFrame(SurfaceId surface_id,
manager_->SurfaceModified(surface_id);
}
void SurfaceFactory::RequestCopyOfSurface(
SurfaceId surface_id,
scoped_ptr<CopyOutputRequest> copy_request) {
OwningSurfaceMap::iterator it = surface_map_.find(surface_id);
if (it == surface_map_.end()) {
copy_request->SendEmptyResult();
return;
}
DCHECK(it->second->factory() == this);
it->second->RequestCopyOfOutput(copy_request.Pass());
}
void SurfaceFactory::ReceiveFromChild(
const TransferableResourceArray& resources) {
holder_.ReceiveFromChild(resources);
......
......@@ -19,6 +19,7 @@ class Size;
namespace cc {
class CompositorFrame;
class CopyOutputRequest;
class Surface;
class SurfaceFactoryClient;
class SurfaceManager;
......@@ -42,6 +43,8 @@ class CC_SURFACES_EXPORT SurfaceFactory
void SubmitFrame(SurfaceId surface_id,
scoped_ptr<CompositorFrame> frame,
const base::Closure& callback);
void RequestCopyOfSurface(SurfaceId surface_id,
scoped_ptr<CopyOutputRequest> copy_request);
SurfaceFactoryClient* client() { return client_; }
......
......@@ -131,7 +131,9 @@ bool DelegatedFrameHost::ShouldCreateResizeLock() {
void DelegatedFrameHost::RequestCopyOfOutput(
scoped_ptr<cc::CopyOutputRequest> request) {
if (use_surfaces_) {
// TODO(jbauman): Make this work with surfaces.
if (surface_factory_ && !surface_id_.is_null())
surface_factory_->RequestCopyOfSurface(surface_id_, request.Pass());
else
request->SendEmptyResult();
} else {
client_->GetLayer()->RequestCopyOfOutput(request.Pass());
......
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