Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Side by Side Diff: content/renderer/android/synchronous_compositor_output_surface.cc

Issue 1418273002: cc: Move draw params from SetExternalDrawConstraints to OnDraw (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tests fixed Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "content/renderer/android/synchronous_compositor_output_surface.h" 5 #include "content/renderer/android/synchronous_compositor_output_surface.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "cc/output/compositor_frame.h" 9 #include "cc/output/compositor_frame.h"
10 #include "cc/output/context_provider.h" 10 #include "cc/output/context_provider.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 SynchronousCompositorRegistry* registry, 64 SynchronousCompositorRegistry* registry,
65 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue) 65 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue)
66 : cc::OutputSurface( 66 : cc::OutputSurface(
67 context_provider, 67 context_provider,
68 worker_context_provider, 68 worker_context_provider,
69 scoped_ptr<cc::SoftwareOutputDevice>(new SoftwareDevice(this))), 69 scoped_ptr<cc::SoftwareOutputDevice>(new SoftwareDevice(this))),
70 routing_id_(routing_id), 70 routing_id_(routing_id),
71 registry_(registry), 71 registry_(registry),
72 registered_(false), 72 registered_(false),
73 sync_client_(nullptr), 73 sync_client_(nullptr),
74 next_hardware_draw_needs_damage_(false),
75 current_sw_canvas_(nullptr), 74 current_sw_canvas_(nullptr),
76 memory_policy_(0u), 75 memory_policy_(0u),
77 frame_swap_message_queue_(frame_swap_message_queue) { 76 frame_swap_message_queue_(frame_swap_message_queue) {
78 thread_checker_.DetachFromThread(); 77 thread_checker_.DetachFromThread();
79 DCHECK(registry_); 78 DCHECK(registry_);
80 capabilities_.adjust_deadline_for_parent = false; 79 capabilities_.adjust_deadline_for_parent = false;
81 capabilities_.delegated_rendering = true; 80 capabilities_.delegated_rendering = true;
82 capabilities_.max_frames_pending = 1; 81 capabilities_.max_frames_pending = 1;
83 memory_policy_.priority_cutoff_when_visible = 82 memory_policy_.priority_cutoff_when_visible =
84 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE; 83 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 const gfx::Transform& transform, 136 const gfx::Transform& transform,
138 const gfx::Rect& viewport, 137 const gfx::Rect& viewport,
139 const gfx::Rect& clip, 138 const gfx::Rect& clip,
140 const gfx::Rect& viewport_rect_for_tile_priority, 139 const gfx::Rect& viewport_rect_for_tile_priority,
141 const gfx::Transform& transform_for_tile_priority) { 140 const gfx::Transform& transform_for_tile_priority) {
142 DCHECK(CalledOnValidThread()); 141 DCHECK(CalledOnValidThread());
143 DCHECK(HasClient()); 142 DCHECK(HasClient());
144 DCHECK(context_provider_.get()); 143 DCHECK(context_provider_.get());
145 144
146 surface_size_ = surface_size; 145 surface_size_ = surface_size;
147 InvokeComposite(transform, viewport, clip, viewport_rect_for_tile_priority, 146 client_->SetExternalDrawConstraints(viewport_rect_for_tile_priority,
148 transform_for_tile_priority, true); 147 transform_for_tile_priority);
148 InvokeComposite(transform, viewport, clip, false);
danakj 2015/11/24 21:17:31 nit: use a temp var dont pass bool literals to fun
boliu 2015/11/24 23:27:38 Done.
149 149
150 return frame_holder_.Pass(); 150 return frame_holder_.Pass();
151 } 151 }
152 152
153 scoped_ptr<cc::CompositorFrame> 153 scoped_ptr<cc::CompositorFrame>
154 SynchronousCompositorOutputSurface::DemandDrawSw(SkCanvas* canvas) { 154 SynchronousCompositorOutputSurface::DemandDrawSw(SkCanvas* canvas) {
155 DCHECK(CalledOnValidThread()); 155 DCHECK(CalledOnValidThread());
156 DCHECK(canvas); 156 DCHECK(canvas);
157 DCHECK(!current_sw_canvas_); 157 DCHECK(!current_sw_canvas_);
158 158
159 base::AutoReset<SkCanvas*> canvas_resetter(&current_sw_canvas_, canvas); 159 base::AutoReset<SkCanvas*> canvas_resetter(&current_sw_canvas_, canvas);
160 160
161 SkIRect canvas_clip; 161 SkIRect canvas_clip;
162 canvas->getClipDeviceBounds(&canvas_clip); 162 canvas->getClipDeviceBounds(&canvas_clip);
163 gfx::Rect clip = gfx::SkIRectToRect(canvas_clip); 163 gfx::Rect clip = gfx::SkIRectToRect(canvas_clip);
164 164
165 gfx::Transform transform(gfx::Transform::kSkipInitialization); 165 gfx::Transform transform(gfx::Transform::kSkipInitialization);
166 transform.matrix() = canvas->getTotalMatrix(); // Converts 3x3 matrix to 4x4. 166 transform.matrix() = canvas->getTotalMatrix(); // Converts 3x3 matrix to 4x4.
167 167
168 surface_size_ = gfx::Size(canvas->getDeviceSize().width(), 168 surface_size_ = gfx::Size(canvas->getDeviceSize().width(),
169 canvas->getDeviceSize().height()); 169 canvas->getDeviceSize().height());
170 170 InvokeComposite(transform, clip, clip, true);
danakj 2015/11/24 21:17:31 ditto
boliu 2015/11/24 23:27:38 Done.
171 // Pass in the cached hw viewport and transform for tile priority to avoid
172 // tile thrashing when the WebView is alternating between hardware and
173 // software draws.
174 InvokeComposite(transform,
175 clip,
176 clip,
177 cached_hw_viewport_rect_for_tile_priority_,
178 cached_hw_transform_for_tile_priority_,
179 false);
180 171
181 return frame_holder_.Pass(); 172 return frame_holder_.Pass();
182 } 173 }
183 174
184 void SynchronousCompositorOutputSurface::InvokeComposite( 175 void SynchronousCompositorOutputSurface::InvokeComposite(
185 const gfx::Transform& transform, 176 const gfx::Transform& transform,
186 const gfx::Rect& viewport, 177 const gfx::Rect& viewport,
187 const gfx::Rect& clip, 178 const gfx::Rect& clip,
188 const gfx::Rect& viewport_rect_for_tile_priority, 179 bool software_draw) {
189 const gfx::Transform& transform_for_tile_priority,
190 bool hardware_draw) {
191 DCHECK(!frame_holder_.get()); 180 DCHECK(!frame_holder_.get());
192 181
193 gfx::Transform adjusted_transform = transform; 182 gfx::Transform adjusted_transform = transform;
194 adjusted_transform.matrix().postTranslate(-viewport.x(), -viewport.y(), 0); 183 adjusted_transform.matrix().postTranslate(-viewport.x(), -viewport.y(), 0);
195 SetExternalDrawConstraints(adjusted_transform, viewport, clip, 184 client_->OnDraw(adjusted_transform, viewport, clip, software_draw);
196 viewport_rect_for_tile_priority,
197 transform_for_tile_priority, !hardware_draw);
198 if (!hardware_draw || next_hardware_draw_needs_damage_) {
199 next_hardware_draw_needs_damage_ = false;
200 SetNeedsRedrawRect(gfx::Rect(viewport.size()));
201 }
202
203 client_->OnDraw();
204
205 // After software draws (which might move the viewport arbitrarily), restore
206 // the previous hardware viewport to allow CC's tile manager to prioritize
207 // properly.
208 if (hardware_draw) {
209 cached_hw_transform_ = adjusted_transform;
210 cached_hw_viewport_ = viewport;
211 cached_hw_clip_ = clip;
212 cached_hw_viewport_rect_for_tile_priority_ =
213 viewport_rect_for_tile_priority;
214 cached_hw_transform_for_tile_priority_ = transform_for_tile_priority;
215 } else {
216 bool resourceless_software_draw = false;
217 SetExternalDrawConstraints(cached_hw_transform_,
218 cached_hw_viewport_,
219 cached_hw_clip_,
220 cached_hw_viewport_rect_for_tile_priority_,
221 cached_hw_transform_for_tile_priority_,
222 resourceless_software_draw);
223 // This draw may have reset all damage, which would lead to subsequent
224 // incorrect hardware draw, so explicitly set damage for next hardware
225 // draw as well.
226 next_hardware_draw_needs_damage_ = true;
227 }
228 185
229 if (frame_holder_.get()) 186 if (frame_holder_.get())
230 client_->DidSwapBuffersComplete(); 187 client_->DidSwapBuffersComplete();
231 } 188 }
232 189
233 void SynchronousCompositorOutputSurface::ReturnResources( 190 void SynchronousCompositorOutputSurface::ReturnResources(
234 const cc::CompositorFrameAck& frame_ack) { 191 const cc::CompositorFrameAck& frame_ack) {
235 ReclaimResources(&frame_ack); 192 ReclaimResources(&frame_ack);
236 } 193 }
237 194
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 scoped_ptr<FrameSwapMessageQueue::SendMessageScope> send_message_scope = 226 scoped_ptr<FrameSwapMessageQueue::SendMessageScope> send_message_scope =
270 frame_swap_message_queue_->AcquireSendMessageScope(); 227 frame_swap_message_queue_->AcquireSendMessageScope();
271 frame_swap_message_queue_->DrainMessages(messages); 228 frame_swap_message_queue_->DrainMessages(messages);
272 } 229 }
273 230
274 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const { 231 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const {
275 return thread_checker_.CalledOnValidThread(); 232 return thread_checker_.CalledOnValidThread();
276 } 233 }
277 234
278 } // namespace content 235 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698