| 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 19 matching lines...) Expand all Loading... |
| 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 |
| 37 : public Compositor, | 37 : public Compositor, |
| 38 public cc::LayerTreeHostClient, | 38 public cc::LayerTreeHostClient, |
| 39 public cc::LayerTreeHostSingleThreadClient, | 39 public cc::LayerTreeHostSingleThreadClient, |
| 40 public ImageTransportFactoryAndroidObserver { | 40 public ImageTransportFactoryAndroidObserver, |
| 41 public cc::UIResourceClient { |
| 41 public: | 42 public: |
| 42 CompositorImpl(CompositorClient* client, gfx::NativeWindow root_window); | 43 CompositorImpl(CompositorClient* client, gfx::NativeWindow root_window); |
| 43 virtual ~CompositorImpl(); | 44 virtual ~CompositorImpl(); |
| 44 | 45 |
| 45 static bool IsInitialized(); | 46 static bool IsInitialized(); |
| 46 | 47 |
| 47 // Returns the Java Surface object for a given view surface id. | 48 // Returns the Java Surface object for a given view surface id. |
| 48 static jobject GetSurface(int surface_id); | 49 static jobject GetSurface(int surface_id); |
| 49 | 50 |
| 50 // Compositor implementation. | 51 // Compositor implementation. |
| 51 virtual void SetRootLayer(scoped_refptr<cc::Layer> root) OVERRIDE; | 52 virtual void SetRootLayer(scoped_refptr<cc::Layer> root) OVERRIDE; |
| 52 virtual void SetWindowSurface(ANativeWindow* window) OVERRIDE; | 53 virtual void SetWindowSurface(ANativeWindow* window) OVERRIDE; |
| 53 virtual void SetSurface(jobject surface) OVERRIDE; | 54 virtual void SetSurface(jobject surface) OVERRIDE; |
| 54 virtual void SetVisible(bool visible) OVERRIDE; | 55 virtual void SetVisible(bool visible) OVERRIDE; |
| 55 virtual void setDeviceScaleFactor(float factor) OVERRIDE; | 56 virtual void setDeviceScaleFactor(float factor) OVERRIDE; |
| 56 virtual void SetWindowBounds(const gfx::Size& size) OVERRIDE; | 57 virtual void SetWindowBounds(const gfx::Size& size) OVERRIDE; |
| 57 virtual void SetHasTransparentBackground(bool flag) OVERRIDE; | 58 virtual void SetHasTransparentBackground(bool flag) OVERRIDE; |
| 58 virtual bool CompositeAndReadback( | 59 virtual bool CompositeAndReadback( |
| 59 void *pixels, const gfx::Rect& rect) OVERRIDE; | 60 void *pixels, const gfx::Rect& rect) OVERRIDE; |
| 60 virtual void Composite() OVERRIDE; | 61 virtual void Composite() OVERRIDE; |
| 61 virtual cc::UIResourceId GenerateUIResource( | 62 virtual cc::UIResourceId GenerateUIResource( |
| 62 const cc::UIResourceBitmap& bitmap) OVERRIDE; | 63 const cc::UIResourceBitmap& bitmap) OVERRIDE; |
| 63 virtual void DeleteUIResource(cc::UIResourceId resource_id) OVERRIDE; | 64 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; | |
| 73 | 65 |
| 74 // LayerTreeHostClient implementation. | 66 // LayerTreeHostClient implementation. |
| 75 virtual void WillBeginMainFrame(int frame_id) OVERRIDE {} | 67 virtual void WillBeginMainFrame(int frame_id) OVERRIDE {} |
| 76 virtual void DidBeginMainFrame() OVERRIDE {} | 68 virtual void DidBeginMainFrame() OVERRIDE {} |
| 77 virtual void Animate(double frame_begin_time) OVERRIDE {} | 69 virtual void Animate(double frame_begin_time) OVERRIDE {} |
| 78 virtual void Layout() OVERRIDE {} | 70 virtual void Layout() OVERRIDE {} |
| 79 virtual void ApplyScrollAndScale(gfx::Vector2d scroll_delta, | 71 virtual void ApplyScrollAndScale(gfx::Vector2d scroll_delta, |
| 80 float page_scale) OVERRIDE {} | 72 float page_scale) OVERRIDE {} |
| 81 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback) | 73 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback) |
| 82 OVERRIDE; | 74 OVERRIDE; |
| 83 virtual void DidInitializeOutputSurface(bool success) OVERRIDE {} | 75 virtual void DidInitializeOutputSurface(bool success) OVERRIDE {} |
| 84 virtual void WillCommit() OVERRIDE {} | 76 virtual void WillCommit() OVERRIDE {} |
| 85 virtual void DidCommit() OVERRIDE; | 77 virtual void DidCommit() OVERRIDE; |
| 86 virtual void DidCommitAndDrawFrame() OVERRIDE {} | 78 virtual void DidCommitAndDrawFrame() OVERRIDE {} |
| 87 virtual void DidCompleteSwapBuffers() OVERRIDE; | 79 virtual void DidCompleteSwapBuffers() OVERRIDE; |
| 88 virtual scoped_refptr<cc::ContextProvider> | 80 virtual scoped_refptr<cc::ContextProvider> |
| 89 OffscreenContextProvider() OVERRIDE; | 81 OffscreenContextProvider() OVERRIDE; |
| 90 | 82 |
| 91 // LayerTreeHostSingleThreadClient implementation. | 83 // LayerTreeHostSingleThreadClient implementation. |
| 92 virtual void ScheduleComposite() OVERRIDE; | 84 virtual void ScheduleComposite() OVERRIDE; |
| 93 virtual void ScheduleAnimation() OVERRIDE; | 85 virtual void ScheduleAnimation() OVERRIDE; |
| 94 virtual void DidPostSwapBuffers() OVERRIDE; | 86 virtual void DidPostSwapBuffers() OVERRIDE; |
| 95 virtual void DidAbortSwapBuffers() OVERRIDE; | 87 virtual void DidAbortSwapBuffers() OVERRIDE; |
| 96 | 88 |
| 97 // ImageTransportFactoryAndroidObserver implementation. | 89 // ImageTransportFactoryAndroidObserver implementation. |
| 98 virtual void OnLostResources() OVERRIDE; | 90 virtual void OnLostResources() OVERRIDE; |
| 99 | 91 |
| 92 // UIResourceClient implementation. |
| 93 virtual cc::UIResourceBitmap GetBitmap(cc::UIResourceId uid, |
| 94 bool resource_lost) OVERRIDE; |
| 95 |
| 100 private: | 96 private: |
| 101 GLuint BuildBasicTexture(); | |
| 102 GLenum GetGLFormatForBitmap(gfx::JavaBitmap& bitmap); | |
| 103 GLenum GetGLTypeForBitmap(gfx::JavaBitmap& bitmap); | |
| 104 | |
| 105 scoped_refptr<cc::Layer> root_layer_; | 97 scoped_refptr<cc::Layer> root_layer_; |
| 106 scoped_ptr<cc::LayerTreeHost> host_; | 98 scoped_ptr<cc::LayerTreeHost> host_; |
| 107 | 99 |
| 108 gfx::Size size_; | 100 gfx::Size size_; |
| 109 bool has_transparent_background_; | 101 bool has_transparent_background_; |
| 110 | 102 |
| 111 ANativeWindow* window_; | 103 ANativeWindow* window_; |
| 112 int surface_id_; | 104 int surface_id_; |
| 113 | 105 |
| 114 CompositorClient* client_; | 106 CompositorClient* client_; |
| 115 | 107 |
| 116 scoped_refptr<cc::ContextProvider> null_offscreen_context_provider_; | 108 scoped_refptr<cc::ContextProvider> null_offscreen_context_provider_; |
| 117 | 109 |
| 118 typedef base::ScopedPtrHashMap<cc::UIResourceId, cc::ScopedUIResource> | 110 typedef base::ScopedPtrHashMap<cc::UIResourceId, cc::ScopedUIResource> |
| 119 UIResourceMap; | 111 ScopedUIResourceMap; |
| 120 UIResourceMap ui_resource_map_; | 112 ScopedUIResourceMap scoped_ui_resource_map_; |
| 113 scoped_ptr<cc::UIResourceBitmap> transient_ui_bitmap_; |
| 121 | 114 |
| 122 gfx::NativeWindow root_window_; | 115 gfx::NativeWindow root_window_; |
| 123 | 116 |
| 124 DISALLOW_COPY_AND_ASSIGN(CompositorImpl); | 117 DISALLOW_COPY_AND_ASSIGN(CompositorImpl); |
| 125 }; | 118 }; |
| 126 | 119 |
| 127 } // namespace content | 120 } // namespace content |
| 128 | 121 |
| 129 #endif // CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_IMPL_ANDROID_H_ | 122 #endif // CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_IMPL_ANDROID_H_ |
| OLD | NEW |