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

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

Issue 470233003: Restrict ETC1 power-of-two rounding to old IMG drivers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 3 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
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"
11 #include "base/android/scoped_java_ref.h" 11 #include "base/android/scoped_java_ref.h"
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/containers/hash_tables.h" 14 #include "base/containers/hash_tables.h"
15 #include "base/lazy_instance.h" 15 #include "base/lazy_instance.h"
16 #include "base/logging.h" 16 #include "base/logging.h"
17 #include "base/memory/weak_ptr.h"
17 #include "base/single_thread_task_runner.h" 18 #include "base/single_thread_task_runner.h"
18 #include "base/synchronization/lock.h" 19 #include "base/synchronization/lock.h"
19 #include "base/threading/thread.h" 20 #include "base/threading/thread.h"
20 #include "base/threading/thread_checker.h" 21 #include "base/threading/thread_checker.h"
21 #include "cc/base/switches.h" 22 #include "cc/base/switches.h"
22 #include "cc/input/input_handler.h" 23 #include "cc/input/input_handler.h"
23 #include "cc/layers/layer.h" 24 #include "cc/layers/layer.h"
24 #include "cc/output/compositor_frame.h" 25 #include "cc/output/compositor_frame.h"
25 #include "cc/output/context_provider.h" 26 #include "cc/output/context_provider.h"
26 #include "cc/output/output_surface.h" 27 #include "cc/output/output_surface.h"
(...skipping 22 matching lines...) Expand all
49 #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl. h" 50 #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl. h"
50 51
51 namespace { 52 namespace {
52 53
53 const unsigned int kMaxSwapBuffers = 2U; 54 const unsigned int kMaxSwapBuffers = 2U;
54 55
55 // Used to override capabilities_.adjust_deadline_for_parent to false 56 // Used to override capabilities_.adjust_deadline_for_parent to false
56 class OutputSurfaceWithoutParent : public cc::OutputSurface { 57 class OutputSurfaceWithoutParent : public cc::OutputSurface {
57 public: 58 public:
58 OutputSurfaceWithoutParent(const scoped_refptr< 59 OutputSurfaceWithoutParent(const scoped_refptr<
59 content::ContextProviderCommandBuffer>& context_provider) 60 content::ContextProviderCommandBuffer>& context_provider,
61 base::WeakPtr<content::CompositorImpl> compositor_impl)
60 : cc::OutputSurface(context_provider) { 62 : cc::OutputSurface(context_provider) {
61 capabilities_.adjust_deadline_for_parent = false; 63 capabilities_.adjust_deadline_for_parent = false;
64 compositor_impl_ = compositor_impl;
65 main_thread_ = base::MessageLoopProxy::current();
62 } 66 }
63 67
64 virtual void SwapBuffers(cc::CompositorFrame* frame) OVERRIDE { 68 virtual void SwapBuffers(cc::CompositorFrame* frame) OVERRIDE {
65 content::ContextProviderCommandBuffer* provider_command_buffer = 69 content::ContextProviderCommandBuffer* provider_command_buffer =
66 static_cast<content::ContextProviderCommandBuffer*>( 70 static_cast<content::ContextProviderCommandBuffer*>(
67 context_provider_.get()); 71 context_provider_.get());
68 content::CommandBufferProxyImpl* command_buffer_proxy = 72 content::CommandBufferProxyImpl* command_buffer_proxy =
69 provider_command_buffer->GetCommandBufferProxy(); 73 provider_command_buffer->GetCommandBufferProxy();
70 DCHECK(command_buffer_proxy); 74 DCHECK(command_buffer_proxy);
71 command_buffer_proxy->SetLatencyInfo(frame->metadata.latency_info); 75 command_buffer_proxy->SetLatencyInfo(frame->metadata.latency_info);
72 76
73 OutputSurface::SwapBuffers(frame); 77 OutputSurface::SwapBuffers(frame);
74 } 78 }
79
80 virtual bool BindToClient(cc::OutputSurfaceClient* client) OVERRIDE {
81 if (!OutputSurface::BindToClient(client))
82 return false;
83
84 main_thread_->PostTask(
85 FROM_HERE,
86 base::Bind(&content::CompositorImpl::PopulateGpuCapabilities,
87 compositor_impl_,
88 context_provider_->ContextCapabilities().gpu));
89
90 return true;
91 }
92
93 scoped_refptr<base::MessageLoopProxy> main_thread_;
94 base::WeakPtr<content::CompositorImpl> compositor_impl_;
75 }; 95 };
76 96
77 class SurfaceTextureTrackerImpl : public gfx::SurfaceTextureTracker { 97 class SurfaceTextureTrackerImpl : public gfx::SurfaceTextureTracker {
78 public: 98 public:
79 SurfaceTextureTrackerImpl() : next_surface_texture_id_(1) { 99 SurfaceTextureTrackerImpl() : next_surface_texture_id_(1) {
80 thread_checker_.DetachFromThread(); 100 thread_checker_.DetachFromThread();
81 } 101 }
82 102
83 // Overridden from gfx::SurfaceTextureTracker: 103 // Overridden from gfx::SurfaceTextureTracker:
84 virtual scoped_refptr<gfx::SurfaceTexture> AcquireSurfaceTexture( 104 virtual scoped_refptr<gfx::SurfaceTexture> AcquireSurfaceTexture(
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 if (gpu_channel_host && !gpu_channel_host->IsLost()) { 565 if (gpu_channel_host && !gpu_channel_host->IsLost()) {
546 context_provider = ContextProviderCommandBuffer::Create( 566 context_provider = ContextProviderCommandBuffer::Create(
547 CreateGpuProcessViewContext(gpu_channel_host, attrs, surface_id_), 567 CreateGpuProcessViewContext(gpu_channel_host, attrs, surface_id_),
548 "BrowserCompositor"); 568 "BrowserCompositor");
549 } 569 }
550 if (!context_provider.get()) { 570 if (!context_provider.get()) {
551 LOG(ERROR) << "Failed to create 3D context for compositor."; 571 LOG(ERROR) << "Failed to create 3D context for compositor.";
552 return scoped_ptr<cc::OutputSurface>(); 572 return scoped_ptr<cc::OutputSurface>();
553 } 573 }
554 574
555 return scoped_ptr<cc::OutputSurface>( 575 return scoped_ptr<cc::OutputSurface>(new OutputSurfaceWithoutParent(
556 new OutputSurfaceWithoutParent(context_provider)); 576 context_provider, weak_factory_.GetWeakPtr()));
577 }
578
579 void CompositorImpl::PopulateGpuCapabilities(
580 gpu::Capabilities gpu_capabilities) {
581 ui_resource_provider_.SetSupportsETC1NonPowerOfTwo(
582 gpu_capabilities.texture_format_etc1_npot);
557 } 583 }
558 584
559 void CompositorImpl::OnLostResources() { 585 void CompositorImpl::OnLostResources() {
560 client_->DidLoseResources(); 586 client_->DidLoseResources();
561 ui_resource_provider_.UIResourcesAreInvalid(); 587 ui_resource_provider_.UIResourcesAreInvalid();
562 } 588 }
563 589
564 void CompositorImpl::ScheduleComposite() { 590 void CompositorImpl::ScheduleComposite() {
565 DCHECK(!needs_composite_ || WillComposite()); 591 DCHECK(!needs_composite_ || WillComposite());
566 if (ignore_schedule_composite_) 592 if (ignore_schedule_composite_)
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 } 670 }
645 671
646 void CompositorImpl::SetNeedsAnimate() { 672 void CompositorImpl::SetNeedsAnimate() {
647 if (!host_) 673 if (!host_)
648 return; 674 return;
649 675
650 host_->SetNeedsAnimate(); 676 host_->SetNeedsAnimate();
651 } 677 }
652 678
653 } // namespace content 679 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/compositor_impl_android.h ('k') | content/common/gpu/gpu_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698