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/renderer_host/image_transport_factory_android.h" | 15 #include "content/browser/renderer_host/image_transport_factory_android.h" |
16 #include "content/common/content_export.h" | 16 #include "content/common/content_export.h" |
17 #include "content/public/browser/android/compositor.h" | 17 #include "content/public/browser/android/compositor.h" |
18 #include "third_party/khronos/GLES2/gl2.h" | 18 #include "third_party/khronos/GLES2/gl2.h" |
19 | 19 |
20 class SkBitmap; | |
21 struct ANativeWindow; | 20 struct ANativeWindow; |
22 | 21 |
23 namespace cc { | 22 namespace cc { |
24 class InputHandlerClient; | 23 class InputHandlerClient; |
25 class Layer; | 24 class Layer; |
26 class LayerTreeHost; | 25 class LayerTreeHost; |
| 26 class ScopedUIResource; |
27 } | 27 } |
28 | 28 |
29 namespace content { | 29 namespace content { |
30 class CompositorClient; | 30 class CompositorClient; |
31 class GraphicsContext; | 31 class GraphicsContext; |
32 | 32 |
33 // ----------------------------------------------------------------------------- | 33 // ----------------------------------------------------------------------------- |
34 // 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. |
35 // ----------------------------------------------------------------------------- | 35 // ----------------------------------------------------------------------------- |
36 class CONTENT_EXPORT CompositorImpl | 36 class CONTENT_EXPORT CompositorImpl |
(...skipping 14 matching lines...) Expand all Loading... |
51 virtual void SetRootLayer(scoped_refptr<cc::Layer> root) OVERRIDE; | 51 virtual void SetRootLayer(scoped_refptr<cc::Layer> root) OVERRIDE; |
52 virtual void SetWindowSurface(ANativeWindow* window) OVERRIDE; | 52 virtual void SetWindowSurface(ANativeWindow* window) OVERRIDE; |
53 virtual void SetSurface(jobject surface) OVERRIDE; | 53 virtual void SetSurface(jobject surface) OVERRIDE; |
54 virtual void SetVisible(bool visible) OVERRIDE; | 54 virtual void SetVisible(bool visible) OVERRIDE; |
55 virtual void setDeviceScaleFactor(float factor) OVERRIDE; | 55 virtual void setDeviceScaleFactor(float factor) OVERRIDE; |
56 virtual void SetWindowBounds(const gfx::Size& size) OVERRIDE; | 56 virtual void SetWindowBounds(const gfx::Size& size) OVERRIDE; |
57 virtual void SetHasTransparentBackground(bool flag) OVERRIDE; | 57 virtual void SetHasTransparentBackground(bool flag) OVERRIDE; |
58 virtual bool CompositeAndReadback( | 58 virtual bool CompositeAndReadback( |
59 void *pixels, const gfx::Rect& rect) OVERRIDE; | 59 void *pixels, const gfx::Rect& rect) OVERRIDE; |
60 virtual void Composite() OVERRIDE; | 60 virtual void Composite() OVERRIDE; |
61 virtual cc::UIResourceId GenerateUIResource(const SkBitmap& bitmap, | 61 virtual cc::UIResourceId GenerateUIResource( |
62 bool is_transient) OVERRIDE; | 62 const cc::UIResourceBitmap& bitmap) OVERRIDE; |
63 virtual cc::UIResourceId GenerateCompressedUIResource(const gfx::Size& size, | |
64 void* pixels, | |
65 bool is_transient) | |
66 OVERRIDE; | |
67 virtual void DeleteUIResource(cc::UIResourceId resource_id) OVERRIDE; | 63 virtual void DeleteUIResource(cc::UIResourceId resource_id) OVERRIDE; |
| 64 virtual GLuint GenerateTexture(gfx::JavaBitmap& bitmap) OVERRIDE; |
| 65 virtual GLuint GenerateCompressedTexture( |
| 66 gfx::Size& size, int data_size, void* data) OVERRIDE; |
| 67 virtual void DeleteTexture(GLuint texture_id) OVERRIDE; |
| 68 virtual bool CopyTextureToBitmap(GLuint texture_id, |
| 69 gfx::JavaBitmap& bitmap) OVERRIDE; |
| 70 virtual bool CopyTextureToBitmap(GLuint texture_id, |
| 71 const gfx::Rect& sub_rect, |
| 72 gfx::JavaBitmap& bitmap) OVERRIDE; |
68 | 73 |
69 // LayerTreeHostClient implementation. | 74 // LayerTreeHostClient implementation. |
70 virtual void WillBeginMainFrame(int frame_id) OVERRIDE {} | 75 virtual void WillBeginMainFrame(int frame_id) OVERRIDE {} |
71 virtual void DidBeginMainFrame() OVERRIDE {} | 76 virtual void DidBeginMainFrame() OVERRIDE {} |
72 virtual void Animate(double frame_begin_time) OVERRIDE {} | 77 virtual void Animate(double frame_begin_time) OVERRIDE {} |
73 virtual void Layout() OVERRIDE {} | 78 virtual void Layout() OVERRIDE {} |
74 virtual void ApplyScrollAndScale(const gfx::Vector2d& scroll_delta, | 79 virtual void ApplyScrollAndScale(const gfx::Vector2d& scroll_delta, |
75 float page_scale) OVERRIDE {} | 80 float page_scale) OVERRIDE {} |
76 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback) | 81 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback) |
77 OVERRIDE; | 82 OVERRIDE; |
78 virtual void DidInitializeOutputSurface(bool success) OVERRIDE {} | 83 virtual void DidInitializeOutputSurface(bool success) OVERRIDE {} |
79 virtual void WillCommit() OVERRIDE {} | 84 virtual void WillCommit() OVERRIDE {} |
80 virtual void DidCommit() OVERRIDE; | 85 virtual void DidCommit() OVERRIDE; |
81 virtual void DidCommitAndDrawFrame() OVERRIDE {} | 86 virtual void DidCommitAndDrawFrame() OVERRIDE {} |
82 virtual void DidCompleteSwapBuffers() OVERRIDE; | 87 virtual void DidCompleteSwapBuffers() OVERRIDE; |
83 virtual scoped_refptr<cc::ContextProvider> | 88 virtual scoped_refptr<cc::ContextProvider> |
84 OffscreenContextProvider() OVERRIDE; | 89 OffscreenContextProvider() OVERRIDE; |
85 | 90 |
86 // LayerTreeHostSingleThreadClient implementation. | 91 // LayerTreeHostSingleThreadClient implementation. |
87 virtual void ScheduleComposite() OVERRIDE; | 92 virtual void ScheduleComposite() OVERRIDE; |
88 virtual void ScheduleAnimation() OVERRIDE; | 93 virtual void ScheduleAnimation() OVERRIDE; |
89 virtual void DidPostSwapBuffers() OVERRIDE; | 94 virtual void DidPostSwapBuffers() OVERRIDE; |
90 virtual void DidAbortSwapBuffers() OVERRIDE; | 95 virtual void DidAbortSwapBuffers() OVERRIDE; |
91 | 96 |
92 // ImageTransportFactoryAndroidObserver implementation. | 97 // ImageTransportFactoryAndroidObserver implementation. |
93 virtual void OnLostResources() OVERRIDE; | 98 virtual void OnLostResources() OVERRIDE; |
94 | 99 |
95 private: | 100 private: |
96 cc::UIResourceId GenerateUIResourceFromUIResourceBitmap( | 101 GLuint BuildBasicTexture(); |
97 const cc::UIResourceBitmap& bitmap, | 102 GLenum GetGLFormatForBitmap(gfx::JavaBitmap& bitmap); |
98 bool is_transient); | 103 GLenum GetGLTypeForBitmap(gfx::JavaBitmap& bitmap); |
99 | 104 |
100 scoped_refptr<cc::Layer> root_layer_; | 105 scoped_refptr<cc::Layer> root_layer_; |
101 scoped_ptr<cc::LayerTreeHost> host_; | 106 scoped_ptr<cc::LayerTreeHost> host_; |
102 | 107 |
103 gfx::Size size_; | 108 gfx::Size size_; |
104 bool has_transparent_background_; | 109 bool has_transparent_background_; |
105 | 110 |
106 ANativeWindow* window_; | 111 ANativeWindow* window_; |
107 int surface_id_; | 112 int surface_id_; |
108 | 113 |
109 CompositorClient* client_; | 114 CompositorClient* client_; |
110 | 115 |
111 scoped_refptr<cc::ContextProvider> null_offscreen_context_provider_; | 116 scoped_refptr<cc::ContextProvider> null_offscreen_context_provider_; |
112 | 117 |
113 typedef base::ScopedPtrHashMap<cc::UIResourceId, cc::UIResourceClient> | 118 typedef base::ScopedPtrHashMap<cc::UIResourceId, cc::ScopedUIResource> |
114 UIResourceMap; | 119 UIResourceMap; |
115 UIResourceMap ui_resource_map_; | 120 UIResourceMap ui_resource_map_; |
116 | 121 |
117 gfx::NativeWindow root_window_; | 122 gfx::NativeWindow root_window_; |
118 | 123 |
119 DISALLOW_COPY_AND_ASSIGN(CompositorImpl); | 124 DISALLOW_COPY_AND_ASSIGN(CompositorImpl); |
120 }; | 125 }; |
121 | 126 |
122 } // namespace content | 127 } // namespace content |
123 | 128 |
124 #endif // CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_IMPL_ANDROID_H_ | 129 #endif // CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_IMPL_ANDROID_H_ |
OLD | NEW |