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

Side by Side Diff: android_webview/browser/hardware_renderer.cc

Issue 2449853004: Getting rid of DelegatedFrameData (Closed)
Patch Set: IsEmpty + rebase 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 unified diff | Download patch
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 "android_webview/browser/hardware_renderer.h" 5 #include "android_webview/browser/hardware_renderer.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "android_webview/browser/aw_gl_surface.h" 9 #include "android_webview/browser/aw_gl_surface.h"
10 #include "android_webview/browser/aw_render_thread_context_provider.h" 10 #include "android_webview/browser/aw_render_thread_context_provider.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 last_submitted_compositor_frame_sink_id_ = 116 last_submitted_compositor_frame_sink_id_ =
117 child_frame_->compositor_frame_sink_id; 117 child_frame_->compositor_frame_sink_id;
118 surface_factory_.reset(new cc::SurfaceFactory( 118 surface_factory_.reset(new cc::SurfaceFactory(
119 frame_sink_id_, surfaces_->GetSurfaceManager(), this)); 119 frame_sink_id_, surfaces_->GetSurfaceManager(), this));
120 } 120 }
121 121
122 std::unique_ptr<cc::CompositorFrame> child_compositor_frame = 122 std::unique_ptr<cc::CompositorFrame> child_compositor_frame =
123 std::move(child_frame_->frame); 123 std::move(child_frame_->frame);
124 124
125 gfx::Size frame_size = 125 gfx::Size frame_size =
126 child_compositor_frame->delegated_frame_data->render_pass_list.back() 126 child_compositor_frame->render_pass_list.back()->output_rect.size();
127 ->output_rect.size();
128 bool size_changed = frame_size != frame_size_; 127 bool size_changed = frame_size != frame_size_;
129 frame_size_ = frame_size; 128 frame_size_ = frame_size;
130 if (child_id_.is_null() || size_changed) { 129 if (child_id_.is_null() || size_changed) {
131 if (!child_id_.is_null()) 130 if (!child_id_.is_null())
132 DestroySurface(); 131 DestroySurface();
133 AllocateSurface(); 132 AllocateSurface();
134 } 133 }
135 134
136 surface_factory_->SubmitCompositorFrame(child_id_, 135 surface_factory_->SubmitCompositorFrame(child_id_,
137 std::move(*child_compositor_frame), 136 std::move(*child_compositor_frame),
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 child_id_ = surface_id_allocator_->GenerateId(); 168 child_id_ = surface_id_allocator_->GenerateId();
170 surface_factory_->Create(child_id_); 169 surface_factory_->Create(child_id_);
171 surfaces_->AddChildId(cc::SurfaceId(frame_sink_id_, child_id_)); 170 surfaces_->AddChildId(cc::SurfaceId(frame_sink_id_, child_id_));
172 } 171 }
173 172
174 void HardwareRenderer::DestroySurface() { 173 void HardwareRenderer::DestroySurface() {
175 DCHECK(!child_id_.is_null()); 174 DCHECK(!child_id_.is_null());
176 DCHECK(surface_factory_); 175 DCHECK(surface_factory_);
177 176
178 // Submit an empty frame to force any existing resources to be returned. 177 // Submit an empty frame to force any existing resources to be returned.
179 cc::CompositorFrame empty_frame; 178 cc::CompositorFrame empty_frame;
danakj 2016/10/27 23:06:56 no need for this variable, just pass cc::Composito
Saman Sami 2016/10/28 16:47:35 Done.
180 empty_frame.delegated_frame_data =
181 base::WrapUnique(new cc::DelegatedFrameData);
182 surface_factory_->SubmitCompositorFrame(child_id_, std::move(empty_frame), 179 surface_factory_->SubmitCompositorFrame(child_id_, std::move(empty_frame),
183 cc::SurfaceFactory::DrawCallback()); 180 cc::SurfaceFactory::DrawCallback());
184 181
185 surfaces_->RemoveChildId(cc::SurfaceId(frame_sink_id_, child_id_)); 182 surfaces_->RemoveChildId(cc::SurfaceId(frame_sink_id_, child_id_));
186 surface_factory_->Destroy(child_id_); 183 surface_factory_->Destroy(child_id_);
187 child_id_ = cc::LocalFrameId(); 184 child_id_ = cc::LocalFrameId();
188 } 185 }
189 186
190 void HardwareRenderer::ReturnResources( 187 void HardwareRenderer::ReturnResources(
191 const cc::ReturnedResourceArray& resources) { 188 const cc::ReturnedResourceArray& resources) {
192 ReturnResourcesToCompositor(resources, compositor_id_, 189 ReturnResourcesToCompositor(resources, compositor_id_,
193 last_submitted_compositor_frame_sink_id_); 190 last_submitted_compositor_frame_sink_id_);
194 } 191 }
195 192
196 void HardwareRenderer::SetBeginFrameSource( 193 void HardwareRenderer::SetBeginFrameSource(
197 cc::BeginFrameSource* begin_frame_source) { 194 cc::BeginFrameSource* begin_frame_source) {
198 // TODO(tansell): Hook this up. 195 // TODO(tansell): Hook this up.
199 } 196 }
200 197
201 void HardwareRenderer::ReturnResourcesInChildFrame() { 198 void HardwareRenderer::ReturnResourcesInChildFrame() {
202 if (child_frame_.get() && child_frame_->frame.get()) { 199 if (child_frame_.get() && child_frame_->frame.get()) {
203 cc::ReturnedResourceArray resources_to_return; 200 cc::ReturnedResourceArray resources_to_return;
204 cc::TransferableResource::ReturnResources( 201 cc::TransferableResource::ReturnResources(
205 child_frame_->frame->delegated_frame_data->resource_list, 202 child_frame_->frame->resource_list, &resources_to_return);
206 &resources_to_return);
207 203
208 // The child frame's compositor id is not necessarily same as 204 // The child frame's compositor id is not necessarily same as
209 // compositor_id_. 205 // compositor_id_.
210 ReturnResourcesToCompositor(resources_to_return, 206 ReturnResourcesToCompositor(resources_to_return,
211 child_frame_->compositor_id, 207 child_frame_->compositor_id,
212 child_frame_->compositor_frame_sink_id); 208 child_frame_->compositor_frame_sink_id);
213 } 209 }
214 child_frame_.reset(); 210 child_frame_.reset();
215 } 211 }
216 212
217 void HardwareRenderer::ReturnResourcesToCompositor( 213 void HardwareRenderer::ReturnResourcesToCompositor(
218 const cc::ReturnedResourceArray& resources, 214 const cc::ReturnedResourceArray& resources,
219 const CompositorID& compositor_id, 215 const CompositorID& compositor_id,
220 uint32_t compositor_frame_sink_id) { 216 uint32_t compositor_frame_sink_id) {
221 if (compositor_frame_sink_id != last_committed_compositor_frame_sink_id_) 217 if (compositor_frame_sink_id != last_committed_compositor_frame_sink_id_)
222 return; 218 return;
223 render_thread_manager_->InsertReturnedResourcesOnRT(resources, compositor_id, 219 render_thread_manager_->InsertReturnedResourcesOnRT(resources, compositor_id,
224 compositor_frame_sink_id); 220 compositor_frame_sink_id);
225 } 221 }
226 222
227 } // namespace android_webview 223 } // namespace android_webview
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698