| 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 "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/cancelable_callback.h" | 9 #include "base/cancelable_callback.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "cc/trees/layer_tree_host_client.h" | 13 #include "cc/trees/layer_tree_host_client.h" |
| 14 #include "cc/trees/layer_tree_host_single_thread_client.h" | 14 #include "cc/trees/layer_tree_host_single_thread_client.h" |
| 15 #include "content/browser/android/ui_resource_provider_impl.h" | |
| 16 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
| 17 #include "content/common/gpu/client/context_provider_command_buffer.h" | 16 #include "content/common/gpu/client/context_provider_command_buffer.h" |
| 18 #include "content/public/browser/android/compositor.h" | 17 #include "content/public/browser/android/compositor.h" |
| 19 #include "gpu/command_buffer/common/capabilities.h" | 18 #include "gpu/command_buffer/common/capabilities.h" |
| 20 #include "third_party/khronos/GLES2/gl2.h" | 19 #include "third_party/khronos/GLES2/gl2.h" |
| 21 #include "ui/android/resources/resource_manager.h" | 20 #include "ui/android/resources/resource_manager.h" |
| 22 #include "ui/base/android/system_ui_resource_manager.h" | 21 #include "ui/android/resources/ui_resource_provider.h" |
| 23 #include "ui/base/android/window_android_compositor.h" | 22 #include "ui/base/android/window_android_compositor.h" |
| 24 | 23 |
| 25 class SkBitmap; | 24 class SkBitmap; |
| 26 struct ANativeWindow; | 25 struct ANativeWindow; |
| 27 | 26 |
| 28 namespace cc { | 27 namespace cc { |
| 29 class Layer; | 28 class Layer; |
| 30 class LayerTreeHost; | 29 class LayerTreeHost; |
| 31 class SurfaceIdAllocator; | 30 class SurfaceIdAllocator; |
| 32 } | 31 } |
| 33 | 32 |
| 34 namespace content { | 33 namespace content { |
| 35 class CompositorClient; | 34 class CompositorClient; |
| 36 class OnscreenDisplayClient; | 35 class OnscreenDisplayClient; |
| 37 class UIResourceProvider; | |
| 38 | 36 |
| 39 // ----------------------------------------------------------------------------- | 37 // ----------------------------------------------------------------------------- |
| 40 // Browser-side compositor that manages a tree of content and UI layers. | 38 // Browser-side compositor that manages a tree of content and UI layers. |
| 41 // ----------------------------------------------------------------------------- | 39 // ----------------------------------------------------------------------------- |
| 42 class CONTENT_EXPORT CompositorImpl | 40 class CONTENT_EXPORT CompositorImpl |
| 43 : public Compositor, | 41 : public Compositor, |
| 44 public cc::LayerTreeHostClient, | 42 public cc::LayerTreeHostClient, |
| 45 public cc::LayerTreeHostSingleThreadClient, | 43 public cc::LayerTreeHostSingleThreadClient, |
| 46 public ui::WindowAndroidCompositor { | 44 public ui::WindowAndroidCompositor { |
| 47 public: | 45 public: |
| 48 CompositorImpl(CompositorClient* client, gfx::NativeWindow root_window); | 46 CompositorImpl(CompositorClient* client, gfx::NativeWindow root_window); |
| 49 virtual ~CompositorImpl(); | 47 virtual ~CompositorImpl(); |
| 50 | 48 |
| 51 static bool IsInitialized(); | 49 static bool IsInitialized(); |
| 52 | 50 |
| 53 void PopulateGpuCapabilities(gpu::Capabilities gpu_capabilities); | 51 void PopulateGpuCapabilities(gpu::Capabilities gpu_capabilities); |
| 54 | 52 |
| 55 private: | 53 private: |
| 56 // Compositor implementation. | 54 // Compositor implementation. |
| 57 virtual void SetRootLayer(scoped_refptr<cc::Layer> root) override; | 55 virtual void SetRootLayer(scoped_refptr<cc::Layer> root) override; |
| 58 virtual void SetSurface(jobject surface) override; | 56 virtual void SetSurface(jobject surface) override; |
| 59 virtual void SetVisible(bool visible) override; | 57 virtual void SetVisible(bool visible) override; |
| 60 virtual void setDeviceScaleFactor(float factor) override; | 58 virtual void setDeviceScaleFactor(float factor) override; |
| 61 virtual void SetWindowBounds(const gfx::Size& size) override; | 59 virtual void SetWindowBounds(const gfx::Size& size) override; |
| 62 virtual void SetHasTransparentBackground(bool flag) override; | 60 virtual void SetHasTransparentBackground(bool flag) override; |
| 63 virtual void SetNeedsComposite() override; | 61 virtual void SetNeedsComposite() override; |
| 64 virtual UIResourceProvider& GetUIResourceProvider() override; | 62 virtual ui::UIResourceProvider& GetUIResourceProvider() override; |
| 65 virtual ui::ResourceManager& GetResourceManager() override; | 63 virtual ui::ResourceManager& GetResourceManager() override; |
| 66 | 64 |
| 67 // LayerTreeHostClient implementation. | 65 // LayerTreeHostClient implementation. |
| 68 virtual void WillBeginMainFrame(int frame_id) override {} | 66 virtual void WillBeginMainFrame(int frame_id) override {} |
| 69 virtual void DidBeginMainFrame() override {} | 67 virtual void DidBeginMainFrame() override {} |
| 70 virtual void BeginMainFrame(const cc::BeginFrameArgs& args) override {} | 68 virtual void BeginMainFrame(const cc::BeginFrameArgs& args) override {} |
| 71 virtual void Layout() override; | 69 virtual void Layout() override; |
| 72 virtual void ApplyViewportDeltas( | 70 virtual void ApplyViewportDeltas( |
| 73 const gfx::Vector2d& inner_delta, | 71 const gfx::Vector2d& inner_delta, |
| 74 const gfx::Vector2d& outer_delta, | 72 const gfx::Vector2d& outer_delta, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 92 virtual void DidPostSwapBuffers() override; | 90 virtual void DidPostSwapBuffers() override; |
| 93 virtual void DidAbortSwapBuffers() override; | 91 virtual void DidAbortSwapBuffers() override; |
| 94 | 92 |
| 95 // WindowAndroidCompositor implementation. | 93 // WindowAndroidCompositor implementation. |
| 96 virtual void AttachLayerForReadback(scoped_refptr<cc::Layer> layer) override; | 94 virtual void AttachLayerForReadback(scoped_refptr<cc::Layer> layer) override; |
| 97 virtual void RequestCopyOfOutputOnRootLayer( | 95 virtual void RequestCopyOfOutputOnRootLayer( |
| 98 scoped_ptr<cc::CopyOutputRequest> request) override; | 96 scoped_ptr<cc::CopyOutputRequest> request) override; |
| 99 virtual void OnVSync(base::TimeTicks frame_time, | 97 virtual void OnVSync(base::TimeTicks frame_time, |
| 100 base::TimeDelta vsync_period) override; | 98 base::TimeDelta vsync_period) override; |
| 101 virtual void SetNeedsAnimate() override; | 99 virtual void SetNeedsAnimate() override; |
| 102 virtual ui::SystemUIResourceManager& GetSystemUIResourceManager() override; | |
| 103 | 100 |
| 104 void SetWindowSurface(ANativeWindow* window); | 101 void SetWindowSurface(ANativeWindow* window); |
| 105 | 102 |
| 106 enum CompositingTrigger { | 103 enum CompositingTrigger { |
| 107 DO_NOT_COMPOSITE, | 104 DO_NOT_COMPOSITE, |
| 108 COMPOSITE_IMMEDIATELY, | 105 COMPOSITE_IMMEDIATELY, |
| 109 COMPOSITE_EVENTUALLY, | 106 COMPOSITE_EVENTUALLY, |
| 110 }; | 107 }; |
| 111 void PostComposite(CompositingTrigger trigger); | 108 void PostComposite(CompositingTrigger trigger); |
| 112 void Composite(CompositingTrigger trigger); | 109 void Composite(CompositingTrigger trigger); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 135 } | 132 } |
| 136 void CreateLayerTreeHost(); | 133 void CreateLayerTreeHost(); |
| 137 void OnGpuChannelEstablished(); | 134 void OnGpuChannelEstablished(); |
| 138 | 135 |
| 139 // root_layer_ is the persistent internal root layer, while subroot_layer_ | 136 // root_layer_ is the persistent internal root layer, while subroot_layer_ |
| 140 // is the one attached by the compositor client. | 137 // is the one attached by the compositor client. |
| 141 scoped_refptr<cc::Layer> root_layer_; | 138 scoped_refptr<cc::Layer> root_layer_; |
| 142 scoped_refptr<cc::Layer> subroot_layer_; | 139 scoped_refptr<cc::Layer> subroot_layer_; |
| 143 | 140 |
| 144 scoped_ptr<cc::LayerTreeHost> host_; | 141 scoped_ptr<cc::LayerTreeHost> host_; |
| 145 content::UIResourceProviderImpl ui_resource_provider_; | 142 ui::UIResourceProvider ui_resource_provider_; |
| 146 ui::ResourceManager resource_manager_; | 143 ui::ResourceManager resource_manager_; |
| 147 | 144 |
| 148 scoped_ptr<OnscreenDisplayClient> display_client_; | 145 scoped_ptr<OnscreenDisplayClient> display_client_; |
| 149 scoped_ptr<cc::SurfaceIdAllocator> surface_id_allocator_; | 146 scoped_ptr<cc::SurfaceIdAllocator> surface_id_allocator_; |
| 150 | 147 |
| 151 gfx::Size size_; | 148 gfx::Size size_; |
| 152 bool has_transparent_background_; | 149 bool has_transparent_background_; |
| 153 float device_scale_factor_; | 150 float device_scale_factor_; |
| 154 | 151 |
| 155 ANativeWindow* window_; | 152 ANativeWindow* window_; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 base::TimeTicks last_vsync_; | 192 base::TimeTicks last_vsync_; |
| 196 | 193 |
| 197 base::WeakPtrFactory<CompositorImpl> weak_factory_; | 194 base::WeakPtrFactory<CompositorImpl> weak_factory_; |
| 198 | 195 |
| 199 DISALLOW_COPY_AND_ASSIGN(CompositorImpl); | 196 DISALLOW_COPY_AND_ASSIGN(CompositorImpl); |
| 200 }; | 197 }; |
| 201 | 198 |
| 202 } // namespace content | 199 } // namespace content |
| 203 | 200 |
| 204 #endif // CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_IMPL_ANDROID_H_ | 201 #endif // CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_IMPL_ANDROID_H_ |
| OLD | NEW |