| 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/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/containers/scoped_ptr_hash_map.h" | 10 #include "base/containers/scoped_ptr_hash_map.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "cc/resources/ui_resource_client.h" | 12 #include "cc/resources/ui_resource_client.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" |
| 15 #include "content/browser/renderer_host/image_transport_factory_android.h" | 16 #include "content/browser/renderer_host/image_transport_factory_android.h" |
| 16 #include "content/common/content_export.h" | 17 #include "content/common/content_export.h" |
| 17 #include "content/public/browser/android/compositor.h" | 18 #include "content/public/browser/android/compositor.h" |
| 18 #include "third_party/khronos/GLES2/gl2.h" | 19 #include "third_party/khronos/GLES2/gl2.h" |
| 19 #include "ui/base/android/window_android_compositor.h" | 20 #include "ui/base/android/window_android_compositor.h" |
| 20 | 21 |
| 21 class SkBitmap; | 22 class SkBitmap; |
| 22 struct ANativeWindow; | 23 struct ANativeWindow; |
| 23 | 24 |
| 24 namespace cc { | 25 namespace cc { |
| 25 class InputHandlerClient; | 26 class InputHandlerClient; |
| 26 class Layer; | 27 class Layer; |
| 27 class LayerTreeHost; | 28 class LayerTreeHost; |
| 28 } | 29 } |
| 29 | 30 |
| 30 namespace content { | 31 namespace content { |
| 31 class CompositorClient; | 32 class CompositorClient; |
| 32 class GraphicsContext; | 33 class GraphicsContext; |
| 34 class UIResourceProvider; |
| 33 | 35 |
| 34 // ----------------------------------------------------------------------------- | 36 // ----------------------------------------------------------------------------- |
| 35 // Browser-side compositor that manages a tree of content and UI layers. | 37 // Browser-side compositor that manages a tree of content and UI layers. |
| 36 // ----------------------------------------------------------------------------- | 38 // ----------------------------------------------------------------------------- |
| 37 class CONTENT_EXPORT CompositorImpl | 39 class CONTENT_EXPORT CompositorImpl |
| 38 : public Compositor, | 40 : public Compositor, |
| 39 public cc::LayerTreeHostClient, | 41 public cc::LayerTreeHostClient, |
| 40 public cc::LayerTreeHostSingleThreadClient, | 42 public cc::LayerTreeHostSingleThreadClient, |
| 41 public ImageTransportFactoryAndroidObserver, | 43 public ImageTransportFactoryAndroidObserver, |
| 42 public ui::WindowAndroidCompositor { | 44 public ui::WindowAndroidCompositor { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 57 virtual void SetRootLayer(scoped_refptr<cc::Layer> root) OVERRIDE; | 59 virtual void SetRootLayer(scoped_refptr<cc::Layer> root) OVERRIDE; |
| 58 virtual void SetWindowSurface(ANativeWindow* window) OVERRIDE; | 60 virtual void SetWindowSurface(ANativeWindow* window) OVERRIDE; |
| 59 virtual void SetSurface(jobject surface) OVERRIDE; | 61 virtual void SetSurface(jobject surface) OVERRIDE; |
| 60 virtual void SetVisible(bool visible) OVERRIDE; | 62 virtual void SetVisible(bool visible) OVERRIDE; |
| 61 virtual void setDeviceScaleFactor(float factor) OVERRIDE; | 63 virtual void setDeviceScaleFactor(float factor) OVERRIDE; |
| 62 virtual void SetWindowBounds(const gfx::Size& size) OVERRIDE; | 64 virtual void SetWindowBounds(const gfx::Size& size) OVERRIDE; |
| 63 virtual void SetHasTransparentBackground(bool flag) OVERRIDE; | 65 virtual void SetHasTransparentBackground(bool flag) OVERRIDE; |
| 64 virtual bool CompositeAndReadback( | 66 virtual bool CompositeAndReadback( |
| 65 void *pixels, const gfx::Rect& rect) OVERRIDE; | 67 void *pixels, const gfx::Rect& rect) OVERRIDE; |
| 66 virtual void Composite() OVERRIDE; | 68 virtual void Composite() OVERRIDE; |
| 67 virtual cc::UIResourceId GenerateUIResource(const SkBitmap& bitmap, | 69 virtual UIResourceProvider* GetUIResourceProvider() OVERRIDE; |
| 68 bool is_transient) OVERRIDE; | |
| 69 virtual cc::UIResourceId GenerateCompressedUIResource(const gfx::Size& size, | |
| 70 void* pixels, | |
| 71 bool is_transient) | |
| 72 OVERRIDE; | |
| 73 virtual void DeleteUIResource(cc::UIResourceId resource_id) OVERRIDE; | |
| 74 | 70 |
| 75 // LayerTreeHostClient implementation. | 71 // LayerTreeHostClient implementation. |
| 76 virtual void WillBeginMainFrame(int frame_id) OVERRIDE {} | 72 virtual void WillBeginMainFrame(int frame_id) OVERRIDE {} |
| 77 virtual void DidBeginMainFrame() OVERRIDE {} | 73 virtual void DidBeginMainFrame() OVERRIDE {} |
| 78 virtual void Animate(base::TimeTicks frame_begin_time) OVERRIDE {} | 74 virtual void Animate(base::TimeTicks frame_begin_time) OVERRIDE {} |
| 79 virtual void Layout() OVERRIDE {} | 75 virtual void Layout() OVERRIDE {} |
| 80 virtual void ApplyScrollAndScale(const gfx::Vector2d& scroll_delta, | 76 virtual void ApplyScrollAndScale(const gfx::Vector2d& scroll_delta, |
| 81 float page_scale) OVERRIDE {} | 77 float page_scale) OVERRIDE {} |
| 82 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback) | 78 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback) |
| 83 OVERRIDE; | 79 OVERRIDE; |
| 84 virtual void DidInitializeOutputSurface() OVERRIDE {} | 80 virtual void DidInitializeOutputSurface() OVERRIDE {} |
| 85 virtual void WillCommit() OVERRIDE {} | 81 virtual void WillCommit() OVERRIDE {} |
| 86 virtual void DidCommit() OVERRIDE; | 82 virtual void DidCommit() OVERRIDE; |
| 87 virtual void DidCommitAndDrawFrame() OVERRIDE {} | 83 virtual void DidCommitAndDrawFrame() OVERRIDE {} |
| 88 virtual void DidCompleteSwapBuffers() OVERRIDE; | 84 virtual void DidCompleteSwapBuffers() OVERRIDE; |
| 89 | 85 |
| 90 // LayerTreeHostSingleThreadClient implementation. | 86 // LayerTreeHostSingleThreadClient implementation. |
| 91 virtual void ScheduleComposite() OVERRIDE; | 87 virtual void ScheduleComposite() OVERRIDE; |
| 92 virtual void ScheduleAnimation() OVERRIDE; | 88 virtual void ScheduleAnimation() OVERRIDE; |
| 93 virtual void DidPostSwapBuffers() OVERRIDE; | 89 virtual void DidPostSwapBuffers() OVERRIDE; |
| 94 virtual void DidAbortSwapBuffers() OVERRIDE; | 90 virtual void DidAbortSwapBuffers() OVERRIDE; |
| 95 | 91 |
| 96 // ImageTransportFactoryAndroidObserver implementation. | 92 // ImageTransportFactoryAndroidObserver implementation. |
| 97 virtual void OnLostResources() OVERRIDE; | 93 virtual void OnLostResources() OVERRIDE; |
| 98 | 94 |
| 99 // WindowAndroidCompositor implementation. | 95 // WindowAndroidCompositor implementation. |
| 100 virtual void AttachLayerForReadback(scoped_refptr<cc::Layer> layer) OVERRIDE; | 96 virtual void AttachLayerForReadback(scoped_refptr<cc::Layer> layer) OVERRIDE; |
| 101 | 97 |
| 102 private: | 98 private: |
| 103 cc::UIResourceId GenerateUIResourceFromUIResourceBitmap( | |
| 104 const cc::UIResourceBitmap& bitmap, | |
| 105 bool is_transient); | |
| 106 | |
| 107 scoped_refptr<cc::Layer> root_layer_; | 99 scoped_refptr<cc::Layer> root_layer_; |
| 108 scoped_ptr<cc::LayerTreeHost> host_; | 100 scoped_ptr<cc::LayerTreeHost> host_; |
| 101 content::UIResourceProviderImpl ui_resource_provider_; |
| 109 | 102 |
| 110 gfx::Size size_; | 103 gfx::Size size_; |
| 111 bool has_transparent_background_; | 104 bool has_transparent_background_; |
| 112 float device_scale_factor_; | 105 float device_scale_factor_; |
| 113 | 106 |
| 114 ANativeWindow* window_; | 107 ANativeWindow* window_; |
| 115 int surface_id_; | 108 int surface_id_; |
| 116 | 109 |
| 117 CompositorClient* client_; | 110 CompositorClient* client_; |
| 118 | 111 |
| 119 typedef base::ScopedPtrHashMap<cc::UIResourceId, cc::UIResourceClient> | |
| 120 UIResourceMap; | |
| 121 UIResourceMap ui_resource_map_; | |
| 122 | |
| 123 gfx::NativeWindow root_window_; | 112 gfx::NativeWindow root_window_; |
| 124 | 113 |
| 125 DISALLOW_COPY_AND_ASSIGN(CompositorImpl); | 114 DISALLOW_COPY_AND_ASSIGN(CompositorImpl); |
| 126 }; | 115 }; |
| 127 | 116 |
| 128 } // namespace content | 117 } // namespace content |
| 129 | 118 |
| 130 #endif // CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_IMPL_ANDROID_H_ | 119 #endif // CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_IMPL_ANDROID_H_ |
| OLD | NEW |