| OLD | NEW |
| 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 #ifndef CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_IMPL_ANDROID_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_IMPL_ANDROID_H_ |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_IMPL_ANDROID_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_IMPL_ANDROID_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 | 11 |
| 12 #include "base/cancelable_callback.h" | 12 #include "base/cancelable_callback.h" |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "base/observer_list.h" | 16 #include "base/observer_list.h" |
| 17 #include "base/timer/timer.h" | 17 #include "base/timer/timer.h" |
| 18 #include "cc/surfaces/frame_sink_id.h" | 18 #include "cc/surfaces/frame_sink_id.h" |
| 19 #include "cc/trees/layer_tree_host_client.h" | 19 #include "cc/trees/layer_tree_host_client.h" |
| 20 #include "cc/trees/layer_tree_host_single_thread_client.h" | 20 #include "cc/trees/layer_tree_host_single_thread_client.h" |
| 21 #include "content/common/content_export.h" | 21 #include "content/common/content_export.h" |
| 22 #include "content/public/browser/android/compositor.h" | 22 #include "content/public/browser/android/compositor.h" |
| 23 #include "gpu/command_buffer/common/capabilities.h" | 23 #include "gpu/command_buffer/common/capabilities.h" |
| 24 #include "gpu/ipc/common/surface_handle.h" | 24 #include "gpu/ipc/common/surface_handle.h" |
| 25 #include "services/ui/public/cpp/gpu/context_provider_command_buffer.h" | 25 #include "services/ui/public/cpp/gpu/context_provider_command_buffer.h" |
| 26 #include "third_party/khronos/GLES2/gl2.h" | 26 #include "third_party/khronos/GLES2/gl2.h" |
| 27 #include "ui/android/context_provider_factory.h" | |
| 28 #include "ui/android/resources/resource_manager_impl.h" | 27 #include "ui/android/resources/resource_manager_impl.h" |
| 29 #include "ui/android/resources/ui_resource_provider.h" | 28 #include "ui/android/resources/ui_resource_provider.h" |
| 30 #include "ui/android/window_android_compositor.h" | 29 #include "ui/android/window_android_compositor.h" |
| 31 | 30 |
| 32 struct ANativeWindow; | 31 struct ANativeWindow; |
| 33 | 32 |
| 34 namespace cc { | 33 namespace cc { |
| 35 class AnimationHost; | 34 class AnimationHost; |
| 36 class Display; | 35 class Display; |
| 36 class FrameSinkId; |
| 37 class Layer; | 37 class Layer; |
| 38 class LayerTreeHost; | 38 class LayerTreeHost; |
| 39 class OutputSurface; | 39 class OutputSurface; |
| 40 class SurfaceManager; |
| 40 class VulkanContextProvider; | 41 class VulkanContextProvider; |
| 41 } | 42 } |
| 42 | 43 |
| 43 namespace content { | 44 namespace content { |
| 44 class CompositorClient; | 45 class CompositorClient; |
| 45 | 46 |
| 46 // ----------------------------------------------------------------------------- | 47 // ----------------------------------------------------------------------------- |
| 47 // Browser-side compositor that manages a tree of content and UI layers. | 48 // Browser-side compositor that manages a tree of content and UI layers. |
| 48 // ----------------------------------------------------------------------------- | 49 // ----------------------------------------------------------------------------- |
| 49 class CONTENT_EXPORT CompositorImpl | 50 class CONTENT_EXPORT CompositorImpl |
| 50 : public Compositor, | 51 : public Compositor, |
| 51 public cc::LayerTreeHostClient, | 52 public cc::LayerTreeHostClient, |
| 52 public cc::LayerTreeHostSingleThreadClient, | 53 public cc::LayerTreeHostSingleThreadClient, |
| 53 public ui::UIResourceProvider, | 54 public ui::UIResourceProvider, |
| 54 public ui::WindowAndroidCompositor { | 55 public ui::WindowAndroidCompositor { |
| 55 public: | 56 public: |
| 56 CompositorImpl(CompositorClient* client, gfx::NativeWindow root_window); | 57 CompositorImpl(CompositorClient* client, gfx::NativeWindow root_window); |
| 57 ~CompositorImpl() override; | 58 ~CompositorImpl() override; |
| 58 | 59 |
| 59 static bool IsInitialized(); | 60 static bool IsInitialized(); |
| 60 | 61 |
| 62 static cc::SurfaceManager* GetSurfaceManager(); |
| 63 static cc::FrameSinkId AllocateFrameSinkId(); |
| 64 |
| 61 // ui::ResourceProvider implementation. | 65 // ui::ResourceProvider implementation. |
| 62 cc::UIResourceId CreateUIResource(cc::UIResourceClient* client) override; | 66 cc::UIResourceId CreateUIResource(cc::UIResourceClient* client) override; |
| 63 void DeleteUIResource(cc::UIResourceId resource_id) override; | 67 void DeleteUIResource(cc::UIResourceId resource_id) override; |
| 64 bool SupportsETC1NonPowerOfTwo() const override; | 68 bool SupportsETC1NonPowerOfTwo() const override; |
| 65 | 69 |
| 66 private: | 70 private: |
| 67 // Compositor implementation. | 71 // Compositor implementation. |
| 68 void SetRootLayer(scoped_refptr<cc::Layer> root) override; | 72 void SetRootLayer(scoped_refptr<cc::Layer> root) override; |
| 69 void SetSurface(jobject surface) override; | 73 void SetSurface(jobject surface) override; |
| 70 void SetWindowBounds(const gfx::Size& size) override; | 74 void SetWindowBounds(const gfx::Size& size) override; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 | 112 |
| 109 void SetVisible(bool visible); | 113 void SetVisible(bool visible); |
| 110 void CreateLayerTreeHost(); | 114 void CreateLayerTreeHost(); |
| 111 | 115 |
| 112 void HandlePendingCompositorFrameSinkRequest(); | 116 void HandlePendingCompositorFrameSinkRequest(); |
| 113 | 117 |
| 114 #if defined(ENABLE_VULKAN) | 118 #if defined(ENABLE_VULKAN) |
| 115 void CreateVulkanOutputSurface(); | 119 void CreateVulkanOutputSurface(); |
| 116 #endif | 120 #endif |
| 117 void OnGpuChannelEstablished( | 121 void OnGpuChannelEstablished( |
| 118 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host, | 122 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host); |
| 119 ui::ContextProviderFactory::GpuChannelHostResult result); | 123 void OnGpuChannelTimeout(); |
| 120 void InitializeDisplay( | 124 void InitializeDisplay( |
| 121 std::unique_ptr<cc::OutputSurface> display_output_surface, | 125 std::unique_ptr<cc::OutputSurface> display_output_surface, |
| 122 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider, | 126 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider, |
| 123 scoped_refptr<cc::ContextProvider> context_provider); | 127 scoped_refptr<cc::ContextProvider> context_provider); |
| 124 | 128 |
| 125 bool HavePendingReadbacks(); | 129 bool HavePendingReadbacks(); |
| 126 void SetBackgroundColor(int color); | 130 void SetBackgroundColor(int color); |
| 127 | 131 |
| 128 cc::FrameSinkId frame_sink_id_; | 132 cc::FrameSinkId frame_sink_id_; |
| 129 | 133 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 153 | 157 |
| 154 // Whether we need to update animations on the next composite. | 158 // Whether we need to update animations on the next composite. |
| 155 bool needs_animate_; | 159 bool needs_animate_; |
| 156 | 160 |
| 157 // The number of SwapBuffer calls that have not returned and ACK'd from | 161 // The number of SwapBuffer calls that have not returned and ACK'd from |
| 158 // the GPU thread. | 162 // the GPU thread. |
| 159 unsigned int pending_swapbuffers_; | 163 unsigned int pending_swapbuffers_; |
| 160 | 164 |
| 161 size_t num_successive_context_creation_failures_; | 165 size_t num_successive_context_creation_failures_; |
| 162 | 166 |
| 167 size_t num_successive_gpu_initialization_failures_; |
| 168 base::OneShotTimer establish_gpu_channel_timeout_; |
| 169 |
| 163 // Whether there is an CompositorFrameSink request pending from the current | 170 // Whether there is an CompositorFrameSink request pending from the current |
| 164 // |host_|. Becomes |true| if RequestNewCompositorFrameSink is called, and | 171 // |host_|. Becomes |true| if RequestNewCompositorFrameSink is called, and |
| 165 // |false| if |host_| is deleted or we succeed in creating *and* initializing | 172 // |false| if |host_| is deleted or we succeed in creating *and* initializing |
| 166 // a CompositorFrameSink (which is essentially the contract with cc). | 173 // a CompositorFrameSink (which is essentially the contract with cc). |
| 167 bool compositor_frame_sink_request_pending_; | 174 bool compositor_frame_sink_request_pending_; |
| 168 | 175 |
| 169 gpu::Capabilities gpu_capabilities_; | 176 gpu::Capabilities gpu_capabilities_; |
| 170 bool has_compositor_frame_sink_ = false; | 177 bool has_compositor_frame_sink_ = false; |
| 171 std::unordered_set<cc::FrameSinkId, cc::FrameSinkIdHash> | 178 std::unordered_set<cc::FrameSinkId, cc::FrameSinkIdHash> |
| 172 pending_child_frame_sink_ids_; | 179 pending_child_frame_sink_ids_; |
| 173 base::WeakPtrFactory<CompositorImpl> weak_factory_; | 180 base::WeakPtrFactory<CompositorImpl> weak_factory_; |
| 174 | 181 |
| 175 DISALLOW_COPY_AND_ASSIGN(CompositorImpl); | 182 DISALLOW_COPY_AND_ASSIGN(CompositorImpl); |
| 176 }; | 183 }; |
| 177 | 184 |
| 178 } // namespace content | 185 } // namespace content |
| 179 | 186 |
| 180 #endif // CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_IMPL_ANDROID_H_ | 187 #endif // CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_IMPL_ANDROID_H_ |
| OLD | NEW |