Commit d8f4f642 authored by staraz's avatar staraz Committed by Commit bot

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}
parent 39fe426a
...@@ -160,6 +160,10 @@ void AshTestHelper::SetUp(bool start_session, ...@@ -160,6 +160,10 @@ void AshTestHelper::SetUp(bool start_session,
void AshTestHelper::TearDown() { void AshTestHelper::TearDown() {
// Tear down the shell. // Tear down the shell.
Shell::DeleteInstance(); Shell::DeleteInstance();
// Suspend the tear down until all resources are returned via
// MojoCompositorFrameSinkClient::ReclaimResources()
RunAllPendingInMessageLoop();
material_design_state_.reset(); material_design_state_.reset();
test::MaterialDesignControllerTestAPI::Uninitialize(); test::MaterialDesignControllerTestAPI::Uninitialize();
ash_test_environment_->TearDown(); ash_test_environment_->TearDown();
......
...@@ -38,6 +38,12 @@ class DesktopMediaListAshTest : public ash::test::AshTestBase { ...@@ -38,6 +38,12 @@ class DesktopMediaListAshTest : public ash::test::AshTestBase {
DesktopMediaListAshTest() {} DesktopMediaListAshTest() {}
~DesktopMediaListAshTest() override {} ~DesktopMediaListAshTest() override {}
void TearDown() override {
// Reset the unique_ptr so the list stops refreshing.
list_.reset();
ash::test::AshTestBase::TearDown();
}
void CreateList(int source_types) { void CreateList(int source_types) {
list_.reset(new DesktopMediaListAsh(source_types)); list_.reset(new DesktopMediaListAsh(source_types));
list_->SetThumbnailSize(gfx::Size(kThumbnailSize, kThumbnailSize)); list_->SetThumbnailSize(gfx::Size(kThumbnailSize, kThumbnailSize));
......
...@@ -9,6 +9,10 @@ source_set("exo") { ...@@ -9,6 +9,10 @@ source_set("exo") {
sources = [ sources = [
"buffer.cc", "buffer.cc",
"buffer.h", "buffer.h",
"compositor_frame_sink.cc",
"compositor_frame_sink.h",
"compositor_frame_sink_holder.cc",
"compositor_frame_sink_holder.h",
"display.cc", "display.cc",
"display.h", "display.h",
"gamepad.cc", "gamepad.cc",
...@@ -156,6 +160,7 @@ test("exo_unittests") { ...@@ -156,6 +160,7 @@ test("exo_unittests") {
"//base", "//base",
"//base/test:test_support", "//base/test:test_support",
"//device/gamepad:test_helpers", "//device/gamepad:test_helpers",
"//mojo/edk/embedder:headers",
] ]
data_deps = [ data_deps = [
......
...@@ -4,8 +4,15 @@ include_rules = [ ...@@ -4,8 +4,15 @@ include_rules = [
"+chromeos/audio/chromeos_sounds.h", "+chromeos/audio/chromeos_sounds.h",
"+device/gamepad", "+device/gamepad",
"+gpu", "+gpu",
"+mojo/public/cpp",
"+services/ui/public/cpp", "+services/ui/public/cpp",
"+third_party/khronos", "+third_party/khronos",
"+third_party/skia", "+third_party/skia",
"+ui", "+ui",
] ]
specific_include_rules = {
"run_all_unittests\.cc": [
"+mojo/edk/embedder/embedder.h",
],
}
// 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
// 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_
// 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
// 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_COMPOSITOR_FRAME_SINK_HOLDER_H_
#define COMPONENTS_EXO_COMPOSITOR_FRAME_SINK_HOLDER_H_
#include <list>
#include <map>
#include <memory>
#include "cc/ipc/mojo_compositor_frame_sink.mojom.h"
#include "cc/resources/single_release_callback.h"
#include "cc/resources/transferable_resource.h"
#include "cc/scheduler/begin_frame_source.h"
#include "components/exo/compositor_frame_sink.h"
#include "components/exo/surface_observer.h"
#include "mojo/public/cpp/bindings/binding.h"
namespace exo {
class Surface;
// This class talks to MojoCompositorFrameSink and keeps track of references to
// the contents of Buffers. It's keeped alive by references from
// release_callbacks_. It's destroyed when its owning Surface is destroyed and
// the last outstanding release callback is called.
class CompositorFrameSinkHolder
: public base::RefCounted<CompositorFrameSinkHolder>,
public cc::ExternalBeginFrameSourceClient,
public cc::mojom::MojoCompositorFrameSinkClient,
public cc::BeginFrameObserver,
public SurfaceObserver {
public:
CompositorFrameSinkHolder(
Surface* surface,
std::unique_ptr<CompositorFrameSink> frame_sink,
cc::mojom::MojoCompositorFrameSinkClientRequest request);
bool HasReleaseCallbackForResource(cc::ResourceId id);
void AddResourceReleaseCallback(
cc::ResourceId id,
std::unique_ptr<cc::SingleReleaseCallback> callback);
CompositorFrameSink* GetCompositorFrameSink() { return frame_sink_.get(); }
base::WeakPtr<CompositorFrameSinkHolder> GetWeakPtr() {
return weak_factory_.GetWeakPtr();
}
using FrameCallback = base::Callback<void(base::TimeTicks frame_time)>;
void ActivateFrameCallbacks(std::list<FrameCallback>* frame_callbacks);
void CancelFrameCallbacks();
void SetNeedsBeginFrame(bool needs_begin_frame);
void Satisfy(const cc::SurfaceSequence& sequence);
void Require(const cc::SurfaceId& id, const cc::SurfaceSequence& sequence);
// Overridden from cc::mojom::MojoCompositorFrameSinkClient:
void DidReceiveCompositorFrameAck() override;
void OnBeginFrame(const cc::BeginFrameArgs& args) override;
void ReclaimResources(const cc::ReturnedResourceArray& resources) override;
void WillDrawSurface() override;
// Overridden from cc::BeginFrameObserver:
const cc::BeginFrameArgs& LastUsedBeginFrameArgs() const override;
void OnBeginFrameSourcePausedChanged(bool paused) override;
// Overridden from cc::ExternalBeginFrameSouceClient:
void OnNeedsBeginFrames(bool needs_begin_frames) override;
// Overridden from SurfaceObserver:
void OnSurfaceDestroying(Surface* surface) override;
private:
friend class base::RefCounted<CompositorFrameSinkHolder>;
~CompositorFrameSinkHolder() override;
void UpdateNeedsBeginFrame();
// Each release callback holds a reference to the CompositorFrameSinkHolder
// itself to keep it alive. Running and erasing the callbacks might result in
// the instance being destroyed. Therefore, we should not access any member
// variables after running and erasing the callbacks.
using ResourceReleaseCallbackMap =
std::map<int,
std::pair<scoped_refptr<CompositorFrameSinkHolder>,
std::unique_ptr<cc::SingleReleaseCallback>>>;
ResourceReleaseCallbackMap release_callbacks_;
Surface* surface_;
std::unique_ptr<CompositorFrameSink> frame_sink_;
std::list<FrameCallback> active_frame_callbacks_;
std::unique_ptr<cc::ExternalBeginFrameSource> begin_frame_source_;
bool needs_begin_frame_ = false;
cc::BeginFrameArgs last_begin_frame_args_;
mojo::Binding<cc::mojom::MojoCompositorFrameSinkClient> binding_;
base::WeakPtrFactory<CompositorFrameSinkHolder> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(CompositorFrameSinkHolder);
};
} // namespace exo
#endif // COMPONENTS_EXO_COMPOSITOR_FRAME_SINK_HOLDER_H_
This diff is collapsed.
...@@ -17,7 +17,9 @@ ...@@ -17,7 +17,9 @@
#include "base/observer_list.h" #include "base/observer_list.h"
#include "cc/resources/transferable_resource.h" #include "cc/resources/transferable_resource.h"
#include "cc/scheduler/begin_frame_source.h" #include "cc/scheduler/begin_frame_source.h"
#include "cc/surfaces/surface_factory_client.h" #include "cc/surfaces/surface_id_allocator.h"
#include "components/exo/compositor_frame_sink.h"
#include "components/exo/compositor_frame_sink_holder.h"
#include "third_party/skia/include/core/SkBlendMode.h" #include "third_party/skia/include/core/SkBlendMode.h"
#include "third_party/skia/include/core/SkRegion.h" #include "third_party/skia/include/core/SkRegion.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
...@@ -31,7 +33,6 @@ class TracedValue; ...@@ -31,7 +33,6 @@ class TracedValue;
} }
namespace cc { namespace cc {
class SurfaceFactory;
class SurfaceIdAllocator; class SurfaceIdAllocator;
} }
...@@ -57,42 +58,9 @@ class PropertyHelper; ...@@ -57,42 +58,9 @@ class PropertyHelper;
// change in the future when better hardware cursor support is added. // change in the future when better hardware cursor support is added.
using CursorProvider = Pointer; using CursorProvider = Pointer;
// This class owns the SurfaceFactory and keeps track of references to the
// contents of Buffers. It's keeped alive by references from
// release_callbacks_. It's destroyed when its owning Surface is destroyed and
// the last outstanding release callback is called.
class SurfaceFactoryOwner : public base::RefCounted<SurfaceFactoryOwner>,
public cc::SurfaceFactoryClient {
public:
SurfaceFactoryOwner();
// Overridden from cc::SurfaceFactoryClient:
void ReturnResources(const cc::ReturnedResourceArray& resources) override;
void WillDrawSurface(const cc::LocalFrameId& id,
const gfx::Rect& damage_rect) override;
void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override;
private:
friend class base::RefCounted<SurfaceFactoryOwner>;
friend class Surface;
~SurfaceFactoryOwner() override;
std::map<int,
std::pair<scoped_refptr<SurfaceFactoryOwner>,
std::unique_ptr<cc::SingleReleaseCallback>>>
release_callbacks_;
cc::FrameSinkId frame_sink_id_;
std::unique_ptr<cc::SurfaceIdAllocator> id_allocator_;
std::unique_ptr<cc::SurfaceFactory> surface_factory_;
Surface* surface_ = nullptr;
};
// This class represents a rectangular area that is displayed on the screen. // This class represents a rectangular area that is displayed on the screen.
// It has a location, size and pixel contents. // It has a location, size and pixel contents.
class Surface : public ui::ContextFactoryObserver, class Surface : public ui::ContextFactoryObserver, public aura::WindowObserver {
public aura::WindowObserver,
public cc::BeginFrameObserver {
public: public:
using PropertyDeallocator = void (*)(int64_t value); using PropertyDeallocator = void (*)(int64_t value);
...@@ -104,9 +72,12 @@ class Surface : public ui::ContextFactoryObserver, ...@@ -104,9 +72,12 @@ class Surface : public ui::ContextFactoryObserver,
aura::Window* window() { return window_.get(); } aura::Window* window() { return window_.get(); }
const cc::LocalFrameId& local_frame_id() const { return local_frame_id_; }
cc::SurfaceId GetSurfaceId() const; cc::SurfaceId GetSurfaceId() const;
CompositorFrameSinkHolder* compositor_frame_sink_holder() {
return compositor_frame_sink_holder_.get();
}
// Set a buffer as the content of this surface. A buffer can only be attached // Set a buffer as the content of this surface. A buffer can only be attached
// to one surface at a time. // to one surface at a time.
void Attach(Buffer* buffer); void Attach(Buffer* buffer);
...@@ -229,11 +200,6 @@ class Surface : public ui::ContextFactoryObserver, ...@@ -229,11 +200,6 @@ class Surface : public ui::ContextFactoryObserver,
void OnWindowRemovingFromRootWindow(aura::Window* window, void OnWindowRemovingFromRootWindow(aura::Window* window,
aura::Window* new_root) override; aura::Window* new_root) override;
// Overridden from cc::BeginFrameObserver:
void OnBeginFrame(const cc::BeginFrameArgs& args) override;
const cc::BeginFrameArgs& LastUsedBeginFrameArgs() const override;
void OnBeginFrameSourcePausedChanged(bool paused) override {}
// Sets the |value| of the given surface |property|. Setting to the default // Sets the |value| of the given surface |property|. Setting to the default
// value (e.g., NULL) removes the property. The caller is responsible for the // value (e.g., NULL) removes the property. The caller is responsible for the
// lifetime of any object set as a property on the Surface. // lifetime of any object set as a property on the Surface.
...@@ -314,9 +280,6 @@ class Surface : public ui::ContextFactoryObserver, ...@@ -314,9 +280,6 @@ class Surface : public ui::ContextFactoryObserver,
// current_resource_. // current_resource_.
void UpdateSurface(bool full_damage); void UpdateSurface(bool full_damage);
// Adds/Removes begin frame observer based on state.
void UpdateNeedsBeginFrame();
int64_t SetPropertyInternal(const void* key, int64_t SetPropertyInternal(const void* key,
const char* name, const char* name,
PropertyDeallocator deallocator, PropertyDeallocator deallocator,
...@@ -350,12 +313,12 @@ class Surface : public ui::ContextFactoryObserver, ...@@ -350,12 +313,12 @@ class Surface : public ui::ContextFactoryObserver,
// The buffer that will become the content of surface when Commit() is called. // The buffer that will become the content of surface when Commit() is called.
BufferAttachment pending_buffer_; BufferAttachment pending_buffer_;
cc::SurfaceManager* surface_manager_; const cc::FrameSinkId frame_sink_id_;
cc::LocalFrameId local_frame_id_;
scoped_refptr<SurfaceFactoryOwner> factory_owner_; scoped_refptr<CompositorFrameSinkHolder> compositor_frame_sink_holder_;
// The Surface Id currently attached to the window. cc::SurfaceIdAllocator id_allocator_;
cc::LocalFrameId local_frame_id_;
// The next resource id the buffer will be attached to. // The next resource id the buffer will be attached to.
int next_resource_id_ = 1; int next_resource_id_ = 1;
...@@ -370,7 +333,6 @@ class Surface : public ui::ContextFactoryObserver, ...@@ -370,7 +333,6 @@ class Surface : public ui::ContextFactoryObserver,
// be drawn. They fire at the first begin frame notification after this. // be drawn. They fire at the first begin frame notification after this.
std::list<FrameCallback> pending_frame_callbacks_; std::list<FrameCallback> pending_frame_callbacks_;
std::list<FrameCallback> frame_callbacks_; std::list<FrameCallback> frame_callbacks_;
std::list<FrameCallback> active_frame_callbacks_;
// This is the state that has yet to be committed. // This is the state that has yet to be committed.
State pending_state_; State pending_state_;
...@@ -407,11 +369,6 @@ class Surface : public ui::ContextFactoryObserver, ...@@ -407,11 +369,6 @@ class Surface : public ui::ContextFactoryObserver,
// maintains. // maintains.
SurfaceDelegate* delegate_ = nullptr; SurfaceDelegate* delegate_ = nullptr;
// The begin frame source being observed.
cc::BeginFrameSource* begin_frame_source_ = nullptr;
cc::BeginFrameArgs last_begin_frame_args_;
bool needs_begin_frame_ = false;
struct Value { struct Value {
const char* name; const char* name;
int64_t value; int64_t value;
......
...@@ -50,6 +50,11 @@ TEST_F(SurfaceTest, Attach) { ...@@ -50,6 +50,11 @@ TEST_F(SurfaceTest, Attach) {
// attached buffer. // attached buffer.
surface->Attach(nullptr); surface->Attach(nullptr);
surface->Commit(); surface->Commit();
// CompositorFrameSinkHolder::ReclaimResources() gets called via
// MojoCompositorFrameSinkClient interface. We need to wait here for the mojo
// call to finish so that the release callback finishes running before
// the assertion below.
RunAllPendingInMessageLoop();
ASSERT_EQ(1, release_buffer_call_count); ASSERT_EQ(1, release_buffer_call_count);
} }
...@@ -205,6 +210,7 @@ TEST_F(SurfaceTest, SetBlendMode) { ...@@ -205,6 +210,7 @@ TEST_F(SurfaceTest, SetBlendMode) {
surface->Attach(buffer.get()); surface->Attach(buffer.get());
surface->SetBlendMode(SkBlendMode::kSrc); surface->SetBlendMode(SkBlendMode::kSrc);
surface->Commit(); surface->Commit();
RunAllPendingInMessageLoop();
const cc::CompositorFrame& frame = GetFrameFromSurface(surface.get()); const cc::CompositorFrame& frame = GetFrameFromSurface(surface.get());
ASSERT_EQ(1u, frame.render_pass_list.size()); ASSERT_EQ(1u, frame.render_pass_list.size());
...@@ -222,6 +228,7 @@ TEST_F(SurfaceTest, OverlayCandidate) { ...@@ -222,6 +228,7 @@ TEST_F(SurfaceTest, OverlayCandidate) {
surface->Attach(buffer.get()); surface->Attach(buffer.get());
surface->Commit(); surface->Commit();
RunAllPendingInMessageLoop();
const cc::CompositorFrame& frame = GetFrameFromSurface(surface.get()); const cc::CompositorFrame& frame = GetFrameFromSurface(surface.get());
ASSERT_EQ(1u, frame.render_pass_list.size()); ASSERT_EQ(1u, frame.render_pass_list.size());
......
...@@ -6,9 +6,17 @@ ...@@ -6,9 +6,17 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/test/launcher/unit_test_launcher.h" #include "base/test/launcher/unit_test_launcher.h"
#if !defined(OS_IOS)
#include "mojo/edk/embedder/embedder.h"
#endif
int main(int argc, char** argv) { int main(int argc, char** argv) {
ash::test::AuraShellTestSuite test_suite(argc, argv); ash::test::AuraShellTestSuite test_suite(argc, argv);
#if !defined(OS_IOS)
mojo::edk::Init();
#endif
return base::LaunchUnitTestsSerially( return base::LaunchUnitTestsSerially(
argc, argv, base::Bind(&ash::test::AuraShellTestSuite::Run, argc, argv, base::Bind(&ash::test::AuraShellTestSuite::Run,
base::Unretained(&test_suite))); base::Unretained(&test_suite)));
......
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