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" |
(...skipping 24 matching lines...) Expand all Loading... |
35 // ----------------------------------------------------------------------------- | 35 // ----------------------------------------------------------------------------- |
36 // Browser-side compositor that manages a tree of content and UI layers. | 36 // Browser-side compositor that manages a tree of content and UI layers. |
37 // ----------------------------------------------------------------------------- | 37 // ----------------------------------------------------------------------------- |
38 class CONTENT_EXPORT CompositorImpl | 38 class CONTENT_EXPORT CompositorImpl |
39 : public Compositor, | 39 : public Compositor, |
40 public cc::LayerTreeHostClient, | 40 public cc::LayerTreeHostClient, |
41 public cc::LayerTreeHostSingleThreadClient, | 41 public cc::LayerTreeHostSingleThreadClient, |
42 public ImageTransportFactoryAndroidObserver, | 42 public ImageTransportFactoryAndroidObserver, |
43 public ui::WindowAndroidCompositor { | 43 public ui::WindowAndroidCompositor { |
44 public: | 44 public: |
| 45 typedef base::Callback<void(int32)> CreateSurfaceTextureCallback; |
| 46 |
45 CompositorImpl(CompositorClient* client, gfx::NativeWindow root_window); | 47 CompositorImpl(CompositorClient* client, gfx::NativeWindow root_window); |
46 virtual ~CompositorImpl(); | 48 virtual ~CompositorImpl(); |
47 | 49 |
48 static bool IsInitialized(); | 50 static bool IsInitialized(); |
49 | 51 |
50 // Returns the Java Surface object for a given view surface id. | 52 // Returns the Java Surface object for a given view surface id. |
51 static jobject GetSurface(int surface_id); | 53 static jobject GetSurface(int surface_id); |
52 | 54 |
53 // Returns the Java Surface object for a given surface texture id. | 55 // Returns the Java Surface object for a given surface texture id. |
54 static jobject GetSurfaceTextureSurface(int surface_texture_id, | 56 static jobject GetSurfaceTextureSurface(int surface_texture_id, |
55 base::ProcessHandle process_handle); | 57 base::ProcessHandle process_handle); |
56 | 58 |
57 // Allocates a surface texture and returns a surface texture id. Returns -1 on | 59 // Creates a new surface texture. |
58 // failure. | 60 static void CreateSurfaceTexture( |
59 static int AllocateSurfaceTexture(base::ProcessHandle process_handle); | 61 base::ProcessHandle process_handle, |
| 62 const CreateSurfaceTextureCallback& callback); |
60 | 63 |
61 // Destroy all surface textures associated with |process_handle|. | 64 // Destroy all surface textures associated with |process_handle|. |
62 static void DestroyAllSurfaceTextures(base::ProcessHandle process_handle); | 65 static void DestroyAllSurfaceTextures(base::ProcessHandle process_handle); |
63 | 66 |
64 // Compositor implementation. | 67 // Compositor implementation. |
65 virtual void SetRootLayer(scoped_refptr<cc::Layer> root) OVERRIDE; | 68 virtual void SetRootLayer(scoped_refptr<cc::Layer> root) OVERRIDE; |
66 virtual void SetWindowSurface(ANativeWindow* window) OVERRIDE; | 69 virtual void SetWindowSurface(ANativeWindow* window) OVERRIDE; |
67 virtual void SetSurface(jobject surface) OVERRIDE; | 70 virtual void SetSurface(jobject surface) OVERRIDE; |
68 virtual void SetVisible(bool visible) OVERRIDE; | 71 virtual void SetVisible(bool visible) OVERRIDE; |
69 virtual void setDeviceScaleFactor(float factor) OVERRIDE; | 72 virtual void setDeviceScaleFactor(float factor) OVERRIDE; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 virtual void OnLostResources() OVERRIDE; | 110 virtual void OnLostResources() OVERRIDE; |
108 | 111 |
109 // WindowAndroidCompositor implementation. | 112 // WindowAndroidCompositor implementation. |
110 virtual void AttachLayerForReadback(scoped_refptr<cc::Layer> layer) OVERRIDE; | 113 virtual void AttachLayerForReadback(scoped_refptr<cc::Layer> layer) OVERRIDE; |
111 | 114 |
112 private: | 115 private: |
113 cc::UIResourceId GenerateUIResourceFromUIResourceBitmap( | 116 cc::UIResourceId GenerateUIResourceFromUIResourceBitmap( |
114 const cc::UIResourceBitmap& bitmap, | 117 const cc::UIResourceBitmap& bitmap, |
115 bool is_transient); | 118 bool is_transient); |
116 | 119 |
| 120 static void OnSurfaceTextureCreated( |
| 121 int surface_texture_id, |
| 122 base::ProcessHandle handle, |
| 123 const CreateSurfaceTextureCallback& callback); |
| 124 |
117 scoped_refptr<cc::Layer> root_layer_; | 125 scoped_refptr<cc::Layer> root_layer_; |
118 scoped_ptr<cc::LayerTreeHost> host_; | 126 scoped_ptr<cc::LayerTreeHost> host_; |
119 | 127 |
120 gfx::Size size_; | 128 gfx::Size size_; |
121 bool has_transparent_background_; | 129 bool has_transparent_background_; |
122 float device_scale_factor_; | 130 float device_scale_factor_; |
123 | 131 |
124 ANativeWindow* window_; | 132 ANativeWindow* window_; |
125 int surface_id_; | 133 int surface_id_; |
126 | 134 |
127 CompositorClient* client_; | 135 CompositorClient* client_; |
128 | 136 |
129 scoped_refptr<cc::ContextProvider> null_offscreen_context_provider_; | 137 scoped_refptr<cc::ContextProvider> null_offscreen_context_provider_; |
130 | 138 |
131 typedef base::ScopedPtrHashMap<cc::UIResourceId, cc::UIResourceClient> | 139 typedef base::ScopedPtrHashMap<cc::UIResourceId, cc::UIResourceClient> |
132 UIResourceMap; | 140 UIResourceMap; |
133 UIResourceMap ui_resource_map_; | 141 UIResourceMap ui_resource_map_; |
134 | 142 |
135 gfx::NativeWindow root_window_; | 143 gfx::NativeWindow root_window_; |
136 | 144 |
137 DISALLOW_COPY_AND_ASSIGN(CompositorImpl); | 145 DISALLOW_COPY_AND_ASSIGN(CompositorImpl); |
138 }; | 146 }; |
139 | 147 |
140 } // namespace content | 148 } // namespace content |
141 | 149 |
142 #endif // CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_IMPL_ANDROID_H_ | 150 #endif // CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_IMPL_ANDROID_H_ |
OLD | NEW |