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 "android_webview/browser/aw_gl_surface.h" | 7 #include "android_webview/browser/aw_gl_surface.h" |
8 #include "android_webview/browser/deferred_gpu_command_service.h" | 8 #include "android_webview/browser/deferred_gpu_command_service.h" |
9 #include "android_webview/browser/parent_output_surface.h" | 9 #include "android_webview/browser/parent_output_surface.h" |
10 #include "android_webview/browser/shared_renderer_state.h" | 10 #include "android_webview/browser/shared_renderer_state.h" |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 // This is called after OutputSurface is created, but before the impl frame | 132 // This is called after OutputSurface is created, but before the impl frame |
133 // starts. We set the draw constraints here. | 133 // starts. We set the draw constraints here. |
134 DCHECK(output_surface_); | 134 DCHECK(output_surface_); |
135 DCHECK(viewport_clip_valid_for_dcheck_); | 135 DCHECK(viewport_clip_valid_for_dcheck_); |
136 output_surface_->SetExternalStencilTest(stencil_enabled_); | 136 output_surface_->SetExternalStencilTest(stencil_enabled_); |
137 output_surface_->SetDrawConstraints(viewport_, clip_); | 137 output_surface_->SetDrawConstraints(viewport_, clip_); |
138 } | 138 } |
139 | 139 |
140 void HardwareRenderer::CommitFrame() { | 140 void HardwareRenderer::CommitFrame() { |
141 scoped_ptr<DrawGLInput> input = shared_renderer_state_->PassDrawGLInput(); | 141 scoped_ptr<DrawGLInput> input = shared_renderer_state_->PassDrawGLInput(); |
142 if (!input.get()) { | 142 // Happens with empty global visible rect. |
143 DLOG(WARNING) << "No frame to commit"; | 143 if (!input.get()) |
144 return; | 144 return; |
145 } | |
146 | 145 |
147 DCHECK(!input->frame.gl_frame_data); | 146 DCHECK(!input->frame.gl_frame_data); |
148 DCHECK(!input->frame.software_frame_data); | 147 DCHECK(!input->frame.software_frame_data); |
149 | 148 |
150 // DelegatedRendererLayerImpl applies the inverse device_scale_factor of the | 149 // DelegatedRendererLayerImpl applies the inverse device_scale_factor of the |
151 // renderer frame, assuming that the browser compositor will scale | 150 // renderer frame, assuming that the browser compositor will scale |
152 // it back up to device scale. But on Android we put our browser layers in | 151 // it back up to device scale. But on Android we put our browser layers in |
153 // physical pixels and set our browser CC device_scale_factor to 1, so this | 152 // physical pixels and set our browser CC device_scale_factor to 1, so this |
154 // suppresses the transform. | 153 // suppresses the transform. |
155 input->frame.delegated_frame_data->device_scale_factor = 1.0f; | 154 input->frame.delegated_frame_data->device_scale_factor = 1.0f; |
(...skipping 29 matching lines...) Expand all Loading... |
185 TRACE_EVENT0("android_webview", "HardwareRenderer::DrawGL"); | 184 TRACE_EVENT0("android_webview", "HardwareRenderer::DrawGL"); |
186 | 185 |
187 // We need to watch if the current Android context has changed and enforce | 186 // We need to watch if the current Android context has changed and enforce |
188 // a clean-up in the compositor. | 187 // a clean-up in the compositor. |
189 EGLContext current_context = eglGetCurrentContext(); | 188 EGLContext current_context = eglGetCurrentContext(); |
190 if (!current_context) { | 189 if (!current_context) { |
191 DLOG(ERROR) << "DrawGL called without EGLContext"; | 190 DLOG(ERROR) << "DrawGL called without EGLContext"; |
192 return; | 191 return; |
193 } | 192 } |
194 | 193 |
195 if (!delegated_layer_.get()) { | |
196 DLOG(ERROR) << "No frame committed"; | |
197 return; | |
198 } | |
199 | |
200 // TODO(boliu): Handle context loss. | 194 // TODO(boliu): Handle context loss. |
201 if (last_egl_context_ != current_context) | 195 if (last_egl_context_ != current_context) |
202 DLOG(WARNING) << "EGLContextChanged"; | 196 DLOG(WARNING) << "EGLContextChanged"; |
203 | 197 |
204 gfx::Transform transform(gfx::Transform::kSkipInitialization); | 198 gfx::Transform transform(gfx::Transform::kSkipInitialization); |
205 transform.matrix().setColMajorf(draw_info->transform); | 199 transform.matrix().setColMajorf(draw_info->transform); |
206 transform.Translate(scroll_offset_.x(), scroll_offset_.y()); | 200 transform.Translate(scroll_offset_.x(), scroll_offset_.y()); |
207 | 201 |
208 // Need to post the new transform matrix back to child compositor | 202 // Need to post the new transform matrix back to child compositor |
209 // because there is no onDraw during a Render Thread animation, and child | 203 // because there is no onDraw during a Render Thread animation, and child |
210 // compositor might not have the tiles rasterized as the animation goes on. | 204 // compositor might not have the tiles rasterized as the animation goes on. |
211 ParentCompositorDrawConstraints draw_constraints( | 205 ParentCompositorDrawConstraints draw_constraints( |
212 draw_info->is_layer, transform, gfx::Rect(viewport_)); | 206 draw_info->is_layer, transform, gfx::Rect(viewport_)); |
213 if (!draw_constraints_.Equals(draw_constraints)) { | 207 if (!draw_constraints_.Equals(draw_constraints)) { |
214 draw_constraints_ = draw_constraints; | 208 draw_constraints_ = draw_constraints; |
215 shared_renderer_state_->PostExternalDrawConstraintsToChildCompositor( | 209 shared_renderer_state_->PostExternalDrawConstraintsToChildCompositor( |
216 draw_constraints); | 210 draw_constraints); |
217 } | 211 } |
218 | 212 |
| 213 if (!delegated_layer_.get()) |
| 214 return; |
| 215 |
219 viewport_.SetSize(draw_info->width, draw_info->height); | 216 viewport_.SetSize(draw_info->width, draw_info->height); |
220 layer_tree_host_->SetViewportSize(viewport_); | 217 layer_tree_host_->SetViewportSize(viewport_); |
221 clip_.SetRect(draw_info->clip_left, | 218 clip_.SetRect(draw_info->clip_left, |
222 draw_info->clip_top, | 219 draw_info->clip_top, |
223 draw_info->clip_right - draw_info->clip_left, | 220 draw_info->clip_right - draw_info->clip_left, |
224 draw_info->clip_bottom - draw_info->clip_top); | 221 draw_info->clip_bottom - draw_info->clip_top); |
225 stencil_enabled_ = stencil_enabled; | 222 stencil_enabled_ = stencil_enabled; |
226 | 223 |
227 delegated_layer_->SetTransform(transform); | 224 delegated_layer_->SetTransform(transform); |
228 | 225 |
(...skipping 22 matching lines...) Expand all Loading... |
251 } | 248 } |
252 | 249 |
253 void HardwareRenderer::UnusedResourcesAreAvailable() { | 250 void HardwareRenderer::UnusedResourcesAreAvailable() { |
254 cc::ReturnedResourceArray returned_resources; | 251 cc::ReturnedResourceArray returned_resources; |
255 resource_collection_->TakeUnusedResourcesForChildCompositor( | 252 resource_collection_->TakeUnusedResourcesForChildCompositor( |
256 &returned_resources); | 253 &returned_resources); |
257 shared_renderer_state_->InsertReturnedResources(returned_resources); | 254 shared_renderer_state_->InsertReturnedResources(returned_resources); |
258 } | 255 } |
259 | 256 |
260 } // namespace android_webview | 257 } // namespace android_webview |
OLD | NEW |