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

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

Issue 1552723002: Convert Pass()→std::move() in //android_webview (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months 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>
8
7 #include "android_webview/browser/aw_gl_surface.h" 9 #include "android_webview/browser/aw_gl_surface.h"
8 #include "android_webview/browser/aw_render_thread_context_provider.h" 10 #include "android_webview/browser/aw_render_thread_context_provider.h"
9 #include "android_webview/browser/child_frame.h" 11 #include "android_webview/browser/child_frame.h"
10 #include "android_webview/browser/deferred_gpu_command_service.h" 12 #include "android_webview/browser/deferred_gpu_command_service.h"
11 #include "android_webview/browser/parent_compositor_draw_constraints.h" 13 #include "android_webview/browser/parent_compositor_draw_constraints.h"
12 #include "android_webview/browser/parent_output_surface.h" 14 #include "android_webview/browser/parent_output_surface.h"
13 #include "android_webview/browser/shared_renderer_state.h" 15 #include "android_webview/browser/shared_renderer_state.h"
14 #include "android_webview/public/browser/draw_gl.h" 16 #include "android_webview/public/browser/draw_gl.h"
15 #include "base/auto_reset.h" 17 #include "base/auto_reset.h"
16 #include "base/strings/string_number_conversions.h" 18 #include "base/strings/string_number_conversions.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 75
74 void HardwareRenderer::CommitFrame() { 76 void HardwareRenderer::CommitFrame() {
75 TRACE_EVENT0("android_webview", "CommitFrame"); 77 TRACE_EVENT0("android_webview", "CommitFrame");
76 scroll_offset_ = shared_renderer_state_->GetScrollOffsetOnRT(); 78 scroll_offset_ = shared_renderer_state_->GetScrollOffsetOnRT();
77 scoped_ptr<ChildFrame> child_frame = 79 scoped_ptr<ChildFrame> child_frame =
78 shared_renderer_state_->PassCompositorFrameOnRT(); 80 shared_renderer_state_->PassCompositorFrameOnRT();
79 if (!child_frame.get()) 81 if (!child_frame.get())
80 return; 82 return;
81 83
82 ReturnResourcesInChildFrame(); 84 ReturnResourcesInChildFrame();
83 child_frame_ = child_frame.Pass(); 85 child_frame_ = std::move(child_frame);
84 DCHECK(child_frame_->frame.get()); 86 DCHECK(child_frame_->frame.get());
85 DCHECK(!child_frame_->frame->gl_frame_data); 87 DCHECK(!child_frame_->frame->gl_frame_data);
86 } 88 }
87 89
88 void HardwareRenderer::DrawGL(bool stencil_enabled, 90 void HardwareRenderer::DrawGL(bool stencil_enabled,
89 AwDrawGLInfo* draw_info) { 91 AwDrawGLInfo* draw_info) {
90 TRACE_EVENT0("android_webview", "HardwareRenderer::DrawGL"); 92 TRACE_EVENT0("android_webview", "HardwareRenderer::DrawGL");
91 93
92 // We need to watch if the current Android context has changed and enforce 94 // We need to watch if the current Android context has changed and enforce
93 // a clean-up in the compositor. 95 // a clean-up in the compositor.
(...skipping 19 matching lines...) Expand all
113 child_id_ = cc::SurfaceId(); 115 child_id_ = cc::SurfaceId();
114 116
115 // This will return all the resources to the previous compositor. 117 // This will return all the resources to the previous compositor.
116 surface_factory_.reset(); 118 surface_factory_.reset();
117 compositor_id_ = child_frame_->compositor_id; 119 compositor_id_ = child_frame_->compositor_id;
118 surface_factory_.reset( 120 surface_factory_.reset(
119 new cc::SurfaceFactory(surface_manager_.get(), this)); 121 new cc::SurfaceFactory(surface_manager_.get(), this));
120 } 122 }
121 123
122 scoped_ptr<cc::CompositorFrame> child_compositor_frame = 124 scoped_ptr<cc::CompositorFrame> child_compositor_frame =
123 child_frame_->frame.Pass(); 125 std::move(child_frame_->frame);
124 126
125 // On Android we put our browser layers in physical pixels and set our 127 // On Android we put our browser layers in physical pixels and set our
126 // browser CC device_scale_factor to 1, so suppress the transform between 128 // browser CC device_scale_factor to 1, so suppress the transform between
127 // DIP and pixels. 129 // DIP and pixels.
128 child_compositor_frame->delegated_frame_data->device_scale_factor = 1.0f; 130 child_compositor_frame->delegated_frame_data->device_scale_factor = 1.0f;
129 131
130 gfx::Size frame_size = 132 gfx::Size frame_size =
131 child_compositor_frame->delegated_frame_data->render_pass_list.back() 133 child_compositor_frame->delegated_frame_data->render_pass_list.back()
132 ->output_rect.size(); 134 ->output_rect.size();
133 bool size_changed = frame_size != frame_size_; 135 bool size_changed = frame_size != frame_size_;
134 frame_size_ = frame_size; 136 frame_size_ = frame_size;
135 if (child_id_.is_null() || size_changed) { 137 if (child_id_.is_null() || size_changed) {
136 if (!child_id_.is_null()) 138 if (!child_id_.is_null())
137 surface_factory_->Destroy(child_id_); 139 surface_factory_->Destroy(child_id_);
138 child_id_ = surface_id_allocator_->GenerateId(); 140 child_id_ = surface_id_allocator_->GenerateId();
139 surface_factory_->Create(child_id_); 141 surface_factory_->Create(child_id_);
140 } 142 }
141 143
142 surface_factory_->SubmitCompositorFrame(child_id_, 144 surface_factory_->SubmitCompositorFrame(child_id_,
143 child_compositor_frame.Pass(), 145 std::move(child_compositor_frame),
144 cc::SurfaceFactory::DrawCallback()); 146 cc::SurfaceFactory::DrawCallback());
145 } 147 }
146 148
147 gfx::Transform transform(gfx::Transform::kSkipInitialization); 149 gfx::Transform transform(gfx::Transform::kSkipInitialization);
148 transform.matrix().setColMajorf(draw_info->transform); 150 transform.matrix().setColMajorf(draw_info->transform);
149 transform.Translate(scroll_offset_.x(), scroll_offset_.y()); 151 transform.Translate(scroll_offset_.x(), scroll_offset_.y());
150 152
151 gfx::Size viewport(draw_info->width, draw_info->height); 153 gfx::Size viewport(draw_info->width, draw_info->height);
152 // Need to post the new transform matrix back to child compositor 154 // Need to post the new transform matrix back to child compositor
153 // because there is no onDraw during a Render Thread animation, and child 155 // because there is no onDraw during a Render Thread animation, and child
(...skipping 25 matching lines...) Expand all
179 quad_state->visible_quad_layer_rect = gfx::Rect(frame_size_); 181 quad_state->visible_quad_layer_rect = gfx::Rect(frame_size_);
180 quad_state->opacity = 1.f; 182 quad_state->opacity = 1.f;
181 183
182 cc::SurfaceDrawQuad* surface_quad = 184 cc::SurfaceDrawQuad* surface_quad =
183 render_pass->CreateAndAppendDrawQuad<cc::SurfaceDrawQuad>(); 185 render_pass->CreateAndAppendDrawQuad<cc::SurfaceDrawQuad>();
184 surface_quad->SetNew(quad_state, gfx::Rect(quad_state->quad_layer_bounds), 186 surface_quad->SetNew(quad_state, gfx::Rect(quad_state->quad_layer_bounds),
185 gfx::Rect(quad_state->quad_layer_bounds), child_id_); 187 gfx::Rect(quad_state->quad_layer_bounds), child_id_);
186 188
187 scoped_ptr<cc::DelegatedFrameData> delegated_frame( 189 scoped_ptr<cc::DelegatedFrameData> delegated_frame(
188 new cc::DelegatedFrameData); 190 new cc::DelegatedFrameData);
189 delegated_frame->render_pass_list.push_back(render_pass.Pass()); 191 delegated_frame->render_pass_list.push_back(std::move(render_pass));
190 scoped_ptr<cc::CompositorFrame> frame(new cc::CompositorFrame); 192 scoped_ptr<cc::CompositorFrame> frame(new cc::CompositorFrame);
191 frame->delegated_frame_data = delegated_frame.Pass(); 193 frame->delegated_frame_data = std::move(delegated_frame);
192 194
193 if (root_id_.is_null()) { 195 if (root_id_.is_null()) {
194 root_id_ = surface_id_allocator_->GenerateId(); 196 root_id_ = surface_id_allocator_->GenerateId();
195 surface_factory_->Create(root_id_); 197 surface_factory_->Create(root_id_);
196 display_->SetSurfaceId(root_id_, 1.f); 198 display_->SetSurfaceId(root_id_, 1.f);
197 } 199 }
198 surface_factory_->SubmitCompositorFrame(root_id_, frame.Pass(), 200 surface_factory_->SubmitCompositorFrame(root_id_, std::move(frame),
199 cc::SurfaceFactory::DrawCallback()); 201 cc::SurfaceFactory::DrawCallback());
200 202
201 display_->Resize(viewport); 203 display_->Resize(viewport);
202 204
203 if (!output_surface_) { 205 if (!output_surface_) {
204 scoped_refptr<cc::ContextProvider> context_provider = 206 scoped_refptr<cc::ContextProvider> context_provider =
205 AwRenderThreadContextProvider::Create( 207 AwRenderThreadContextProvider::Create(
206 gl_surface_, DeferredGpuCommandService::GetInstance()); 208 gl_surface_, DeferredGpuCommandService::GetInstance());
207 scoped_ptr<ParentOutputSurface> output_surface_holder( 209 scoped_ptr<ParentOutputSurface> output_surface_holder(
208 new ParentOutputSurface(context_provider)); 210 new ParentOutputSurface(context_provider));
209 output_surface_ = output_surface_holder.get(); 211 output_surface_ = output_surface_holder.get();
210 display_->Initialize(output_surface_holder.Pass(), nullptr); 212 display_->Initialize(std::move(output_surface_holder), nullptr);
211 } 213 }
212 output_surface_->SetExternalStencilTest(stencil_enabled); 214 output_surface_->SetExternalStencilTest(stencil_enabled);
213 display_->SetExternalClip(clip); 215 display_->SetExternalClip(clip);
214 display_->DrawAndSwap(); 216 display_->DrawAndSwap();
215 } 217 }
216 218
217 void HardwareRenderer::ReturnResources( 219 void HardwareRenderer::ReturnResources(
218 const cc::ReturnedResourceArray& resources) { 220 const cc::ReturnedResourceArray& resources) {
219 ReturnResourcesToCompositor(resources, compositor_id_); 221 ReturnResourcesToCompositor(resources, compositor_id_);
220 } 222 }
(...skipping 24 matching lines...) Expand all
245 child_frame_.reset(); 247 child_frame_.reset();
246 } 248 }
247 249
248 void HardwareRenderer::ReturnResourcesToCompositor( 250 void HardwareRenderer::ReturnResourcesToCompositor(
249 const cc::ReturnedResourceArray& resources, 251 const cc::ReturnedResourceArray& resources,
250 unsigned int compositor_id) { 252 unsigned int compositor_id) {
251 shared_renderer_state_->InsertReturnedResourcesOnRT(resources, compositor_id); 253 shared_renderer_state_->InsertReturnedResourcesOnRT(resources, compositor_id);
252 } 254 }
253 255
254 } // namespace android_webview 256 } // namespace android_webview
OLDNEW
« no previous file with comments | « android_webview/browser/child_frame.cc ('k') | android_webview/browser/net/android_stream_reader_url_request_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698