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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 | 111 |
112 CreateNewCompositorFrameSinkSupport(); | 112 CreateNewCompositorFrameSinkSupport(); |
113 compositor_id_ = child_frame_->compositor_id; | 113 compositor_id_ = child_frame_->compositor_id; |
114 last_submitted_compositor_frame_sink_id_ = | 114 last_submitted_compositor_frame_sink_id_ = |
115 child_frame_->compositor_frame_sink_id; | 115 child_frame_->compositor_frame_sink_id; |
116 } | 116 } |
117 | 117 |
118 std::unique_ptr<cc::CompositorFrame> child_compositor_frame = | 118 std::unique_ptr<cc::CompositorFrame> child_compositor_frame = |
119 std::move(child_frame_->frame); | 119 std::move(child_frame_->frame); |
120 | 120 |
| 121 float device_scale_factor = |
| 122 child_compositor_frame->metadata.device_scale_factor; |
121 gfx::Size frame_size = | 123 gfx::Size frame_size = |
122 child_compositor_frame->render_pass_list.back()->output_rect.size(); | 124 child_compositor_frame->render_pass_list.back()->output_rect.size(); |
123 bool size_changed = frame_size != frame_size_; | 125 if (!child_id_.is_valid() || surface_size_ != frame_size || |
124 frame_size_ = frame_size; | 126 device_scale_factor_ != device_scale_factor) { |
125 if (!child_id_.is_valid() || size_changed) { | |
126 if (child_id_.is_valid()) | 127 if (child_id_.is_valid()) |
127 DestroySurface(); | 128 DestroySurface(); |
128 AllocateSurface(); | 129 AllocateSurface(); |
| 130 surface_size_ = frame_size; |
| 131 device_scale_factor_ = device_scale_factor; |
129 } | 132 } |
130 | 133 |
131 support_->SubmitCompositorFrame(child_id_, | 134 support_->SubmitCompositorFrame(child_id_, |
132 std::move(*child_compositor_frame)); | 135 std::move(*child_compositor_frame)); |
133 } | 136 } |
134 | 137 |
135 gfx::Transform transform(gfx::Transform::kSkipInitialization); | 138 gfx::Transform transform(gfx::Transform::kSkipInitialization); |
136 transform.matrix().setColMajorf(draw_info->transform); | 139 transform.matrix().setColMajorf(draw_info->transform); |
137 transform.Translate(scroll_offset_.x(), scroll_offset_.y()); | 140 transform.Translate(scroll_offset_.x(), scroll_offset_.y()); |
138 | 141 |
139 gfx::Size viewport(draw_info->width, draw_info->height); | 142 gfx::Size viewport(draw_info->width, draw_info->height); |
140 // Need to post the new transform matrix back to child compositor | 143 // Need to post the new transform matrix back to child compositor |
141 // because there is no onDraw during a Render Thread animation, and child | 144 // because there is no onDraw during a Render Thread animation, and child |
142 // compositor might not have the tiles rasterized as the animation goes on. | 145 // compositor might not have the tiles rasterized as the animation goes on. |
143 ParentCompositorDrawConstraints draw_constraints( | 146 ParentCompositorDrawConstraints draw_constraints( |
144 draw_info->is_layer, transform, viewport.IsEmpty()); | 147 draw_info->is_layer, transform, viewport.IsEmpty()); |
145 if (!child_frame_.get() || draw_constraints.NeedUpdate(*child_frame_)) { | 148 if (!child_frame_.get() || draw_constraints.NeedUpdate(*child_frame_)) { |
146 render_thread_manager_->PostExternalDrawConstraintsToChildCompositorOnRT( | 149 render_thread_manager_->PostExternalDrawConstraintsToChildCompositorOnRT( |
147 draw_constraints); | 150 draw_constraints); |
148 } | 151 } |
149 | 152 |
150 if (!child_id_.is_valid()) | 153 if (!child_id_.is_valid()) |
151 return; | 154 return; |
152 | 155 |
153 gfx::Rect clip(draw_info->clip_left, draw_info->clip_top, | 156 gfx::Rect clip(draw_info->clip_left, draw_info->clip_top, |
154 draw_info->clip_right - draw_info->clip_left, | 157 draw_info->clip_right - draw_info->clip_left, |
155 draw_info->clip_bottom - draw_info->clip_top); | 158 draw_info->clip_bottom - draw_info->clip_top); |
156 surfaces_->DrawAndSwap(viewport, clip, transform, frame_size_, | 159 surfaces_->DrawAndSwap(viewport, clip, transform, surface_size_, |
157 cc::SurfaceId(frame_sink_id_, child_id_)); | 160 cc::SurfaceId(frame_sink_id_, child_id_)); |
158 } | 161 } |
159 | 162 |
160 void HardwareRenderer::AllocateSurface() { | 163 void HardwareRenderer::AllocateSurface() { |
161 DCHECK(!child_id_.is_valid()); | 164 DCHECK(!child_id_.is_valid()); |
162 child_id_ = local_surface_id_allocator_->GenerateId(); | 165 child_id_ = local_surface_id_allocator_->GenerateId(); |
163 surfaces_->AddChildId(cc::SurfaceId(frame_sink_id_, child_id_)); | 166 surfaces_->AddChildId(cc::SurfaceId(frame_sink_id_, child_id_)); |
164 } | 167 } |
165 | 168 |
166 void HardwareRenderer::DestroySurface() { | 169 void HardwareRenderer::DestroySurface() { |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 constexpr bool is_root = false; | 260 constexpr bool is_root = false; |
258 constexpr bool handles_frame_sink_id_invalidation = false; | 261 constexpr bool handles_frame_sink_id_invalidation = false; |
259 constexpr bool needs_sync_points = true; | 262 constexpr bool needs_sync_points = true; |
260 support_.reset(); | 263 support_.reset(); |
261 support_ = cc::CompositorFrameSinkSupport::Create( | 264 support_ = cc::CompositorFrameSinkSupport::Create( |
262 this, surfaces_->GetSurfaceManager(), frame_sink_id_, is_root, | 265 this, surfaces_->GetSurfaceManager(), frame_sink_id_, is_root, |
263 handles_frame_sink_id_invalidation, needs_sync_points); | 266 handles_frame_sink_id_invalidation, needs_sync_points); |
264 } | 267 } |
265 | 268 |
266 } // namespace android_webview | 269 } // namespace android_webview |
OLD | NEW |