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/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "cc/layer_tree_host_client.h" |
12 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
13 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" | 14 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
14 #include "content/public/browser/android/compositor.h" | 15 #include "content/public/browser/android/compositor.h" |
15 #include "third_party/WebKit/Source/Platform/chromium/public/WebLayer.h" | |
16 #include "third_party/WebKit/Source/Platform/chromium/public/WebLayerTreeView.h" | |
17 #include "third_party/WebKit/Source/Platform/chromium/public/WebLayerTreeViewCli
ent.h" | |
18 | 16 |
19 struct ANativeWindow; | 17 struct ANativeWindow; |
20 | 18 |
21 namespace webkit { | 19 namespace cc { |
22 class WebCompositorSupportImpl; | 20 class InputHandler; |
| 21 class Layer; |
| 22 class LayerTreeHost; |
23 } | 23 } |
24 | 24 |
25 namespace content { | 25 namespace content { |
26 class GraphicsContext; | 26 class GraphicsContext; |
27 | 27 |
28 // ----------------------------------------------------------------------------- | 28 // ----------------------------------------------------------------------------- |
29 // Browser-side compositor that manages a tree of content and UI layers. | 29 // Browser-side compositor that manages a tree of content and UI layers. |
30 // ----------------------------------------------------------------------------- | 30 // ----------------------------------------------------------------------------- |
31 class CONTENT_EXPORT CompositorImpl | 31 class CONTENT_EXPORT CompositorImpl |
32 : public Compositor, | 32 : public Compositor, |
33 public WebKit::WebLayerTreeViewClient, | 33 public cc::LayerTreeHostClient, |
34 public WebGraphicsContext3DSwapBuffersClient { | 34 public WebGraphicsContext3DSwapBuffersClient { |
35 public: | 35 public: |
36 explicit CompositorImpl(Compositor::Client* client); | 36 explicit CompositorImpl(Compositor::Client* client); |
37 virtual ~CompositorImpl(); | 37 virtual ~CompositorImpl(); |
38 | 38 |
39 static webkit::WebCompositorSupportImpl* CompositorSupport(); | |
40 static bool IsInitialized(); | 39 static bool IsInitialized(); |
| 40 static bool IsThreadingEnabled(); |
41 | 41 |
42 // Returns true if initialized with DIRECT_CONTEXT_ON_DRAW_THREAD. | 42 // Returns true if initialized with DIRECT_CONTEXT_ON_DRAW_THREAD. |
43 static bool UsesDirectGL(); | 43 static bool UsesDirectGL(); |
44 | 44 |
45 // Compositor implementation. | 45 // Compositor implementation. |
46 virtual void SetRootLayer(WebKit::WebLayer* root) OVERRIDE; | 46 virtual void SetRootLayer(scoped_refptr<cc::Layer> root) OVERRIDE; |
47 virtual void SetWindowSurface(ANativeWindow* window) OVERRIDE; | 47 virtual void SetWindowSurface(ANativeWindow* window) OVERRIDE; |
48 virtual void SetVisible(bool visible) OVERRIDE; | 48 virtual void SetVisible(bool visible) OVERRIDE; |
49 virtual void SetWindowBounds(const gfx::Size& size) OVERRIDE; | 49 virtual void SetWindowBounds(const gfx::Size& size) OVERRIDE; |
50 virtual bool CompositeAndReadback( | 50 virtual bool CompositeAndReadback( |
51 void *pixels, const gfx::Rect& rect) OVERRIDE; | 51 void *pixels, const gfx::Rect& rect) OVERRIDE; |
52 virtual void Composite() OVERRIDE; | 52 virtual void Composite() OVERRIDE; |
53 virtual WebKit::WebGLId GenerateTexture(gfx::JavaBitmap& bitmap) OVERRIDE; | 53 virtual WebKit::WebGLId GenerateTexture(gfx::JavaBitmap& bitmap) OVERRIDE; |
54 virtual WebKit::WebGLId GenerateCompressedTexture( | 54 virtual WebKit::WebGLId GenerateCompressedTexture( |
55 gfx::Size& size, int data_size, void* data) OVERRIDE; | 55 gfx::Size& size, int data_size, void* data) OVERRIDE; |
56 virtual void DeleteTexture(WebKit::WebGLId texture_id) OVERRIDE; | 56 virtual void DeleteTexture(WebKit::WebGLId texture_id) OVERRIDE; |
57 virtual void CopyTextureToBitmap(WebKit::WebGLId texture_id, | 57 virtual void CopyTextureToBitmap(WebKit::WebGLId texture_id, |
58 gfx::JavaBitmap& bitmap) OVERRIDE; | 58 gfx::JavaBitmap& bitmap) OVERRIDE; |
59 | 59 |
60 // WebLayerTreeViewClient implementation. | 60 // LayerTreeHostClient implementation. |
61 virtual void updateAnimations(double frameBeginTime) OVERRIDE; | 61 virtual void willBeginFrame() OVERRIDE {} |
| 62 virtual void didBeginFrame() OVERRIDE {} |
| 63 virtual void animate(double monotonicFrameBeginTime) OVERRIDE; |
62 virtual void layout() OVERRIDE; | 64 virtual void layout() OVERRIDE; |
63 virtual void applyScrollAndScale(const WebKit::WebSize& scrollDelta, | 65 virtual void applyScrollAndScale(gfx::Vector2d scrollDelta, |
64 float scaleFactor) OVERRIDE; | 66 float pageScale) OVERRIDE; |
65 virtual WebKit::WebCompositorOutputSurface* createOutputSurface() OVERRIDE; | 67 virtual scoped_ptr<WebKit::WebCompositorOutputSurface> createOutputSurface() |
| 68 OVERRIDE; |
| 69 virtual scoped_ptr<cc::InputHandler> createInputHandler() OVERRIDE; |
66 virtual void didRecreateOutputSurface(bool success) OVERRIDE; | 70 virtual void didRecreateOutputSurface(bool success) OVERRIDE; |
| 71 virtual void willCommit() OVERRIDE {} |
67 virtual void didCommit() OVERRIDE; | 72 virtual void didCommit() OVERRIDE; |
68 virtual void didCommitAndDrawFrame() OVERRIDE; | 73 virtual void didCommitAndDrawFrame() OVERRIDE; |
69 virtual void didCompleteSwapBuffers() OVERRIDE; | 74 virtual void didCompleteSwapBuffers() OVERRIDE; |
70 virtual void scheduleComposite() OVERRIDE; | 75 virtual void scheduleComposite() OVERRIDE; |
71 | 76 |
| 77 |
72 // WebGraphicsContext3DSwapBuffersClient implementation. | 78 // WebGraphicsContext3DSwapBuffersClient implementation. |
73 virtual void OnViewContextSwapBuffersPosted() OVERRIDE; | 79 virtual void OnViewContextSwapBuffersPosted() OVERRIDE; |
74 virtual void OnViewContextSwapBuffersComplete() OVERRIDE; | 80 virtual void OnViewContextSwapBuffersComplete() OVERRIDE; |
75 virtual void OnViewContextSwapBuffersAborted() OVERRIDE; | 81 virtual void OnViewContextSwapBuffersAborted() OVERRIDE; |
76 | 82 |
77 private: | 83 private: |
78 WebKit::WebGLId BuildBasicTexture(); | 84 WebKit::WebGLId BuildBasicTexture(); |
79 WebKit::WGC3Denum GetGLFormatForBitmap(gfx::JavaBitmap& bitmap); | 85 WebKit::WGC3Denum GetGLFormatForBitmap(gfx::JavaBitmap& bitmap); |
80 WebKit::WGC3Denum GetGLTypeForBitmap(gfx::JavaBitmap& bitmap); | 86 WebKit::WGC3Denum GetGLTypeForBitmap(gfx::JavaBitmap& bitmap); |
81 | 87 |
82 scoped_ptr<WebKit::WebLayer> root_layer_; | 88 scoped_refptr<cc::Layer> root_layer_; |
83 scoped_ptr<WebKit::WebLayerTreeView> host_; | 89 scoped_ptr<cc::LayerTreeHost> host_; |
84 | 90 |
85 gfx::Size size_; | 91 gfx::Size size_; |
86 | 92 |
87 ANativeWindow* window_; | 93 ANativeWindow* window_; |
88 int surface_id_; | 94 int surface_id_; |
89 | 95 |
90 Compositor::Client* client_; | 96 Compositor::Client* client_; |
91 base::WeakPtrFactory<CompositorImpl> weak_factory_; | 97 base::WeakPtrFactory<CompositorImpl> weak_factory_; |
92 | 98 |
93 DISALLOW_COPY_AND_ASSIGN(CompositorImpl); | 99 DISALLOW_COPY_AND_ASSIGN(CompositorImpl); |
94 }; | 100 }; |
95 | 101 |
96 } // namespace content | 102 } // namespace content |
97 | 103 |
98 #endif // CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_IMPL_ANDROID_H_ | 104 #endif // CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_IMPL_ANDROID_H_ |
OLD | NEW |