| Index: cc/test/test_compositor_frame_sink.cc
|
| diff --git a/cc/test/test_compositor_frame_sink.cc b/cc/test/test_compositor_frame_sink.cc
|
| index 2b3c260cfeebe4bede854e13f398b2f163428981..e07ada5bde2efb3ac16da5d2d84da6af3a1b1f96 100644
|
| --- a/cc/test/test_compositor_frame_sink.cc
|
| +++ b/cc/test/test_compositor_frame_sink.cc
|
| @@ -14,7 +14,6 @@
|
| #include "cc/output/direct_renderer.h"
|
| #include "cc/output/output_surface.h"
|
| #include "cc/output/texture_mailbox_deleter.h"
|
| -#include "cc/surfaces/compositor_frame_sink_support.h"
|
|
|
| namespace cc {
|
|
|
| @@ -39,7 +38,8 @@
|
| frame_sink_id_(kCompositorFrameSinkId),
|
| surface_manager_(new SurfaceManager),
|
| local_surface_id_allocator_(new LocalSurfaceIdAllocator()),
|
| - external_begin_frame_source_(this),
|
| + surface_factory_(
|
| + new SurfaceFactory(frame_sink_id_, surface_manager_.get(), this)),
|
| weak_ptr_factory_(this) {
|
| // Since this CompositorFrameSink and the Display are tightly coupled and in
|
| // the same process/thread, the LayerTreeHostImpl can reclaim resources from
|
| @@ -98,23 +98,26 @@
|
| if (display_context_shared_with_compositor && context_provider())
|
| context_provider()->SetLostContextCallback(base::Closure());
|
|
|
| - support_ = base::MakeUnique<CompositorFrameSinkSupport>(
|
| - this, surface_manager_.get(), frame_sink_id_, false /* is_root */,
|
| - true /* handles_frame_sink_id_invalidation */,
|
| - true /* needs_sync_points */);
|
| - client_->SetBeginFrameSource(&external_begin_frame_source_);
|
| -
|
| + surface_manager_->RegisterFrameSinkId(frame_sink_id_);
|
| + surface_manager_->RegisterSurfaceFactoryClient(frame_sink_id_, this);
|
| display_->Initialize(this, surface_manager_.get());
|
| display_->renderer_for_testing()->SetEnlargePassTextureAmountForTesting(
|
| enlarge_pass_texture_amount_);
|
| display_->SetVisible(true);
|
| + bound_ = true;
|
| return true;
|
| }
|
|
|
| void TestCompositorFrameSink::DetachFromClient() {
|
| - client_->SetBeginFrameSource(nullptr);
|
| - support_ = nullptr;
|
| - display_ = nullptr;
|
| + // Some tests make BindToClient fail on purpose. ^__^
|
| + if (bound_) {
|
| + surface_factory_->EvictSurface();
|
| + surface_manager_->UnregisterSurfaceFactoryClient(frame_sink_id_);
|
| + surface_manager_->InvalidateFrameSinkId(frame_sink_id_);
|
| + display_ = nullptr;
|
| + bound_ = false;
|
| + }
|
| + surface_factory_ = nullptr;
|
| local_surface_id_allocator_ = nullptr;
|
| surface_manager_ = nullptr;
|
| test_client_ = nullptr;
|
| @@ -133,52 +136,58 @@
|
| gfx::Size frame_size = frame.render_pass_list.back()->output_rect.size();
|
| display_->Resize(frame_size);
|
|
|
| - support_->SubmitCompositorFrame(delegated_local_surface_id_,
|
| - std::move(frame));
|
| + bool synchronous = !display_->has_scheduler();
|
| +
|
| + SurfaceFactory::DrawCallback draw_callback;
|
| + if (!synchronous) {
|
| + // For async draws, we use a callback tell when it is done, but for sync
|
| + // draws we don't need one. Unretained is safe here because the callback
|
| + // will be run when |surface_factory_| is destroyed which is owned by this
|
| + // class.
|
| + draw_callback = base::Bind(&TestCompositorFrameSink::DidDrawCallback,
|
| + base::Unretained(this));
|
| + }
|
| +
|
| + surface_factory_->SubmitCompositorFrame(delegated_local_surface_id_,
|
| + std::move(frame), draw_callback);
|
|
|
| for (std::unique_ptr<CopyOutputRequest>& copy_request : copy_requests_) {
|
| - support_->RequestCopyOfSurface(std::move(copy_request));
|
| + surface_factory_->RequestCopyOfSurface(std::move(copy_request));
|
| }
|
| copy_requests_.clear();
|
|
|
| - if (!display_->has_scheduler()) {
|
| + if (synchronous) {
|
| display_->DrawAndSwap();
|
| // Post this to get a new stack frame so that we exit this function before
|
| // calling the client to tell it that it is done.
|
| - task_runner_->PostTask(
|
| - FROM_HERE,
|
| - base::Bind(&TestCompositorFrameSink::SendCompositorFrameAckToClient,
|
| - weak_ptr_factory_.GetWeakPtr()));
|
| - }
|
| + task_runner_->PostTask(FROM_HERE,
|
| + base::Bind(&TestCompositorFrameSink::DidDrawCallback,
|
| + weak_ptr_factory_.GetWeakPtr()));
|
| + }
|
| +}
|
| +
|
| +void TestCompositorFrameSink::DidDrawCallback() {
|
| + // This is to unthrottle the next frame, not actually a notice that drawing is
|
| + // done.
|
| + client_->DidReceiveCompositorFrameAck();
|
| }
|
|
|
| void TestCompositorFrameSink::ForceReclaimResources() {
|
| if (capabilities_.can_force_reclaim_resources &&
|
| delegated_local_surface_id_.is_valid()) {
|
| - support_->ForceReclaimResources();
|
| - }
|
| -}
|
| -
|
| -void TestCompositorFrameSink::DidReceiveCompositorFrameAck() {
|
| - // In synchronous mode, we manually send acks and this method should not be
|
| - // used.
|
| - if (!display_->has_scheduler())
|
| - return;
|
| - client_->DidReceiveCompositorFrameAck();
|
| -}
|
| -
|
| -void TestCompositorFrameSink::OnBeginFrame(const BeginFrameArgs& args) {
|
| - external_begin_frame_source_.OnBeginFrame(args);
|
| -}
|
| -
|
| -void TestCompositorFrameSink::ReclaimResources(
|
| + surface_factory_->ClearSurface();
|
| + }
|
| +}
|
| +
|
| +void TestCompositorFrameSink::ReturnResources(
|
| const ReturnedResourceArray& resources) {
|
| client_->ReclaimResources(resources);
|
| }
|
|
|
| -void TestCompositorFrameSink::WillDrawSurface(
|
| - const LocalSurfaceId& local_surface_id,
|
| - const gfx::Rect& damage_rect) {}
|
| +void TestCompositorFrameSink::SetBeginFrameSource(
|
| + BeginFrameSource* begin_frame_source) {
|
| + client_->SetBeginFrameSource(begin_frame_source);
|
| +}
|
|
|
| void TestCompositorFrameSink::DisplayOutputSurfaceLost() {
|
| client_->DidLoseCompositorFrameSink();
|
| @@ -194,14 +203,4 @@
|
| test_client_->DisplayDidDrawAndSwap();
|
| }
|
|
|
| -void TestCompositorFrameSink::OnNeedsBeginFrames(bool needs_begin_frames) {
|
| - support_->SetNeedsBeginFrame(needs_begin_frames);
|
| -}
|
| -
|
| -void TestCompositorFrameSink::OnDidFinishFrame(const BeginFrameAck& ack) {}
|
| -
|
| -void TestCompositorFrameSink::SendCompositorFrameAckToClient() {
|
| - client_->DidReceiveCompositorFrameAck();
|
| -}
|
| -
|
| } // namespace cc
|
|
|