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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 EGLContext current_context = eglGetCurrentContext(); | 137 EGLContext current_context = eglGetCurrentContext(); |
138 if (!current_context) { | 138 if (!current_context) { |
139 DLOG(ERROR) << "DrawGL called without EGLContext"; | 139 DLOG(ERROR) << "DrawGL called without EGLContext"; |
140 return; | 140 return; |
141 } | 141 } |
142 | 142 |
143 // TODO(boliu): Handle context loss. | 143 // TODO(boliu): Handle context loss. |
144 if (last_egl_context_ != current_context) | 144 if (last_egl_context_ != current_context) |
145 DLOG(WARNING) << "EGLContextChanged"; | 145 DLOG(WARNING) << "EGLContextChanged"; |
146 | 146 |
| 147 gfx::Transform transform(gfx::Transform::kSkipInitialization); |
| 148 transform.matrix().setColMajorf(draw_info->transform); |
| 149 transform.Translate(scroll_offset_.x(), scroll_offset_.y()); |
| 150 |
| 151 // Need to post the new transform matrix back to child compositor |
| 152 // because there is no onDraw during a Render Thread animation, and child |
| 153 // compositor might not have the tiles rasterized as the animation goes on. |
| 154 ParentCompositorDrawConstraints draw_constraints( |
| 155 draw_info->is_layer, transform, gfx::Rect(viewport_)); |
| 156 if (!draw_constraints_.Equals(draw_constraints)) { |
| 157 draw_constraints_ = draw_constraints; |
| 158 shared_renderer_state_->PostExternalDrawConstraintsToChildCompositor( |
| 159 draw_constraints); |
| 160 } |
| 161 |
147 scoped_ptr<DrawGLInput> input = shared_renderer_state_->PassDrawGLInput(); | 162 scoped_ptr<DrawGLInput> input = shared_renderer_state_->PassDrawGLInput(); |
148 if (!resource_collection_.get()) { | 163 if (!resource_collection_.get()) { |
149 resource_collection_ = new cc::DelegatedFrameResourceCollection; | 164 resource_collection_ = new cc::DelegatedFrameResourceCollection; |
150 resource_collection_->SetClient(this); | 165 resource_collection_->SetClient(this); |
151 } | 166 } |
152 | 167 |
153 if (input.get()) { | 168 if (input.get()) { |
154 DCHECK(!input->frame.gl_frame_data); | 169 DCHECK(!input->frame.gl_frame_data); |
155 DCHECK(!input->frame.software_frame_data); | 170 DCHECK(!input->frame.software_frame_data); |
156 | 171 |
(...skipping 30 matching lines...) Expand all Loading... |
187 } | 202 } |
188 | 203 |
189 viewport_.SetSize(draw_info->width, draw_info->height); | 204 viewport_.SetSize(draw_info->width, draw_info->height); |
190 layer_tree_host_->SetViewportSize(viewport_); | 205 layer_tree_host_->SetViewportSize(viewport_); |
191 clip_.SetRect(draw_info->clip_left, | 206 clip_.SetRect(draw_info->clip_left, |
192 draw_info->clip_top, | 207 draw_info->clip_top, |
193 draw_info->clip_right - draw_info->clip_left, | 208 draw_info->clip_right - draw_info->clip_left, |
194 draw_info->clip_bottom - draw_info->clip_top); | 209 draw_info->clip_bottom - draw_info->clip_top); |
195 stencil_enabled_ = stencil_enabled; | 210 stencil_enabled_ = stencil_enabled; |
196 | 211 |
197 gfx::Transform transform(gfx::Transform::kSkipInitialization); | |
198 transform.matrix().setColMajorf(draw_info->transform); | |
199 transform.Translate(scroll_offset_.x(), scroll_offset_.y()); | |
200 delegated_layer_->SetTransform(transform); | 212 delegated_layer_->SetTransform(transform); |
201 | 213 |
202 gl_surface_->SetBackingFrameBufferObject(framebuffer_binding_ext); | 214 gl_surface_->SetBackingFrameBufferObject(framebuffer_binding_ext); |
203 { | 215 { |
204 base::AutoReset<bool> frame_resetter(&viewport_clip_valid_for_dcheck_, | 216 base::AutoReset<bool> frame_resetter(&viewport_clip_valid_for_dcheck_, |
205 true); | 217 true); |
206 layer_tree_host_->SetNeedsRedrawRect(clip_); | 218 layer_tree_host_->SetNeedsRedrawRect(clip_); |
207 layer_tree_host_->Composite(gfx::FrameTime::Now()); | 219 layer_tree_host_->Composite(gfx::FrameTime::Now()); |
208 } | 220 } |
209 gl_surface_->ResetBackingFrameBufferObject(); | 221 gl_surface_->ResetBackingFrameBufferObject(); |
(...skipping 14 matching lines...) Expand all Loading... |
224 } | 236 } |
225 | 237 |
226 void HardwareRenderer::UnusedResourcesAreAvailable() { | 238 void HardwareRenderer::UnusedResourcesAreAvailable() { |
227 cc::ReturnedResourceArray returned_resources; | 239 cc::ReturnedResourceArray returned_resources; |
228 resource_collection_->TakeUnusedResourcesForChildCompositor( | 240 resource_collection_->TakeUnusedResourcesForChildCompositor( |
229 &returned_resources); | 241 &returned_resources); |
230 shared_renderer_state_->InsertReturnedResources(returned_resources); | 242 shared_renderer_state_->InsertReturnedResources(returned_resources); |
231 } | 243 } |
232 | 244 |
233 } // namespace android_webview | 245 } // namespace android_webview |
OLD | NEW |