forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved exo::SurfaceFactoryOwner to its own file and renamed it to exo:…
…:CompositorFrameSink. CompositorFrameSink implements cc::mojom::MojoCompositorFrameSink. CompositorFrameSink is no longer a friend class of exo::Surface. Added exo::CompositorFrameSinkHolder class that implements cc::mojom::MojoCompositorFrameSinkClient. BUG=659601 CQ_INCLUDE_TRYBOTS=master.tryserver.blink:linux_trusty_blink_rel Review-Url: https://codereview.chromium.org/2493223002 Review-Url: https://codereview.chromium.org/2493223002 Cr-Commit-Position: refs/heads/master@{#437780}
- Loading branch information
Showing
12 changed files
with
491 additions
and
194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
// Copyright 2016 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "components/exo/compositor_frame_sink.h" | ||
|
||
#include "cc/surfaces/surface.h" | ||
#include "cc/surfaces/surface_manager.h" | ||
#include "mojo/public/cpp/bindings/strong_binding.h" | ||
|
||
namespace exo { | ||
|
||
//////////////////////////////////////////////////////////////////////////////// | ||
// ExoComopositorFrameSink, public: | ||
|
||
// static | ||
void CompositorFrameSink::Create( | ||
const cc::FrameSinkId& frame_sink_id, | ||
cc::SurfaceManager* surface_manager, | ||
cc::mojom::MojoCompositorFrameSinkClientPtr client, | ||
cc::mojom::MojoCompositorFrameSinkRequest request) { | ||
std::unique_ptr<CompositorFrameSink> impl = | ||
base::MakeUnique<CompositorFrameSink>(frame_sink_id, surface_manager, | ||
std::move(client)); | ||
CompositorFrameSink* compositor_frame_sink = impl.get(); | ||
compositor_frame_sink->binding_ = | ||
mojo::MakeStrongBinding(std::move(impl), std::move(request)); | ||
} | ||
|
||
CompositorFrameSink::CompositorFrameSink( | ||
const cc::FrameSinkId& frame_sink_id, | ||
cc::SurfaceManager* surface_manager, | ||
cc::mojom::MojoCompositorFrameSinkClientPtr client) | ||
: support_(this, surface_manager, frame_sink_id, nullptr), | ||
client_(std::move(client)) {} | ||
|
||
CompositorFrameSink::~CompositorFrameSink() {} | ||
|
||
//////////////////////////////////////////////////////////////////////////////// | ||
// cc::mojom::MojoCompositorFrameSink overrides: | ||
|
||
void CompositorFrameSink::SetNeedsBeginFrame(bool needs_begin_frame) { | ||
support_.SetNeedsBeginFrame(needs_begin_frame); | ||
} | ||
|
||
void CompositorFrameSink::SubmitCompositorFrame( | ||
const cc::LocalFrameId& local_frame_id, | ||
cc::CompositorFrame frame) { | ||
support_.SubmitCompositorFrame(local_frame_id, std::move(frame)); | ||
} | ||
|
||
void CompositorFrameSink::AddSurfaceReferences( | ||
const std::vector<cc::SurfaceReference>& references) { | ||
// TODO(fsamuel, staraz): Implement this. | ||
NOTIMPLEMENTED(); | ||
} | ||
|
||
void CompositorFrameSink::RemoveSurfaceReferences( | ||
const std::vector<cc::SurfaceReference>& references) { | ||
// TODO(fsamuel, staraz): Implement this. | ||
NOTIMPLEMENTED(); | ||
} | ||
|
||
void CompositorFrameSink::EvictFrame() { | ||
support_.EvictFrame(); | ||
} | ||
|
||
void CompositorFrameSink::Require(const cc::LocalFrameId& local_frame_id, | ||
const cc::SurfaceSequence& sequence) { | ||
support_.Require(local_frame_id, sequence); | ||
} | ||
|
||
void CompositorFrameSink::Satisfy(const cc::SurfaceSequence& sequence) { | ||
support_.Satisfy(sequence); | ||
} | ||
|
||
//////////////////////////////////////////////////////////////////////////////// | ||
// cc::CompositorFrameSinkSupportClient overrides: | ||
|
||
void CompositorFrameSink::DidReceiveCompositorFrameAck() { | ||
if (client_) | ||
client_->DidReceiveCompositorFrameAck(); | ||
} | ||
|
||
void CompositorFrameSink::OnBeginFrame(const cc::BeginFrameArgs& args) { | ||
if (client_) | ||
client_->OnBeginFrame(args); | ||
} | ||
|
||
void CompositorFrameSink::ReclaimResources( | ||
const cc::ReturnedResourceArray& resources) { | ||
if (client_) | ||
client_->ReclaimResources(resources); | ||
} | ||
|
||
void CompositorFrameSink::WillDrawSurface() { | ||
if (client_) | ||
client_->WillDrawSurface(); | ||
} | ||
|
||
} // namespace exo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright 2016 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef COMPONENTS_EXO_EXO_COMPOSITOR_FRAME_SINK_H_ | ||
#define COMPONENTS_EXO_EXO_COMPOSITOR_FRAME_SINK_H_ | ||
|
||
#include "cc/ipc/compositor_frame.mojom.h" | ||
#include "cc/ipc/mojo_compositor_frame_sink.mojom.h" | ||
#include "cc/resources/transferable_resource.h" | ||
#include "cc/surfaces/compositor_frame_sink_support.h" | ||
#include "cc/surfaces/compositor_frame_sink_support_client.h" | ||
#include "mojo/public/cpp/bindings/strong_binding.h" | ||
|
||
namespace exo { | ||
|
||
class CompositorFrameSink : public cc::CompositorFrameSinkSupportClient, | ||
public cc::mojom::MojoCompositorFrameSink { | ||
public: | ||
static void Create(const cc::FrameSinkId& frame_sink_id, | ||
cc::SurfaceManager* surface_manager, | ||
cc::mojom::MojoCompositorFrameSinkClientPtr client, | ||
cc::mojom::MojoCompositorFrameSinkRequest request); | ||
|
||
CompositorFrameSink(const cc::FrameSinkId& frame_sink_id, | ||
cc::SurfaceManager* surface_manager, | ||
cc::mojom::MojoCompositorFrameSinkClientPtr client); | ||
|
||
~CompositorFrameSink() override; | ||
|
||
// Overridden from cc::mojom::MojoCompositorFrameSink: | ||
void SetNeedsBeginFrame(bool needs_begin_frame) override; | ||
void SubmitCompositorFrame(const cc::LocalFrameId& local_frame_id, | ||
cc::CompositorFrame frame) override; | ||
void AddSurfaceReferences( | ||
const std::vector<cc::SurfaceReference>& references) override; | ||
void RemoveSurfaceReferences( | ||
const std::vector<cc::SurfaceReference>& references) override; | ||
void EvictFrame() override; | ||
void Require(const cc::LocalFrameId& local_frame_id, | ||
const cc::SurfaceSequence& sequence) override; | ||
void Satisfy(const cc::SurfaceSequence& sequence) override; | ||
|
||
// Overridden from cc::CompositorFrameSinkSupportClient: | ||
void DidReceiveCompositorFrameAck() override; | ||
void OnBeginFrame(const cc::BeginFrameArgs& args) override; | ||
void ReclaimResources(const cc::ReturnedResourceArray& resources) override; | ||
void WillDrawSurface() override; | ||
|
||
private: | ||
cc::CompositorFrameSinkSupport support_; | ||
cc::mojom::MojoCompositorFrameSinkClientPtr client_; | ||
cc::ReturnedResourceArray surface_returned_resources_; | ||
mojo::StrongBindingPtr<cc::mojom::MojoCompositorFrameSink> binding_; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(CompositorFrameSink); | ||
}; | ||
|
||
} // namespace exo | ||
|
||
#endif // COMPONENTS_EXO_EXO_COMPOSITOR_FRAME_SINK_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
// Copyright 2016 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "components/exo/compositor_frame_sink_holder.h" | ||
|
||
#include "cc/resources/returned_resource.h" | ||
#include "components/exo/surface.h" | ||
|
||
namespace exo { | ||
|
||
//////////////////////////////////////////////////////////////////////////////// | ||
// CompositorFrameSinkHolder, public: | ||
|
||
CompositorFrameSinkHolder::CompositorFrameSinkHolder( | ||
Surface* surface, | ||
std::unique_ptr<CompositorFrameSink> frame_sink, | ||
cc::mojom::MojoCompositorFrameSinkClientRequest request) | ||
: surface_(surface), | ||
frame_sink_(std::move(frame_sink)), | ||
begin_frame_source_(base::MakeUnique<cc::ExternalBeginFrameSource>(this)), | ||
binding_(this, std::move(request)), | ||
weak_factory_(this) { | ||
surface_->AddSurfaceObserver(this); | ||
} | ||
|
||
bool CompositorFrameSinkHolder::HasReleaseCallbackForResource( | ||
cc::ResourceId id) { | ||
return release_callbacks_.find(id) != release_callbacks_.end(); | ||
} | ||
|
||
void CompositorFrameSinkHolder::AddResourceReleaseCallback( | ||
cc::ResourceId id, | ||
std::unique_ptr<cc::SingleReleaseCallback> callback) { | ||
release_callbacks_[id] = std::make_pair(this, std::move(callback)); | ||
} | ||
|
||
void CompositorFrameSinkHolder::ActivateFrameCallbacks( | ||
std::list<FrameCallback>* frame_callbacks) { | ||
active_frame_callbacks_.splice(active_frame_callbacks_.end(), | ||
*frame_callbacks); | ||
UpdateNeedsBeginFrame(); | ||
} | ||
|
||
void CompositorFrameSinkHolder::CancelFrameCallbacks() { | ||
// Call pending frame callbacks with a null frame time to indicate that they | ||
// have been cancelled. | ||
for (const auto& frame_callback : active_frame_callbacks_) | ||
frame_callback.Run(base::TimeTicks()); | ||
} | ||
|
||
void CompositorFrameSinkHolder::SetNeedsBeginFrame(bool needs_begin_frame) { | ||
needs_begin_frame_ = needs_begin_frame; | ||
OnNeedsBeginFrames(needs_begin_frame); | ||
} | ||
|
||
void CompositorFrameSinkHolder::Satisfy(const cc::SurfaceSequence& sequence) { | ||
frame_sink_->Satisfy(sequence); | ||
} | ||
|
||
void CompositorFrameSinkHolder::Require(const cc::SurfaceId& id, | ||
const cc::SurfaceSequence& sequence) { | ||
frame_sink_->Require(id.local_frame_id(), sequence); | ||
} | ||
|
||
//////////////////////////////////////////////////////////////////////////////// | ||
// cc::mojom::MojoCompositorFrameSinkClient overrides: | ||
|
||
void CompositorFrameSinkHolder::DidReceiveCompositorFrameAck() { | ||
// TODO(staraz): Implement this | ||
} | ||
|
||
void CompositorFrameSinkHolder::OnBeginFrame(const cc::BeginFrameArgs& args) { | ||
while (!active_frame_callbacks_.empty()) { | ||
active_frame_callbacks_.front().Run(args.frame_time); | ||
active_frame_callbacks_.pop_front(); | ||
} | ||
begin_frame_source_->OnBeginFrame(args); | ||
} | ||
|
||
void CompositorFrameSinkHolder::ReclaimResources( | ||
const cc::ReturnedResourceArray& resources) { | ||
for (auto& resource : resources) { | ||
auto it = release_callbacks_.find(resource.id); | ||
DCHECK(it != release_callbacks_.end()); | ||
std::unique_ptr<cc::SingleReleaseCallback> callback = | ||
std::move(it->second.second); | ||
release_callbacks_.erase(it); | ||
callback->Run(resource.sync_token, resource.lost); | ||
} | ||
} | ||
|
||
void CompositorFrameSinkHolder::WillDrawSurface() { | ||
if (surface_) | ||
surface_->WillDraw(); | ||
|
||
UpdateNeedsBeginFrame(); | ||
} | ||
|
||
//////////////////////////////////////////////////////////////////////////////// | ||
// cc::BeginFrameObserver overrides: | ||
|
||
const cc::BeginFrameArgs& CompositorFrameSinkHolder::LastUsedBeginFrameArgs() | ||
const { | ||
return last_begin_frame_args_; | ||
} | ||
|
||
void CompositorFrameSinkHolder::OnBeginFrameSourcePausedChanged(bool paused) {} | ||
|
||
//////////////////////////////////////////////////////////////////////////////// | ||
// cc::ExternalBeginFrameSouceClient overrides: | ||
|
||
void CompositorFrameSinkHolder::OnNeedsBeginFrames(bool needs_begin_frames) { | ||
frame_sink_->SetNeedsBeginFrame(needs_begin_frames); | ||
} | ||
|
||
//////////////////////////////////////////////////////////////////////////////// | ||
// SurfaceObserver overrides: | ||
|
||
void CompositorFrameSinkHolder::OnSurfaceDestroying(Surface* surface) { | ||
surface_->RemoveSurfaceObserver(this); | ||
surface_ = nullptr; | ||
} | ||
|
||
//////////////////////////////////////////////////////////////////////////////// | ||
// ExoComopositorFrameSink, private: | ||
|
||
CompositorFrameSinkHolder::~CompositorFrameSinkHolder() {} | ||
|
||
void CompositorFrameSinkHolder::UpdateNeedsBeginFrame() { | ||
if (!begin_frame_source_) | ||
return; | ||
|
||
bool needs_begin_frame = !active_frame_callbacks_.empty(); | ||
if (needs_begin_frame == needs_begin_frame_) | ||
return; | ||
|
||
needs_begin_frame_ = needs_begin_frame; | ||
OnNeedsBeginFrames(needs_begin_frame_); | ||
} | ||
|
||
} // namespace exo |
Oops, something went wrong.