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

Side by Side Diff: cc/surfaces/direct_compositor_frame_sink.cc

Issue 2485473003: Remove SurfaceFactory::Create and SurfaceFactory::Destroy (Closed)
Patch Set: up Created 4 years 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 unified diff | Download patch
« no previous file with comments | « blimp/client/core/compositor/blimp_compositor.cc ('k') | cc/surfaces/display_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/surfaces/direct_compositor_frame_sink.h" 5 #include "cc/surfaces/direct_compositor_frame_sink.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "cc/output/compositor_frame.h" 8 #include "cc/output/compositor_frame.h"
9 #include "cc/output/compositor_frame_sink_client.h" 9 #include "cc/output/compositor_frame_sink_client.h"
10 #include "cc/surfaces/display.h" 10 #include "cc/surfaces/display.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 // Avoid initializing GL context here, as this should be sharing the 75 // Avoid initializing GL context here, as this should be sharing the
76 // Display's context. 76 // Display's context.
77 display_->Initialize(this, surface_manager_); 77 display_->Initialize(this, surface_manager_);
78 return true; 78 return true;
79 } 79 }
80 80
81 void DirectCompositorFrameSink::DetachFromClient() { 81 void DirectCompositorFrameSink::DetachFromClient() {
82 // Unregister the SurfaceFactoryClient here instead of the dtor so that only 82 // Unregister the SurfaceFactoryClient here instead of the dtor so that only
83 // one client is alive for this namespace at any given time. 83 // one client is alive for this namespace at any given time.
84 surface_manager_->UnregisterSurfaceFactoryClient(frame_sink_id_); 84 surface_manager_->UnregisterSurfaceFactoryClient(frame_sink_id_);
85 if (delegated_local_frame_id_.is_valid()) 85 factory_.EvictSurface();
86 factory_.Destroy(delegated_local_frame_id_);
87 86
88 CompositorFrameSink::DetachFromClient(); 87 CompositorFrameSink::DetachFromClient();
89 } 88 }
90 89
91 void DirectCompositorFrameSink::SubmitCompositorFrame(CompositorFrame frame) { 90 void DirectCompositorFrameSink::SubmitCompositorFrame(CompositorFrame frame) {
92 gfx::Size frame_size = frame.render_pass_list.back()->output_rect.size(); 91 gfx::Size frame_size = frame.render_pass_list.back()->output_rect.size();
93 if (frame_size.IsEmpty() || frame_size != last_swap_frame_size_) { 92 if (frame_size.IsEmpty() || frame_size != last_swap_frame_size_) {
94 if (delegated_local_frame_id_.is_valid()) {
95 factory_.Destroy(delegated_local_frame_id_);
96 }
97 delegated_local_frame_id_ = surface_id_allocator_.GenerateId(); 93 delegated_local_frame_id_ = surface_id_allocator_.GenerateId();
98 factory_.Create(delegated_local_frame_id_);
99 last_swap_frame_size_ = frame_size; 94 last_swap_frame_size_ = frame_size;
100 } 95 }
101 display_->SetLocalFrameId(delegated_local_frame_id_, 96 display_->SetLocalFrameId(delegated_local_frame_id_,
102 frame.metadata.device_scale_factor); 97 frame.metadata.device_scale_factor);
103 98
104 factory_.SubmitCompositorFrame( 99 factory_.SubmitCompositorFrame(
105 delegated_local_frame_id_, std::move(frame), 100 delegated_local_frame_id_, std::move(frame),
106 base::Bind(&DirectCompositorFrameSink::DidDrawCallback, 101 base::Bind(&DirectCompositorFrameSink::DidDrawCallback,
107 base::Unretained(this))); 102 base::Unretained(this)));
108 } 103 }
109 104
110 void DirectCompositorFrameSink::ForceReclaimResources() { 105 void DirectCompositorFrameSink::ForceReclaimResources() {
111 if (delegated_local_frame_id_.is_valid()) 106 if (delegated_local_frame_id_.is_valid())
112 factory_.ClearSurface(delegated_local_frame_id_); 107 factory_.ClearSurface();
113 } 108 }
114 109
115 void DirectCompositorFrameSink::ReturnResources( 110 void DirectCompositorFrameSink::ReturnResources(
116 const ReturnedResourceArray& resources) { 111 const ReturnedResourceArray& resources) {
117 if (client_) 112 if (client_)
118 client_->ReclaimResources(resources); 113 client_->ReclaimResources(resources);
119 } 114 }
120 115
121 void DirectCompositorFrameSink::SetBeginFrameSource( 116 void DirectCompositorFrameSink::SetBeginFrameSource(
122 BeginFrameSource* begin_frame_source) { 117 BeginFrameSource* begin_frame_source) {
(...skipping 16 matching lines...) Expand all
139 // This notification is not relevant to our client outside of tests. We 134 // This notification is not relevant to our client outside of tests. We
140 // unblock the client from DidDrawCallback() when the surface is going to 135 // unblock the client from DidDrawCallback() when the surface is going to
141 // be drawn. 136 // be drawn.
142 } 137 }
143 138
144 void DirectCompositorFrameSink::DidDrawCallback() { 139 void DirectCompositorFrameSink::DidDrawCallback() {
145 client_->DidReceiveCompositorFrameAck(); 140 client_->DidReceiveCompositorFrameAck();
146 } 141 }
147 142
148 } // namespace cc 143 } // namespace cc
OLDNEW
« no previous file with comments | « blimp/client/core/compositor/blimp_compositor.cc ('k') | cc/surfaces/display_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698