| 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" | 11 #include "base/containers/scoped_ptr_hash_map.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "cc/resources/ui_resource_client.h" | 14 #include "cc/resources/ui_resource_client.h" |
| 15 #include "cc/trees/layer_tree_host_client.h" | 15 #include "cc/trees/layer_tree_host_client.h" |
| 16 #include "cc/trees/layer_tree_host_single_thread_client.h" | 16 #include "cc/trees/layer_tree_host_single_thread_client.h" |
| 17 #include "content/browser/android/ui_resource_provider_impl.h" |
| 17 #include "content/browser/renderer_host/image_transport_factory_android.h" | 18 #include "content/browser/renderer_host/image_transport_factory_android.h" |
| 18 #include "content/common/content_export.h" | 19 #include "content/common/content_export.h" |
| 19 #include "content/public/browser/android/compositor.h" | 20 #include "content/public/browser/android/compositor.h" |
| 20 #include "third_party/khronos/GLES2/gl2.h" | 21 #include "third_party/khronos/GLES2/gl2.h" |
| 21 #include "ui/base/android/window_android_compositor.h" | 22 #include "ui/base/android/window_android_compositor.h" |
| 22 | 23 |
| 23 class SkBitmap; | 24 class SkBitmap; |
| 24 struct ANativeWindow; | 25 struct ANativeWindow; |
| 25 | 26 |
| 26 namespace cc { | 27 namespace cc { |
| 27 class InputHandlerClient; | 28 class InputHandlerClient; |
| 28 class Layer; | 29 class Layer; |
| 29 class LayerTreeHost; | 30 class LayerTreeHost; |
| 30 } | 31 } |
| 31 | 32 |
| 32 namespace content { | 33 namespace content { |
| 33 class CompositorClient; | 34 class CompositorClient; |
| 34 class GraphicsContext; | 35 class GraphicsContext; |
| 36 class UIResourceProvider; |
| 35 | 37 |
| 36 // ----------------------------------------------------------------------------- | 38 // ----------------------------------------------------------------------------- |
| 37 // Browser-side compositor that manages a tree of content and UI layers. | 39 // Browser-side compositor that manages a tree of content and UI layers. |
| 38 // ----------------------------------------------------------------------------- | 40 // ----------------------------------------------------------------------------- |
| 39 class CONTENT_EXPORT CompositorImpl | 41 class CONTENT_EXPORT CompositorImpl |
| 40 : public Compositor, | 42 : public Compositor, |
| 41 public cc::LayerTreeHostClient, | 43 public cc::LayerTreeHostClient, |
| 42 public cc::LayerTreeHostSingleThreadClient, | 44 public cc::LayerTreeHostSingleThreadClient, |
| 43 public ImageTransportFactoryAndroidObserver, | 45 public ImageTransportFactoryAndroidObserver, |
| 44 public ui::WindowAndroidCompositor { | 46 public ui::WindowAndroidCompositor { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 58 private: | 60 private: |
| 59 // Compositor implementation. | 61 // Compositor implementation. |
| 60 virtual void SetRootLayer(scoped_refptr<cc::Layer> root) OVERRIDE; | 62 virtual void SetRootLayer(scoped_refptr<cc::Layer> root) OVERRIDE; |
| 61 virtual void SetWindowSurface(ANativeWindow* window) OVERRIDE; | 63 virtual void SetWindowSurface(ANativeWindow* window) OVERRIDE; |
| 62 virtual void SetSurface(jobject surface) OVERRIDE; | 64 virtual void SetSurface(jobject surface) OVERRIDE; |
| 63 virtual void SetVisible(bool visible) OVERRIDE; | 65 virtual void SetVisible(bool visible) OVERRIDE; |
| 64 virtual void setDeviceScaleFactor(float factor) OVERRIDE; | 66 virtual void setDeviceScaleFactor(float factor) OVERRIDE; |
| 65 virtual void SetWindowBounds(const gfx::Size& size) OVERRIDE; | 67 virtual void SetWindowBounds(const gfx::Size& size) OVERRIDE; |
| 66 virtual void SetHasTransparentBackground(bool flag) OVERRIDE; | 68 virtual void SetHasTransparentBackground(bool flag) OVERRIDE; |
| 67 virtual void SetNeedsComposite() OVERRIDE; | 69 virtual void SetNeedsComposite() OVERRIDE; |
| 68 virtual cc::UIResourceId GenerateUIResource(const SkBitmap& bitmap, | 70 virtual UIResourceProvider& GetUIResourceProvider() OVERRIDE; |
| 69 bool is_transient) OVERRIDE; | |
| 70 virtual cc::UIResourceId GenerateCompressedUIResource(const gfx::Size& size, | |
| 71 void* pixels, | |
| 72 bool is_transient) | |
| 73 OVERRIDE; | |
| 74 virtual void DeleteUIResource(cc::UIResourceId resource_id) OVERRIDE; | |
| 75 | 71 |
| 76 // LayerTreeHostClient implementation. | 72 // LayerTreeHostClient implementation. |
| 77 virtual void WillBeginMainFrame(int frame_id) OVERRIDE {} | 73 virtual void WillBeginMainFrame(int frame_id) OVERRIDE {} |
| 78 virtual void DidBeginMainFrame() OVERRIDE {} | 74 virtual void DidBeginMainFrame() OVERRIDE {} |
| 79 virtual void Animate(base::TimeTicks frame_begin_time) OVERRIDE {} | 75 virtual void Animate(base::TimeTicks frame_begin_time) OVERRIDE {} |
| 80 virtual void Layout() OVERRIDE; | 76 virtual void Layout() OVERRIDE; |
| 81 virtual void ApplyScrollAndScale(const gfx::Vector2d& scroll_delta, | 77 virtual void ApplyScrollAndScale(const gfx::Vector2d& scroll_delta, |
| 82 float page_scale) OVERRIDE {} | 78 float page_scale) OVERRIDE {} |
| 83 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback) | 79 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback) |
| 84 OVERRIDE; | 80 OVERRIDE; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 composite_on_vsync_trigger_ = DO_NOT_COMPOSITE; | 129 composite_on_vsync_trigger_ = DO_NOT_COMPOSITE; |
| 134 will_composite_immediately_ = false; | 130 will_composite_immediately_ = false; |
| 135 } | 131 } |
| 136 cc::UIResourceId GenerateUIResourceFromUIResourceBitmap( | 132 cc::UIResourceId GenerateUIResourceFromUIResourceBitmap( |
| 137 const cc::UIResourceBitmap& bitmap, | 133 const cc::UIResourceBitmap& bitmap, |
| 138 bool is_transient); | 134 bool is_transient); |
| 139 void OnGpuChannelEstablished(); | 135 void OnGpuChannelEstablished(); |
| 140 | 136 |
| 141 scoped_refptr<cc::Layer> root_layer_; | 137 scoped_refptr<cc::Layer> root_layer_; |
| 142 scoped_ptr<cc::LayerTreeHost> host_; | 138 scoped_ptr<cc::LayerTreeHost> host_; |
| 139 content::UIResourceProviderImpl ui_resource_provider_; |
| 143 | 140 |
| 144 gfx::Size size_; | 141 gfx::Size size_; |
| 145 bool has_transparent_background_; | 142 bool has_transparent_background_; |
| 146 float device_scale_factor_; | 143 float device_scale_factor_; |
| 147 | 144 |
| 148 ANativeWindow* window_; | 145 ANativeWindow* window_; |
| 149 int surface_id_; | 146 int surface_id_; |
| 150 | 147 |
| 151 CompositorClient* client_; | 148 CompositorClient* client_; |
| 152 | 149 |
| 153 typedef base::ScopedPtrHashMap<cc::UIResourceId, cc::UIResourceClient> | |
| 154 UIResourceMap; | |
| 155 UIResourceMap ui_resource_map_; | |
| 156 | |
| 157 gfx::NativeWindow root_window_; | 150 gfx::NativeWindow root_window_; |
| 158 | 151 |
| 159 // Used locally to track whether a call to LTH::Composite() did result in | 152 // Used locally to track whether a call to LTH::Composite() did result in |
| 160 // a posted SwapBuffers(). | 153 // a posted SwapBuffers(). |
| 161 bool did_post_swapbuffers_; | 154 bool did_post_swapbuffers_; |
| 162 | 155 |
| 163 // Used locally to inhibit ScheduleComposite() during Layout(). | 156 // Used locally to inhibit ScheduleComposite() during Layout(). |
| 164 bool ignore_schedule_composite_; | 157 bool ignore_schedule_composite_; |
| 165 | 158 |
| 166 // Whether we need to composite in general because of any invalidation or | 159 // Whether we need to composite in general because of any invalidation or |
| (...skipping 20 matching lines...) Expand all Loading... |
| 187 base::TimeTicks last_vsync_; | 180 base::TimeTicks last_vsync_; |
| 188 | 181 |
| 189 base::WeakPtrFactory<CompositorImpl> weak_factory_; | 182 base::WeakPtrFactory<CompositorImpl> weak_factory_; |
| 190 | 183 |
| 191 DISALLOW_COPY_AND_ASSIGN(CompositorImpl); | 184 DISALLOW_COPY_AND_ASSIGN(CompositorImpl); |
| 192 }; | 185 }; |
| 193 | 186 |
| 194 } // namespace content | 187 } // namespace content |
| 195 | 188 |
| 196 #endif // CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_IMPL_ANDROID_H_ | 189 #endif // CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_IMPL_ANDROID_H_ |
| OLD | NEW |