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

Side by Side Diff: content/browser/renderer_host/compositor_impl_android.cc

Issue 134623005: Make SingleThreadProxy a SchedulerClient (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Post task for ScheduledActionBeginOutputSurfaceCreation Created 6 years, 6 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/browser/renderer_host/compositor_impl_android.h" 5 #include "content/browser/renderer_host/compositor_impl_android.h"
6 6
7 #include <android/bitmap.h> 7 #include <android/bitmap.h>
8 #include <android/native_window_jni.h> 8 #include <android/native_window_jni.h>
9 9
10 #include "base/android/jni_android.h" 10 #include "base/android/jni_android.h"
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 CompositorImpl::CompositorImpl(CompositorClient* client, 188 CompositorImpl::CompositorImpl(CompositorClient* client,
189 gfx::NativeWindow root_window) 189 gfx::NativeWindow root_window)
190 : root_layer_(cc::Layer::Create()), 190 : root_layer_(cc::Layer::Create()),
191 has_transparent_background_(false), 191 has_transparent_background_(false),
192 device_scale_factor_(1), 192 device_scale_factor_(1),
193 window_(NULL), 193 window_(NULL),
194 surface_id_(0), 194 surface_id_(0),
195 client_(client), 195 client_(client),
196 root_window_(root_window), 196 root_window_(root_window),
197 did_post_swapbuffers_(false), 197 did_post_swapbuffers_(false),
198 ignore_schedule_composite_(false),
199 needs_composite_(false), 198 needs_composite_(false),
200 needs_animate_(false), 199 needs_animate_(false),
201 will_composite_immediately_(false), 200 will_composite_immediately_(false),
202 composite_on_vsync_trigger_(DO_NOT_COMPOSITE), 201 composite_on_vsync_trigger_(DO_NOT_COMPOSITE),
203 pending_swapbuffers_(0U), 202 pending_swapbuffers_(0U),
204 weak_factory_(this) { 203 weak_factory_(this) {
205 DCHECK(client); 204 DCHECK(client);
206 DCHECK(root_window); 205 DCHECK(root_window);
207 ImageTransportFactoryAndroid::AddObserver(this); 206 ImageTransportFactoryAndroid::AddObserver(this);
208 root_window->AttachCompositor(this); 207 root_window->AttachCompositor(this);
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 } 302 }
304 303
305 // Reset state before Layout+Composite since that might create more 304 // Reset state before Layout+Composite since that might create more
306 // requests to Composite that we need to respect. 305 // requests to Composite that we need to respect.
307 needs_composite_ = false; 306 needs_composite_ = false;
308 307
309 // Only allow compositing once per vsync. 308 // Only allow compositing once per vsync.
310 current_composite_task_->Cancel(); 309 current_composite_task_->Cancel();
311 DCHECK(DidCompositeThisFrame() && !WillComposite()); 310 DCHECK(DidCompositeThisFrame() && !WillComposite());
312 311
313 // Ignore ScheduleComposite() from layer tree changes during layout and 312 host_->SetDeferCommits(true);
no sievers 2014/06/13 21:25:43 I'm slightly worried that during client_->Layout()
danakj 2014/06/13 21:41:54 FWIW You could run with the --strict-layer-propert
314 // animation updates that will already be reflected in the current frame
315 // we are about to draw.
316 ignore_schedule_composite_ = true;
317 client_->Layout(); 313 client_->Layout();
318 314
319 const base::TimeTicks frame_time = gfx::FrameTime::Now(); 315 const base::TimeTicks frame_time = gfx::FrameTime::Now();
320 if (needs_animate_) { 316 if (needs_animate_) {
321 needs_animate_ = false; 317 needs_animate_ = false;
322 root_window_->Animate(frame_time); 318 root_window_->Animate(frame_time);
323 } 319 }
324 ignore_schedule_composite_ = false; 320 host_->SetDeferCommits(false);
325 321
326 did_post_swapbuffers_ = false; 322 did_post_swapbuffers_ = false;
327 host_->Composite(frame_time); 323 host_->Composite(frame_time);
328 if (did_post_swapbuffers_) 324 if (did_post_swapbuffers_)
329 pending_swapbuffers_++; 325 pending_swapbuffers_++;
330 326
331 // Need to track vsync to avoid compositing more than once per frame. 327 // Need to track vsync to avoid compositing more than once per frame.
332 root_window_->RequestVSyncUpdate(); 328 root_window_->RequestVSyncUpdate();
333 } 329 }
334 330
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 if (host_) 448 if (host_)
453 host_->set_has_transparent_background(flag); 449 host_->set_has_transparent_background(flag);
454 } 450 }
455 451
456 void CompositorImpl::SetNeedsComposite() { 452 void CompositorImpl::SetNeedsComposite() {
457 if (!host_.get()) 453 if (!host_.get())
458 return; 454 return;
459 DCHECK(!needs_composite_ || WillComposite()); 455 DCHECK(!needs_composite_ || WillComposite());
460 456
461 needs_composite_ = true; 457 needs_composite_ = true;
462 PostComposite(COMPOSITE_IMMEDIATELY); 458 PostComposite(COMPOSITE_IMMEDIATELY);
no sievers 2014/06/13 21:25:43 Does this need to become host_->SetNeedsCommit()?
enne (OOO) 2014/06/17 17:15:23 Hmm, I was trying to minimally change this code, b
463 } 459 }
464 460
465 static scoped_ptr<WebGraphicsContext3DCommandBufferImpl> 461 static scoped_ptr<WebGraphicsContext3DCommandBufferImpl>
466 CreateGpuProcessViewContext( 462 CreateGpuProcessViewContext(
467 const scoped_refptr<GpuChannelHost>& gpu_channel_host, 463 const scoped_refptr<GpuChannelHost>& gpu_channel_host,
468 const blink::WebGraphicsContext3D::Attributes attributes, 464 const blink::WebGraphicsContext3D::Attributes attributes,
469 int surface_id) { 465 int surface_id) {
470 DCHECK(gpu_channel_host); 466 DCHECK(gpu_channel_host);
471 467
472 GURL url("chrome://gpu/Compositor::createContext3D"); 468 GURL url("chrome://gpu/Compositor::createContext3D");
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 523
528 return scoped_ptr<cc::OutputSurface>( 524 return scoped_ptr<cc::OutputSurface>(
529 new OutputSurfaceWithoutParent(context_provider)); 525 new OutputSurfaceWithoutParent(context_provider));
530 } 526 }
531 527
532 void CompositorImpl::OnLostResources() { 528 void CompositorImpl::OnLostResources() {
533 client_->DidLoseResources(); 529 client_->DidLoseResources();
534 ui_resource_provider_.UIResourcesAreInvalid(); 530 ui_resource_provider_.UIResourcesAreInvalid();
535 } 531 }
536 532
537 void CompositorImpl::ScheduleComposite() {
538 DCHECK(!needs_composite_ || WillComposite());
539 if (ignore_schedule_composite_)
540 return;
541
542 needs_composite_ = true;
543 // We currently expect layer tree invalidations at most once per frame
544 // during normal operation and therefore try to composite immediately
545 // to minimize latency.
546 PostComposite(COMPOSITE_IMMEDIATELY);
547 }
548
549 void CompositorImpl::ScheduleAnimation() {
550 DCHECK(!needs_animate_ || needs_composite_);
551 DCHECK(!needs_composite_ || WillComposite());
552 needs_animate_ = true;
553
554 if (needs_composite_)
555 return;
556
557 TRACE_EVENT0("cc", "CompositorImpl::ScheduleAnimation");
558 needs_composite_ = true;
559 PostComposite(COMPOSITE_EVENTUALLY);
560 }
561
562 void CompositorImpl::DidPostSwapBuffers() { 533 void CompositorImpl::DidPostSwapBuffers() {
563 TRACE_EVENT0("compositor", "CompositorImpl::DidPostSwapBuffers"); 534 TRACE_EVENT0("compositor", "CompositorImpl::DidPostSwapBuffers");
564 did_post_swapbuffers_ = true; 535 did_post_swapbuffers_ = true;
565 } 536 }
566 537
567 void CompositorImpl::DidCompleteSwapBuffers() { 538 void CompositorImpl::DidCompleteSwapBuffers() {
568 TRACE_EVENT0("compositor", "CompositorImpl::DidCompleteSwapBuffers"); 539 TRACE_EVENT0("compositor", "CompositorImpl::DidCompleteSwapBuffers");
569 DCHECK_GT(pending_swapbuffers_, 0U); 540 DCHECK_GT(pending_swapbuffers_, 0U);
570 if (pending_swapbuffers_-- == kMaxSwapBuffers && needs_composite_) 541 if (pending_swapbuffers_-- == kMaxSwapBuffers && needs_composite_)
571 PostComposite(COMPOSITE_IMMEDIATELY); 542 PostComposite(COMPOSITE_IMMEDIATELY);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 } 588 }
618 589
619 void CompositorImpl::SetNeedsAnimate() { 590 void CompositorImpl::SetNeedsAnimate() {
620 if (!host_) 591 if (!host_)
621 return; 592 return;
622 593
623 host_->SetNeedsAnimate(); 594 host_->SetNeedsAnimate();
624 } 595 }
625 596
626 } // namespace content 597 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/compositor_impl_android.h ('k') | content/renderer/gpu/render_widget_compositor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698