Chromium Code Reviews| 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 133 // This is called after OutputSurface is created, but before the impl frame | 133 // This is called after OutputSurface is created, but before the impl frame |
| 134 // starts. We set the draw constraints here. | 134 // starts. We set the draw constraints here. |
| 135 DCHECK(output_surface_); | 135 DCHECK(output_surface_); |
| 136 DCHECK(viewport_clip_valid_for_dcheck_); | 136 DCHECK(viewport_clip_valid_for_dcheck_); |
| 137 output_surface_->SetExternalStencilTest(stencil_enabled_); | 137 output_surface_->SetExternalStencilTest(stencil_enabled_); |
| 138 output_surface_->SetDrawConstraints(viewport_, clip_); | 138 output_surface_->SetDrawConstraints(viewport_, clip_); |
| 139 } | 139 } |
| 140 | 140 |
| 141 void HardwareRenderer::CommitFrame() { | 141 void HardwareRenderer::CommitFrame() { |
| 142 scroll_offset_ = shared_renderer_state_->GetScrollOffset(); | 142 scroll_offset_ = shared_renderer_state_->GetScrollOffset(); |
| 143 if (committed_frame_.get()) { | 143 if (committed_frame_.get() && !shared_renderer_state_->ForceCommit()) { |
| 144 TRACE_EVENT_INSTANT0("android_webview", | 144 TRACE_EVENT_INSTANT0("android_webview", |
| 145 "EarlyOut_PreviousFrameUnconsumed", | 145 "EarlyOut_PreviousFrameUnconsumed", |
| 146 TRACE_EVENT_SCOPE_THREAD); | 146 TRACE_EVENT_SCOPE_THREAD); |
| 147 return; | 147 return; |
| 148 } | 148 } |
| 149 | 149 |
| 150 committed_frame_ = shared_renderer_state_->PassCompositorFrame(); | 150 committed_frame_ = shared_renderer_state_->PassCompositorFrame(); |
|
hush (inactive)
2014/10/15 18:17:30
since ForceCommmit() stays true until the next onD
boliu
2014/10/15 19:37:51
As discussed, fixed. Just don't have the new condi
| |
| 151 // Happens with empty global visible rect. | 151 // Happens with empty global visible rect. |
| 152 if (!committed_frame_.get()) | 152 if (!committed_frame_.get()) |
| 153 return; | 153 return; |
| 154 | 154 |
| 155 DCHECK(!committed_frame_->gl_frame_data); | 155 DCHECK(!committed_frame_->gl_frame_data); |
| 156 DCHECK(!committed_frame_->software_frame_data); | 156 DCHECK(!committed_frame_->software_frame_data); |
| 157 | 157 |
| 158 // DelegatedRendererLayerImpl applies the inverse device_scale_factor of the | 158 // DelegatedRendererLayerImpl applies the inverse device_scale_factor of the |
| 159 // renderer frame, assuming that the browser compositor will scale | 159 // renderer frame, assuming that the browser compositor will scale |
| 160 // it back up to device scale. But on Android we put our browser layers in | 160 // it back up to device scale. But on Android we put our browser layers in |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 199 // We need to watch if the current Android context has changed and enforce | 199 // We need to watch if the current Android context has changed and enforce |
| 200 // a clean-up in the compositor. | 200 // a clean-up in the compositor. |
| 201 EGLContext current_context = eglGetCurrentContext(); | 201 EGLContext current_context = eglGetCurrentContext(); |
| 202 DCHECK(current_context) << "DrawGL called without EGLContext"; | 202 DCHECK(current_context) << "DrawGL called without EGLContext"; |
| 203 | 203 |
| 204 // TODO(boliu): Handle context loss. | 204 // TODO(boliu): Handle context loss. |
| 205 if (last_egl_context_ != current_context) | 205 if (last_egl_context_ != current_context) |
| 206 DLOG(WARNING) << "EGLContextChanged"; | 206 DLOG(WARNING) << "EGLContextChanged"; |
| 207 | 207 |
| 208 SetFrameData(); | 208 SetFrameData(); |
| 209 if (shared_renderer_state_->ForceCommit()) { | |
| 210 CommitFrame(); | |
| 211 SetFrameData(); | |
|
boliu
2014/10/15 18:01:25
Hmm, my guess is it doesn't like having 2 frames s
hush (inactive)
2014/10/15 18:17:30
you committed frame data twice. I don't know what
| |
| 212 } | |
| 213 | |
| 209 gfx::Transform transform(gfx::Transform::kSkipInitialization); | 214 gfx::Transform transform(gfx::Transform::kSkipInitialization); |
| 210 transform.matrix().setColMajorf(draw_info->transform); | 215 transform.matrix().setColMajorf(draw_info->transform); |
| 211 transform.Translate(scroll_offset_.x(), scroll_offset_.y()); | 216 transform.Translate(scroll_offset_.x(), scroll_offset_.y()); |
| 212 | 217 |
| 213 // Need to post the new transform matrix back to child compositor | 218 // Need to post the new transform matrix back to child compositor |
| 214 // because there is no onDraw during a Render Thread animation, and child | 219 // because there is no onDraw during a Render Thread animation, and child |
| 215 // compositor might not have the tiles rasterized as the animation goes on. | 220 // compositor might not have the tiles rasterized as the animation goes on. |
| 216 ParentCompositorDrawConstraints draw_constraints( | 221 ParentCompositorDrawConstraints draw_constraints( |
| 217 draw_info->is_layer, transform, gfx::Rect(viewport_)); | 222 draw_info->is_layer, transform, gfx::Rect(viewport_)); |
| 218 | 223 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 257 } | 262 } |
| 258 | 263 |
| 259 void HardwareRenderer::UnusedResourcesAreAvailable() { | 264 void HardwareRenderer::UnusedResourcesAreAvailable() { |
| 260 cc::ReturnedResourceArray returned_resources; | 265 cc::ReturnedResourceArray returned_resources; |
| 261 resource_collection_->TakeUnusedResourcesForChildCompositor( | 266 resource_collection_->TakeUnusedResourcesForChildCompositor( |
| 262 &returned_resources); | 267 &returned_resources); |
| 263 shared_renderer_state_->InsertReturnedResources(returned_resources); | 268 shared_renderer_state_->InsertReturnedResources(returned_resources); |
| 264 } | 269 } |
| 265 | 270 |
| 266 } // namespace android_webview | 271 } // namespace android_webview |
| OLD | NEW |