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

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: EXPECT_SCOPED Created 5 years 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
« no previous file with comments | « content/renderer/android/synchronous_compositor_output_surface.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 memory_policy_.priority_cutoff_when_visible = 81 memory_policy_.priority_cutoff_when_visible =
83 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE; 82 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE;
84 } 83 }
(...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_->SetExternalTilePriorityConstraints(viewport_rect_for_tile_priority,
148 transform_for_tile_priority, true); 147 transform_for_tile_priority);
148 const bool software_draw = false;
149 InvokeComposite(transform, viewport, clip, software_draw);
149 150
150 return frame_holder_.Pass(); 151 return frame_holder_.Pass();
151 } 152 }
152 153
153 scoped_ptr<cc::CompositorFrame> 154 scoped_ptr<cc::CompositorFrame>
154 SynchronousCompositorOutputSurface::DemandDrawSw(SkCanvas* canvas) { 155 SynchronousCompositorOutputSurface::DemandDrawSw(SkCanvas* canvas) {
155 DCHECK(CalledOnValidThread()); 156 DCHECK(CalledOnValidThread());
156 DCHECK(canvas); 157 DCHECK(canvas);
157 DCHECK(!current_sw_canvas_); 158 DCHECK(!current_sw_canvas_);
158 159
159 base::AutoReset<SkCanvas*> canvas_resetter(&current_sw_canvas_, canvas); 160 base::AutoReset<SkCanvas*> canvas_resetter(&current_sw_canvas_, canvas);
160 161
161 SkIRect canvas_clip; 162 SkIRect canvas_clip;
162 canvas->getClipDeviceBounds(&canvas_clip); 163 canvas->getClipDeviceBounds(&canvas_clip);
163 gfx::Rect clip = gfx::SkIRectToRect(canvas_clip); 164 gfx::Rect clip = gfx::SkIRectToRect(canvas_clip);
164 165
165 gfx::Transform transform(gfx::Transform::kSkipInitialization); 166 gfx::Transform transform(gfx::Transform::kSkipInitialization);
166 transform.matrix() = canvas->getTotalMatrix(); // Converts 3x3 matrix to 4x4. 167 transform.matrix() = canvas->getTotalMatrix(); // Converts 3x3 matrix to 4x4.
167 168
168 surface_size_ = gfx::Size(canvas->getBaseLayerSize().width(), 169 surface_size_ = gfx::Size(canvas->getBaseLayerSize().width(),
169 canvas->getBaseLayerSize().height()); 170 canvas->getBaseLayerSize().height());
170 171 const bool software_draw = true;
171 // Pass in the cached hw viewport and transform for tile priority to avoid 172 InvokeComposite(transform, clip, clip, software_draw);
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 173
181 return frame_holder_.Pass(); 174 return frame_holder_.Pass();
182 } 175 }
183 176
184 void SynchronousCompositorOutputSurface::InvokeComposite( 177 void SynchronousCompositorOutputSurface::InvokeComposite(
185 const gfx::Transform& transform, 178 const gfx::Transform& transform,
186 const gfx::Rect& viewport, 179 const gfx::Rect& viewport,
187 const gfx::Rect& clip, 180 const gfx::Rect& clip,
188 const gfx::Rect& viewport_rect_for_tile_priority, 181 bool software_draw) {
189 const gfx::Transform& transform_for_tile_priority,
190 bool hardware_draw) {
191 DCHECK(!frame_holder_.get()); 182 DCHECK(!frame_holder_.get());
192 183
193 gfx::Transform adjusted_transform = transform; 184 gfx::Transform adjusted_transform = transform;
194 adjusted_transform.matrix().postTranslate(-viewport.x(), -viewport.y(), 0); 185 adjusted_transform.matrix().postTranslate(-viewport.x(), -viewport.y(), 0);
195 SetExternalDrawConstraints(adjusted_transform, viewport, clip, 186 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 187
229 if (frame_holder_.get()) 188 if (frame_holder_.get())
230 client_->DidSwapBuffersComplete(); 189 client_->DidSwapBuffersComplete();
231 } 190 }
232 191
233 void SynchronousCompositorOutputSurface::ReturnResources( 192 void SynchronousCompositorOutputSurface::ReturnResources(
234 const cc::CompositorFrameAck& frame_ack) { 193 const cc::CompositorFrameAck& frame_ack) {
235 ReclaimResources(&frame_ack); 194 ReclaimResources(&frame_ack);
236 } 195 }
237 196
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 scoped_ptr<FrameSwapMessageQueue::SendMessageScope> send_message_scope = 228 scoped_ptr<FrameSwapMessageQueue::SendMessageScope> send_message_scope =
270 frame_swap_message_queue_->AcquireSendMessageScope(); 229 frame_swap_message_queue_->AcquireSendMessageScope();
271 frame_swap_message_queue_->DrainMessages(messages); 230 frame_swap_message_queue_->DrainMessages(messages);
272 } 231 }
273 232
274 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const { 233 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const {
275 return thread_checker_.CalledOnValidThread(); 234 return thread_checker_.CalledOnValidThread();
276 } 235 }
277 236
278 } // namespace content 237 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/android/synchronous_compositor_output_surface.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698