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

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

Issue 738983002: Move output surface fallback from cc to embedders (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 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
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 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 limits, 521 limits,
522 NULL)); 522 NULL));
523 } 523 }
524 524
525 void CompositorImpl::Layout() { 525 void CompositorImpl::Layout() {
526 ignore_schedule_composite_ = true; 526 ignore_schedule_composite_ = true;
527 client_->Layout(); 527 client_->Layout();
528 ignore_schedule_composite_ = false; 528 ignore_schedule_composite_ = false;
529 } 529 }
530 530
531 void CompositorImpl::RequestNewOutputSurface(bool fallback) { 531 void CompositorImpl::RequestNewOutputSurface() {
532 // SetVisible(false) can happen (destroying the host_) between when this
533 // function is posted and when it is handled. An output surface will get
534 // re-requested when the host is recreated.
535 if (!host_.get())
536 return;
537
532 BrowserGpuChannelHostFactory* factory = 538 BrowserGpuChannelHostFactory* factory =
533 BrowserGpuChannelHostFactory::instance(); 539 BrowserGpuChannelHostFactory::instance();
534 if (!factory->GetGpuChannel() || factory->GetGpuChannel()->IsLost()) { 540 if (!factory->GetGpuChannel() || factory->GetGpuChannel()->IsLost()) {
535 CauseForGpuLaunch cause = 541 CauseForGpuLaunch cause =
536 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE; 542 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE;
537 factory->EstablishGpuChannel( 543 factory->EstablishGpuChannel(
538 cause, 544 cause,
539 base::Bind(&CompositorImpl::CreateOutputSurface, 545 base::Bind(&CompositorImpl::CreateOutputSurface,
540 weak_factory_.GetWeakPtr(), 546 weak_factory_.GetWeakPtr()));
541 fallback));
542 return; 547 return;
543 } 548 }
544 549
545 CreateOutputSurface(fallback); 550 CreateOutputSurface();
546 } 551 }
547 552
548 void CompositorImpl::CreateOutputSurface(bool fallback) { 553 void CompositorImpl::DidFailToInitializeOutputSurface() {
554 RequestNewOutputSurface();
555 }
556
557 void CompositorImpl::CreateOutputSurface() {
549 blink::WebGraphicsContext3D::Attributes attrs; 558 blink::WebGraphicsContext3D::Attributes attrs;
550 attrs.shareResources = true; 559 attrs.shareResources = true;
551 attrs.noAutomaticFlushes = true; 560 attrs.noAutomaticFlushes = true;
552 pending_swapbuffers_ = 0; 561 pending_swapbuffers_ = 0;
553 562
554 DCHECK(window_); 563 DCHECK(window_);
555 DCHECK(surface_id_); 564 DCHECK(surface_id_);
556 565
557 scoped_refptr<ContextProviderCommandBuffer> context_provider; 566 scoped_refptr<ContextProviderCommandBuffer> context_provider;
558 BrowserGpuChannelHostFactory* factory = 567 BrowserGpuChannelHostFactory* factory =
559 BrowserGpuChannelHostFactory::instance(); 568 BrowserGpuChannelHostFactory::instance();
560 scoped_refptr<GpuChannelHost> gpu_channel_host = factory->GetGpuChannel(); 569 scoped_refptr<GpuChannelHost> gpu_channel_host = factory->GetGpuChannel();
561 if (gpu_channel_host.get() && !gpu_channel_host->IsLost()) { 570 if (gpu_channel_host.get() && !gpu_channel_host->IsLost()) {
562 context_provider = ContextProviderCommandBuffer::Create( 571 context_provider = ContextProviderCommandBuffer::Create(
563 CreateGpuProcessViewContext(gpu_channel_host, attrs, surface_id_), 572 CreateGpuProcessViewContext(gpu_channel_host, attrs, surface_id_),
564 "BrowserCompositor"); 573 "BrowserCompositor");
565 } 574 }
566 if (!context_provider.get()) { 575 if (!context_provider.get()) {
567 LOG(ERROR) << "Failed to create 3D context for compositor."; 576 LOG(ERROR) << "Failed to create 3D context for compositor.";
568 host_->SetOutputSurface(scoped_ptr<cc::OutputSurface>()); 577 base::MessageLoopProxy::current()->PostTask(
578 FROM_HERE, base::Bind(&CompositorImpl::RequestNewOutputSurface,
579 weak_factory_.GetWeakPtr()));
569 return; 580 return;
570 } 581 }
571 582
572 scoped_ptr<cc::OutputSurface> real_output_surface( 583 scoped_ptr<cc::OutputSurface> real_output_surface(
573 new OutputSurfaceWithoutParent(context_provider, 584 new OutputSurfaceWithoutParent(context_provider,
574 weak_factory_.GetWeakPtr())); 585 weak_factory_.GetWeakPtr()));
575 586
576 cc::SurfaceManager* manager = GetSurfaceManager(); 587 cc::SurfaceManager* manager = GetSurfaceManager();
577 if (manager) { 588 if (manager) {
578 display_client_.reset( 589 display_client_.reset(
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 } 691 }
681 692
682 void CompositorImpl::SetNeedsAnimate() { 693 void CompositorImpl::SetNeedsAnimate() {
683 if (!host_) 694 if (!host_)
684 return; 695 return;
685 696
686 host_->SetNeedsAnimate(); 697 host_->SetNeedsAnimate();
687 } 698 }
688 699
689 } // namespace content 700 } // 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