OLD | NEW |
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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 | 76 |
77 // Reset draw constraints. | 77 // Reset draw constraints. |
78 shared_renderer_state_->PostExternalDrawConstraintsToChildCompositorOnRT( | 78 shared_renderer_state_->PostExternalDrawConstraintsToChildCompositorOnRT( |
79 ParentCompositorDrawConstraints()); | 79 ParentCompositorDrawConstraints()); |
80 ReturnResourcesInChildFrame(); | 80 ReturnResourcesInChildFrame(); |
81 } | 81 } |
82 | 82 |
83 void HardwareRenderer::CommitFrame() { | 83 void HardwareRenderer::CommitFrame() { |
84 TRACE_EVENT0("android_webview", "CommitFrame"); | 84 TRACE_EVENT0("android_webview", "CommitFrame"); |
85 scroll_offset_ = shared_renderer_state_->GetScrollOffsetOnRT(); | 85 scroll_offset_ = shared_renderer_state_->GetScrollOffsetOnRT(); |
86 scoped_ptr<ChildFrame> child_frame = shared_renderer_state_->PassFrameOnRT(); | 86 std::unique_ptr<ChildFrame> child_frame = |
| 87 shared_renderer_state_->PassFrameOnRT(); |
87 if (!child_frame.get()) | 88 if (!child_frame.get()) |
88 return; | 89 return; |
89 | 90 |
90 last_committed_output_surface_id_ = child_frame->output_surface_id; | 91 last_committed_output_surface_id_ = child_frame->output_surface_id; |
91 ReturnResourcesInChildFrame(); | 92 ReturnResourcesInChildFrame(); |
92 child_frame_ = std::move(child_frame); | 93 child_frame_ = std::move(child_frame); |
93 DCHECK(child_frame_->frame.get()); | 94 DCHECK(child_frame_->frame.get()); |
94 DCHECK(!child_frame_->frame->gl_frame_data); | 95 DCHECK(!child_frame_->frame->gl_frame_data); |
95 } | 96 } |
96 | 97 |
(...skipping 26 matching lines...) Expand all Loading... |
123 child_id_ = cc::SurfaceId(); | 124 child_id_ = cc::SurfaceId(); |
124 | 125 |
125 // This will return all the resources to the previous compositor. | 126 // This will return all the resources to the previous compositor. |
126 surface_factory_.reset(); | 127 surface_factory_.reset(); |
127 compositor_id_ = child_frame_->compositor_id; | 128 compositor_id_ = child_frame_->compositor_id; |
128 last_submitted_output_surface_id_ = child_frame_->output_surface_id; | 129 last_submitted_output_surface_id_ = child_frame_->output_surface_id; |
129 surface_factory_.reset( | 130 surface_factory_.reset( |
130 new cc::SurfaceFactory(surface_manager_.get(), this)); | 131 new cc::SurfaceFactory(surface_manager_.get(), this)); |
131 } | 132 } |
132 | 133 |
133 scoped_ptr<cc::CompositorFrame> child_compositor_frame = | 134 std::unique_ptr<cc::CompositorFrame> child_compositor_frame = |
134 std::move(child_frame_->frame); | 135 std::move(child_frame_->frame); |
135 | 136 |
136 // On Android we put our browser layers in physical pixels and set our | 137 // On Android we put our browser layers in physical pixels and set our |
137 // browser CC device_scale_factor to 1, so suppress the transform between | 138 // browser CC device_scale_factor to 1, so suppress the transform between |
138 // DIP and pixels. | 139 // DIP and pixels. |
139 child_compositor_frame->delegated_frame_data->device_scale_factor = 1.0f; | 140 child_compositor_frame->delegated_frame_data->device_scale_factor = 1.0f; |
140 | 141 |
141 gfx::Size frame_size = | 142 gfx::Size frame_size = |
142 child_compositor_frame->delegated_frame_data->render_pass_list.back() | 143 child_compositor_frame->delegated_frame_data->render_pass_list.back() |
143 ->output_rect.size(); | 144 ->output_rect.size(); |
(...skipping 28 matching lines...) Expand all Loading... |
172 | 173 |
173 if (child_id_.is_null()) | 174 if (child_id_.is_null()) |
174 return; | 175 return; |
175 | 176 |
176 gfx::Rect clip(draw_info->clip_left, draw_info->clip_top, | 177 gfx::Rect clip(draw_info->clip_left, draw_info->clip_top, |
177 draw_info->clip_right - draw_info->clip_left, | 178 draw_info->clip_right - draw_info->clip_left, |
178 draw_info->clip_bottom - draw_info->clip_top); | 179 draw_info->clip_bottom - draw_info->clip_top); |
179 | 180 |
180 // Create a frame with a single SurfaceDrawQuad referencing the child | 181 // Create a frame with a single SurfaceDrawQuad referencing the child |
181 // Surface and transformed using the given transform. | 182 // Surface and transformed using the given transform. |
182 scoped_ptr<cc::RenderPass> render_pass = cc::RenderPass::Create(); | 183 std::unique_ptr<cc::RenderPass> render_pass = cc::RenderPass::Create(); |
183 render_pass->SetAll(cc::RenderPassId(1, 1), gfx::Rect(viewport), clip, | 184 render_pass->SetAll(cc::RenderPassId(1, 1), gfx::Rect(viewport), clip, |
184 gfx::Transform(), false); | 185 gfx::Transform(), false); |
185 | 186 |
186 cc::SharedQuadState* quad_state = | 187 cc::SharedQuadState* quad_state = |
187 render_pass->CreateAndAppendSharedQuadState(); | 188 render_pass->CreateAndAppendSharedQuadState(); |
188 quad_state->quad_to_target_transform = transform; | 189 quad_state->quad_to_target_transform = transform; |
189 quad_state->quad_layer_bounds = frame_size_; | 190 quad_state->quad_layer_bounds = frame_size_; |
190 quad_state->visible_quad_layer_rect = gfx::Rect(frame_size_); | 191 quad_state->visible_quad_layer_rect = gfx::Rect(frame_size_); |
191 quad_state->opacity = 1.f; | 192 quad_state->opacity = 1.f; |
192 | 193 |
193 cc::SurfaceDrawQuad* surface_quad = | 194 cc::SurfaceDrawQuad* surface_quad = |
194 render_pass->CreateAndAppendDrawQuad<cc::SurfaceDrawQuad>(); | 195 render_pass->CreateAndAppendDrawQuad<cc::SurfaceDrawQuad>(); |
195 surface_quad->SetNew(quad_state, gfx::Rect(quad_state->quad_layer_bounds), | 196 surface_quad->SetNew(quad_state, gfx::Rect(quad_state->quad_layer_bounds), |
196 gfx::Rect(quad_state->quad_layer_bounds), child_id_); | 197 gfx::Rect(quad_state->quad_layer_bounds), child_id_); |
197 | 198 |
198 scoped_ptr<cc::DelegatedFrameData> delegated_frame( | 199 std::unique_ptr<cc::DelegatedFrameData> delegated_frame( |
199 new cc::DelegatedFrameData); | 200 new cc::DelegatedFrameData); |
200 delegated_frame->render_pass_list.push_back(std::move(render_pass)); | 201 delegated_frame->render_pass_list.push_back(std::move(render_pass)); |
201 scoped_ptr<cc::CompositorFrame> frame(new cc::CompositorFrame); | 202 std::unique_ptr<cc::CompositorFrame> frame(new cc::CompositorFrame); |
202 frame->delegated_frame_data = std::move(delegated_frame); | 203 frame->delegated_frame_data = std::move(delegated_frame); |
203 | 204 |
204 if (root_id_.is_null()) { | 205 if (root_id_.is_null()) { |
205 root_id_ = surface_id_allocator_->GenerateId(); | 206 root_id_ = surface_id_allocator_->GenerateId(); |
206 surface_factory_->Create(root_id_); | 207 surface_factory_->Create(root_id_); |
207 display_->SetSurfaceId(root_id_, 1.f); | 208 display_->SetSurfaceId(root_id_, 1.f); |
208 } | 209 } |
209 surface_factory_->SubmitCompositorFrame(root_id_, std::move(frame), | 210 surface_factory_->SubmitCompositorFrame(root_id_, std::move(frame), |
210 cc::SurfaceFactory::DrawCallback()); | 211 cc::SurfaceFactory::DrawCallback()); |
211 | 212 |
212 display_->Resize(viewport); | 213 display_->Resize(viewport); |
213 | 214 |
214 if (!output_surface_) { | 215 if (!output_surface_) { |
215 scoped_refptr<cc::ContextProvider> context_provider = | 216 scoped_refptr<cc::ContextProvider> context_provider = |
216 AwRenderThreadContextProvider::Create( | 217 AwRenderThreadContextProvider::Create( |
217 gl_surface_, DeferredGpuCommandService::GetInstance()); | 218 gl_surface_, DeferredGpuCommandService::GetInstance()); |
218 scoped_ptr<ParentOutputSurface> output_surface_holder( | 219 std::unique_ptr<ParentOutputSurface> output_surface_holder( |
219 new ParentOutputSurface(context_provider)); | 220 new ParentOutputSurface(context_provider)); |
220 output_surface_ = output_surface_holder.get(); | 221 output_surface_ = output_surface_holder.get(); |
221 display_->Initialize(std::move(output_surface_holder), nullptr); | 222 display_->Initialize(std::move(output_surface_holder), nullptr); |
222 } | 223 } |
223 output_surface_->SetGLState(gl_state); | 224 output_surface_->SetGLState(gl_state); |
224 display_->SetExternalClip(clip); | 225 display_->SetExternalClip(clip); |
225 display_->DrawAndSwap(); | 226 display_->DrawAndSwap(); |
226 } | 227 } |
227 | 228 |
228 void HardwareRenderer::ReturnResources( | 229 void HardwareRenderer::ReturnResources( |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 const cc::ReturnedResourceArray& resources, | 262 const cc::ReturnedResourceArray& resources, |
262 uint32_t compositor_id, | 263 uint32_t compositor_id, |
263 uint32_t output_surface_id) { | 264 uint32_t output_surface_id) { |
264 if (output_surface_id != last_committed_output_surface_id_) | 265 if (output_surface_id != last_committed_output_surface_id_) |
265 return; | 266 return; |
266 shared_renderer_state_->InsertReturnedResourcesOnRT(resources, compositor_id, | 267 shared_renderer_state_->InsertReturnedResourcesOnRT(resources, compositor_id, |
267 output_surface_id); | 268 output_surface_id); |
268 } | 269 } |
269 | 270 |
270 } // namespace android_webview | 271 } // namespace android_webview |
OLD | NEW |