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

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

Issue 1394263004: android webview: allow cc to fail hardware draw (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: damage before hardware to avoid invalidate-draw loop 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
« 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),
74 current_sw_canvas_(nullptr), 75 current_sw_canvas_(nullptr),
75 memory_policy_(0u), 76 memory_policy_(0u),
76 frame_swap_message_queue_(frame_swap_message_queue) { 77 frame_swap_message_queue_(frame_swap_message_queue) {
77 thread_checker_.DetachFromThread(); 78 thread_checker_.DetachFromThread();
78 DCHECK(registry_); 79 DCHECK(registry_);
79 capabilities_.draw_and_swap_full_viewport_every_frame = true;
80 capabilities_.adjust_deadline_for_parent = false; 80 capabilities_.adjust_deadline_for_parent = false;
81 capabilities_.delegated_rendering = true; 81 capabilities_.delegated_rendering = true;
82 capabilities_.max_frames_pending = 1; 82 capabilities_.max_frames_pending = 1;
83 memory_policy_.priority_cutoff_when_visible = 83 memory_policy_.priority_cutoff_when_visible =
84 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE; 84 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE;
85 } 85 }
86 86
87 SynchronousCompositorOutputSurface::~SynchronousCompositorOutputSurface() {} 87 SynchronousCompositorOutputSurface::~SynchronousCompositorOutputSurface() {}
88 88
89 void SynchronousCompositorOutputSurface::SetSyncClient( 89 void SynchronousCompositorOutputSurface::SetSyncClient(
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 gfx::Rect viewport_rect_for_tile_priority, 188 gfx::Rect viewport_rect_for_tile_priority,
189 gfx::Transform transform_for_tile_priority, 189 gfx::Transform transform_for_tile_priority,
190 bool hardware_draw) { 190 bool hardware_draw) {
191 DCHECK(!frame_holder_.get()); 191 DCHECK(!frame_holder_.get());
192 192
193 gfx::Transform adjusted_transform = transform; 193 gfx::Transform adjusted_transform = transform;
194 adjusted_transform.matrix().postTranslate(-viewport.x(), -viewport.y(), 0); 194 adjusted_transform.matrix().postTranslate(-viewport.x(), -viewport.y(), 0);
195 SetExternalDrawConstraints(adjusted_transform, viewport, clip, 195 SetExternalDrawConstraints(adjusted_transform, viewport, clip,
196 viewport_rect_for_tile_priority, 196 viewport_rect_for_tile_priority,
197 transform_for_tile_priority, !hardware_draw); 197 transform_for_tile_priority, !hardware_draw);
198 SetNeedsRedrawRect(gfx::Rect(viewport.size())); 198 if (!hardware_draw || next_hardware_draw_needs_damage_) {
199 next_hardware_draw_needs_damage_ = false;
200 SetNeedsRedrawRect(gfx::Rect(viewport.size()));
201 }
199 202
200 client_->OnDraw(); 203 client_->OnDraw();
201 204
202 // After software draws (which might move the viewport arbitrarily), restore 205 // After software draws (which might move the viewport arbitrarily), restore
203 // the previous hardware viewport to allow CC's tile manager to prioritize 206 // the previous hardware viewport to allow CC's tile manager to prioritize
204 // properly. 207 // properly.
205 if (hardware_draw) { 208 if (hardware_draw) {
206 cached_hw_transform_ = adjusted_transform; 209 cached_hw_transform_ = adjusted_transform;
207 cached_hw_viewport_ = viewport; 210 cached_hw_viewport_ = viewport;
208 cached_hw_clip_ = clip; 211 cached_hw_clip_ = clip;
209 cached_hw_viewport_rect_for_tile_priority_ = 212 cached_hw_viewport_rect_for_tile_priority_ =
210 viewport_rect_for_tile_priority; 213 viewport_rect_for_tile_priority;
211 cached_hw_transform_for_tile_priority_ = transform_for_tile_priority; 214 cached_hw_transform_for_tile_priority_ = transform_for_tile_priority;
212 } else { 215 } else {
213 bool resourceless_software_draw = false; 216 bool resourceless_software_draw = false;
214 SetExternalDrawConstraints(cached_hw_transform_, 217 SetExternalDrawConstraints(cached_hw_transform_,
215 cached_hw_viewport_, 218 cached_hw_viewport_,
216 cached_hw_clip_, 219 cached_hw_clip_,
217 cached_hw_viewport_rect_for_tile_priority_, 220 cached_hw_viewport_rect_for_tile_priority_,
218 cached_hw_transform_for_tile_priority_, 221 cached_hw_transform_for_tile_priority_,
219 resourceless_software_draw); 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;
220 } 227 }
221 228
222 if (frame_holder_.get()) 229 if (frame_holder_.get())
223 client_->DidSwapBuffersComplete(); 230 client_->DidSwapBuffersComplete();
224 } 231 }
225 232
226 void SynchronousCompositorOutputSurface::ReturnResources( 233 void SynchronousCompositorOutputSurface::ReturnResources(
227 const cc::CompositorFrameAck& frame_ack) { 234 const cc::CompositorFrameAck& frame_ack) {
228 ReclaimResources(&frame_ack); 235 ReclaimResources(&frame_ack);
229 } 236 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 scoped_ptr<FrameSwapMessageQueue::SendMessageScope> send_message_scope = 269 scoped_ptr<FrameSwapMessageQueue::SendMessageScope> send_message_scope =
263 frame_swap_message_queue_->AcquireSendMessageScope(); 270 frame_swap_message_queue_->AcquireSendMessageScope();
264 frame_swap_message_queue_->DrainMessages(messages); 271 frame_swap_message_queue_->DrainMessages(messages);
265 } 272 }
266 273
267 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const { 274 bool SynchronousCompositorOutputSurface::CalledOnValidThread() const {
268 return thread_checker_.CalledOnValidThread(); 275 return thread_checker_.CalledOnValidThread();
269 } 276 }
270 277
271 } // namespace content 278 } // 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