Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Unified Diff: content/renderer/android/synchronous_compositor_frame_sink.cc

Issue 2485473003: Remove SurfaceFactory::Create and SurfaceFactory::Destroy (Closed)
Patch Set: up Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/renderer/android/synchronous_compositor_frame_sink.cc
diff --git a/content/renderer/android/synchronous_compositor_frame_sink.cc b/content/renderer/android/synchronous_compositor_frame_sink.cc
index fd683c1199015225cb563e29d8562c916080554b..c0ff4c0f9fbb6281aff35e0251950e5a3900084a 100644
--- a/content/renderer/android/synchronous_compositor_frame_sink.cc
+++ b/content/renderer/android/synchronous_compositor_frame_sink.cc
@@ -48,7 +48,8 @@ namespace content {
namespace {
const int64_t kFallbackTickTimeoutInMilliseconds = 100;
-const cc::FrameSinkId kFrameSinkId(1, 1);
+const cc::FrameSinkId kRootFrameSinkId(1, 1);
+const cc::FrameSinkId kChildFrameSinkId(1, 2);
// Do not limit number of resources, so use an unrealistically high value.
const size_t kNumResourcesLimit = 10 * 1000 * 1000;
@@ -122,8 +123,12 @@ SynchronousCompositorFrameSink::SynchronousCompositorFrameSink(
frame_swap_message_queue_(frame_swap_message_queue),
surface_manager_(new cc::SurfaceManager),
surface_id_allocator_(new cc::SurfaceIdAllocator()),
- surface_factory_(
- new cc::SurfaceFactory(kFrameSinkId, surface_manager_.get(), this)),
+ root_factory_(new cc::SurfaceFactory(kRootFrameSinkId,
+ surface_manager_.get(),
+ this)),
+ child_factory_(new cc::SurfaceFactory(kChildFrameSinkId,
+ surface_manager_.get(),
+ this)),
begin_frame_source_(std::move(begin_frame_source)) {
DCHECK(registry_);
DCHECK(sender_);
@@ -168,8 +173,10 @@ bool SynchronousCompositorFrameSink::BindToClient(
base::Unretained(this)));
registry_->RegisterCompositorFrameSink(routing_id_, this);
- surface_manager_->RegisterFrameSinkId(kFrameSinkId);
- surface_manager_->RegisterSurfaceFactoryClient(kFrameSinkId, this);
+ surface_manager_->RegisterFrameSinkId(kRootFrameSinkId);
+ surface_manager_->RegisterFrameSinkId(kChildFrameSinkId);
+ surface_manager_->RegisterSurfaceFactoryClient(kRootFrameSinkId, this);
+ surface_manager_->RegisterSurfaceFactoryClient(kChildFrameSinkId, this);
cc::RendererSettings software_renderer_settings;
@@ -184,8 +191,9 @@ bool SynchronousCompositorFrameSink::BindToClient(
display_.reset(new cc::Display(
nullptr /* shared_bitmap_manager */,
nullptr /* gpu_memory_buffer_manager */, software_renderer_settings,
- kFrameSinkId, nullptr /* begin_frame_source */, std::move(output_surface),
- nullptr /* scheduler */, nullptr /* texture_mailbox_deleter */));
+ kRootFrameSinkId, nullptr /* begin_frame_source */,
+ std::move(output_surface), nullptr /* scheduler */,
+ nullptr /* texture_mailbox_deleter */));
display_->Initialize(&display_client_, surface_manager_.get());
display_->SetVisible(true);
return true;
@@ -198,15 +206,16 @@ void SynchronousCompositorFrameSink::DetachFromClient() {
begin_frame_source_ = nullptr;
registry_->UnregisterCompositorFrameSink(routing_id_, this);
client_->SetTreeActivationCallback(base::Closure());
- if (root_local_frame_id_.is_valid()) {
- surface_factory_->Destroy(root_local_frame_id_);
- surface_factory_->Destroy(child_local_frame_id_);
- }
- surface_manager_->UnregisterSurfaceFactoryClient(kFrameSinkId);
- surface_manager_->InvalidateFrameSinkId(kFrameSinkId);
+ root_factory_->EvictSurface();
+ child_factory_->EvictSurface();
+ surface_manager_->UnregisterSurfaceFactoryClient(kRootFrameSinkId);
+ surface_manager_->UnregisterSurfaceFactoryClient(kChildFrameSinkId);
+ surface_manager_->InvalidateFrameSinkId(kRootFrameSinkId);
+ surface_manager_->InvalidateFrameSinkId(kChildFrameSinkId);
software_output_surface_ = nullptr;
display_ = nullptr;
- surface_factory_ = nullptr;
+ child_factory_ = nullptr;
+ root_factory_ = nullptr;
surface_id_allocator_ = nullptr;
surface_manager_ = nullptr;
cc::CompositorFrameSink::DetachFromClient();
@@ -237,9 +246,7 @@ void SynchronousCompositorFrameSink::SubmitCompositorFrame(
if (!root_local_frame_id_.is_valid()) {
root_local_frame_id_ = surface_id_allocator_->GenerateId();
- surface_factory_->Create(root_local_frame_id_);
child_local_frame_id_ = surface_id_allocator_->GenerateId();
- surface_factory_->Create(child_local_frame_id_);
}
display_->SetLocalFrameId(root_local_frame_id_,
@@ -284,15 +291,15 @@ void SynchronousCompositorFrameSink::SubmitCompositorFrame(
child_transform, child_size, gfx::Rect(child_size),
gfx::Rect() /* clip_rect */, false /* is_clipped */, 1.f /* opacity */,
SkBlendMode::kSrcOver, 0 /* sorting_context_id */);
- surface_quad->SetNew(shared_quad_state, gfx::Rect(child_size),
- gfx::Rect(child_size),
- cc::SurfaceId(kFrameSinkId, child_local_frame_id_));
+ surface_quad->SetNew(
+ shared_quad_state, gfx::Rect(child_size), gfx::Rect(child_size),
+ cc::SurfaceId(kChildFrameSinkId, child_local_frame_id_));
- surface_factory_->SubmitCompositorFrame(
+ child_factory_->SubmitCompositorFrame(
child_local_frame_id_, std::move(frame), base::Bind(&NoOpDrawCallback));
- surface_factory_->SubmitCompositorFrame(root_local_frame_id_,
- std::move(embed_frame),
- base::Bind(&NoOpDrawCallback));
+ root_factory_->SubmitCompositorFrame(root_local_frame_id_,
+ std::move(embed_frame),
+ base::Bind(&NoOpDrawCallback));
display_->DrawAndSwap();
} else {
// For hardware draws we send the whole frame to the client so it can draw
« no previous file with comments | « content/renderer/android/synchronous_compositor_frame_sink.h ('k') | services/ui/surfaces/gpu_compositor_frame_sink.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698