| 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/containers/scoped_ptr_hash_map.h" | |
| 12 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 14 #include "cc/resources/ui_resource_client.h" | |
| 15 #include "cc/trees/layer_tree_host_client.h" | 13 #include "cc/trees/layer_tree_host_client.h" |
| 16 #include "cc/trees/layer_tree_host_single_thread_client.h" | 14 #include "cc/trees/layer_tree_host_single_thread_client.h" |
| 17 #include "content/browser/android/ui_resource_provider_impl.h" | 15 #include "content/browser/android/ui_resource_provider_impl.h" |
| 18 #include "content/browser/renderer_host/image_transport_factory_android.h" | 16 #include "content/browser/renderer_host/image_transport_factory_android.h" |
| 19 #include "content/common/content_export.h" | 17 #include "content/common/content_export.h" |
| 20 #include "content/public/browser/android/compositor.h" | 18 #include "content/public/browser/android/compositor.h" |
| 21 #include "third_party/khronos/GLES2/gl2.h" | 19 #include "third_party/khronos/GLES2/gl2.h" |
| 22 #include "ui/base/android/window_android_compositor.h" | 20 #include "ui/base/android/window_android_compositor.h" |
| 23 | 21 |
| 24 class SkBitmap; | 22 class SkBitmap; |
| 25 struct ANativeWindow; | 23 struct ANativeWindow; |
| 26 | 24 |
| 27 namespace cc { | 25 namespace cc { |
| 28 class Layer; | 26 class Layer; |
| 29 class LayerTreeHost; | 27 class LayerTreeHost; |
| 30 } | 28 } |
| 31 | 29 |
| 32 namespace content { | 30 namespace content { |
| 33 class CompositorClient; | 31 class CompositorClient; |
| 34 class UIResourceProvider; | |
| 35 | 32 |
| 36 // ----------------------------------------------------------------------------- | 33 // ----------------------------------------------------------------------------- |
| 37 // Browser-side compositor that manages a tree of content and UI layers. | 34 // Browser-side compositor that manages a tree of content and UI layers. |
| 38 // ----------------------------------------------------------------------------- | 35 // ----------------------------------------------------------------------------- |
| 39 class CONTENT_EXPORT CompositorImpl | 36 class CONTENT_EXPORT CompositorImpl |
| 40 : public Compositor, | 37 : public Compositor, |
| 41 public cc::LayerTreeHostClient, | 38 public cc::LayerTreeHostClient, |
| 42 public cc::LayerTreeHostSingleThreadClient, | 39 public cc::LayerTreeHostSingleThreadClient, |
| 43 public ImageTransportFactoryAndroidObserver, | 40 public ImageTransportFactoryAndroidObserver, |
| 44 public ui::WindowAndroidCompositor { | 41 public ui::WindowAndroidCompositor { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 58 private: | 55 private: |
| 59 // Compositor implementation. | 56 // Compositor implementation. |
| 60 virtual void SetRootLayer(scoped_refptr<cc::Layer> root) OVERRIDE; | 57 virtual void SetRootLayer(scoped_refptr<cc::Layer> root) OVERRIDE; |
| 61 virtual void SetWindowSurface(ANativeWindow* window) OVERRIDE; | 58 virtual void SetWindowSurface(ANativeWindow* window) OVERRIDE; |
| 62 virtual void SetSurface(jobject surface) OVERRIDE; | 59 virtual void SetSurface(jobject surface) OVERRIDE; |
| 63 virtual void SetVisible(bool visible) OVERRIDE; | 60 virtual void SetVisible(bool visible) OVERRIDE; |
| 64 virtual void setDeviceScaleFactor(float factor) OVERRIDE; | 61 virtual void setDeviceScaleFactor(float factor) OVERRIDE; |
| 65 virtual void SetWindowBounds(const gfx::Size& size) OVERRIDE; | 62 virtual void SetWindowBounds(const gfx::Size& size) OVERRIDE; |
| 66 virtual void SetHasTransparentBackground(bool flag) OVERRIDE; | 63 virtual void SetHasTransparentBackground(bool flag) OVERRIDE; |
| 67 virtual void SetNeedsComposite() OVERRIDE; | 64 virtual void SetNeedsComposite() OVERRIDE; |
| 68 virtual UIResourceProvider& GetUIResourceProvider() OVERRIDE; | |
| 69 | 65 |
| 70 // LayerTreeHostClient implementation. | 66 // LayerTreeHostClient implementation. |
| 71 virtual void WillBeginMainFrame(int frame_id) OVERRIDE {} | 67 virtual void WillBeginMainFrame(int frame_id) OVERRIDE {} |
| 72 virtual void DidBeginMainFrame() OVERRIDE {} | 68 virtual void DidBeginMainFrame() OVERRIDE {} |
| 73 virtual void Animate(base::TimeTicks frame_begin_time) OVERRIDE {} | 69 virtual void Animate(base::TimeTicks frame_begin_time) OVERRIDE {} |
| 74 virtual void Layout() OVERRIDE; | 70 virtual void Layout() OVERRIDE; |
| 75 virtual void ApplyScrollAndScale(const gfx::Vector2d& scroll_delta, | 71 virtual void ApplyScrollAndScale(const gfx::Vector2d& scroll_delta, |
| 76 float page_scale) OVERRIDE {} | 72 float page_scale) OVERRIDE {} |
| 77 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback) | 73 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback) |
| 78 OVERRIDE; | 74 OVERRIDE; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 91 // ImageTransportFactoryAndroidObserver implementation. | 87 // ImageTransportFactoryAndroidObserver implementation. |
| 92 virtual void OnLostResources() OVERRIDE; | 88 virtual void OnLostResources() OVERRIDE; |
| 93 | 89 |
| 94 // WindowAndroidCompositor implementation. | 90 // WindowAndroidCompositor implementation. |
| 95 virtual void AttachLayerForReadback(scoped_refptr<cc::Layer> layer) OVERRIDE; | 91 virtual void AttachLayerForReadback(scoped_refptr<cc::Layer> layer) OVERRIDE; |
| 96 virtual void RequestCopyOfOutputOnRootLayer( | 92 virtual void RequestCopyOfOutputOnRootLayer( |
| 97 scoped_ptr<cc::CopyOutputRequest> request) OVERRIDE; | 93 scoped_ptr<cc::CopyOutputRequest> request) OVERRIDE; |
| 98 virtual void OnVSync(base::TimeTicks frame_time, | 94 virtual void OnVSync(base::TimeTicks frame_time, |
| 99 base::TimeDelta vsync_period) OVERRIDE; | 95 base::TimeDelta vsync_period) OVERRIDE; |
| 100 virtual void SetNeedsAnimate() OVERRIDE; | 96 virtual void SetNeedsAnimate() OVERRIDE; |
| 97 virtual ui::UIResourceProvider& GetUIResourceProvider() OVERRIDE; |
| 101 | 98 |
| 102 enum CompositingTrigger { | 99 enum CompositingTrigger { |
| 103 DO_NOT_COMPOSITE, | 100 DO_NOT_COMPOSITE, |
| 104 COMPOSITE_IMMEDIATELY, | 101 COMPOSITE_IMMEDIATELY, |
| 105 COMPOSITE_EVENTUALLY, | 102 COMPOSITE_EVENTUALLY, |
| 106 }; | 103 }; |
| 107 void PostComposite(CompositingTrigger trigger); | 104 void PostComposite(CompositingTrigger trigger); |
| 108 void Composite(CompositingTrigger trigger); | 105 void Composite(CompositingTrigger trigger); |
| 109 | 106 |
| 110 bool WillCompositeThisFrame() const { | 107 bool WillCompositeThisFrame() const { |
| 111 return current_composite_task_ && | 108 return current_composite_task_ && |
| 112 !current_composite_task_->callback().is_null(); | 109 !current_composite_task_->callback().is_null(); |
| 113 } | 110 } |
| 114 bool DidCompositeThisFrame() const { | 111 bool DidCompositeThisFrame() const { |
| 115 return current_composite_task_ && | 112 return current_composite_task_ && |
| 116 current_composite_task_->callback().is_null(); | 113 current_composite_task_->callback().is_null(); |
| 117 } | 114 } |
| 118 bool WillComposite() const { | 115 bool WillComposite() const { |
| 119 return WillCompositeThisFrame() || | 116 return WillCompositeThisFrame() || |
| 120 composite_on_vsync_trigger_ != DO_NOT_COMPOSITE; | 117 composite_on_vsync_trigger_ != DO_NOT_COMPOSITE; |
| 121 } | 118 } |
| 122 void CancelComposite() { | 119 void CancelComposite() { |
| 123 DCHECK(WillComposite()); | 120 DCHECK(WillComposite()); |
| 124 if (WillCompositeThisFrame()) | 121 if (WillCompositeThisFrame()) |
| 125 current_composite_task_->Cancel(); | 122 current_composite_task_->Cancel(); |
| 126 current_composite_task_.reset(); | 123 current_composite_task_.reset(); |
| 127 composite_on_vsync_trigger_ = DO_NOT_COMPOSITE; | 124 composite_on_vsync_trigger_ = DO_NOT_COMPOSITE; |
| 128 will_composite_immediately_ = false; | 125 will_composite_immediately_ = false; |
| 129 } | 126 } |
| 130 cc::UIResourceId GenerateUIResourceFromUIResourceBitmap( | |
| 131 const cc::UIResourceBitmap& bitmap, | |
| 132 bool is_transient); | |
| 133 void OnGpuChannelEstablished(); | 127 void OnGpuChannelEstablished(); |
| 134 | 128 |
| 135 scoped_refptr<cc::Layer> root_layer_; | 129 scoped_refptr<cc::Layer> root_layer_; |
| 136 scoped_ptr<cc::LayerTreeHost> host_; | 130 scoped_ptr<cc::LayerTreeHost> host_; |
| 137 content::UIResourceProviderImpl ui_resource_provider_; | 131 content::UIResourceProviderImpl ui_resource_provider_; |
| 138 | 132 |
| 139 gfx::Size size_; | 133 gfx::Size size_; |
| 140 bool has_transparent_background_; | 134 bool has_transparent_background_; |
| 141 float device_scale_factor_; | 135 float device_scale_factor_; |
| 142 | 136 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 base::TimeTicks last_vsync_; | 172 base::TimeTicks last_vsync_; |
| 179 | 173 |
| 180 base::WeakPtrFactory<CompositorImpl> weak_factory_; | 174 base::WeakPtrFactory<CompositorImpl> weak_factory_; |
| 181 | 175 |
| 182 DISALLOW_COPY_AND_ASSIGN(CompositorImpl); | 176 DISALLOW_COPY_AND_ASSIGN(CompositorImpl); |
| 183 }; | 177 }; |
| 184 | 178 |
| 185 } // namespace content | 179 } // namespace content |
| 186 | 180 |
| 187 #endif // CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_IMPL_ANDROID_H_ | 181 #endif // CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_IMPL_ANDROID_H_ |
| OLD | NEW |