Ignore non-active fullscreen windows for shelf state.
[chromium-blink-merge.git] / content / browser / renderer_host / compositor_impl_android.h
bloba662b1de72ec93b88217d62ca66b685c3277dc4f
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_IMPL_ANDROID_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_IMPL_ANDROID_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/containers/scoped_ptr_hash_map.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "cc/resources/ui_resource_client.h"
13 #include "cc/trees/layer_tree_host_client.h"
14 #include "cc/trees/layer_tree_host_single_thread_client.h"
15 #include "content/browser/renderer_host/image_transport_factory_android.h"
16 #include "content/common/content_export.h"
17 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
18 #include "content/public/browser/android/compositor.h"
20 struct ANativeWindow;
22 namespace cc {
23 class InputHandlerClient;
24 class Layer;
25 class LayerTreeHost;
26 class ScopedUIResource;
29 namespace content {
30 class CompositorClient;
31 class GraphicsContext;
33 // -----------------------------------------------------------------------------
34 // Browser-side compositor that manages a tree of content and UI layers.
35 // -----------------------------------------------------------------------------
36 class CONTENT_EXPORT CompositorImpl
37 : public Compositor,
38 public cc::LayerTreeHostClient,
39 public cc::LayerTreeHostSingleThreadClient,
40 public ImageTransportFactoryAndroidObserver {
41 public:
42 CompositorImpl(CompositorClient* client, gfx::NativeWindow root_window);
43 virtual ~CompositorImpl();
45 static bool IsInitialized();
47 // Returns the Java Surface object for a given view surface id.
48 static jobject GetSurface(int surface_id);
50 // Compositor implementation.
51 virtual void SetRootLayer(scoped_refptr<cc::Layer> root) OVERRIDE;
52 virtual void SetWindowSurface(ANativeWindow* window) OVERRIDE;
53 virtual void SetSurface(jobject surface) OVERRIDE;
54 virtual void SetVisible(bool visible) OVERRIDE;
55 virtual void setDeviceScaleFactor(float factor) OVERRIDE;
56 virtual void SetWindowBounds(const gfx::Size& size) OVERRIDE;
57 virtual bool CompositeAndReadback(
58 void *pixels, const gfx::Rect& rect) OVERRIDE;
59 virtual void Composite() OVERRIDE;
60 virtual cc::UIResourceId GenerateUIResource(
61 const cc::UIResourceBitmap& bitmap) OVERRIDE;
62 virtual void DeleteUIResource(cc::UIResourceId resource_id) OVERRIDE;
63 virtual blink::WebGLId GenerateTexture(gfx::JavaBitmap& bitmap) OVERRIDE;
64 virtual blink::WebGLId GenerateCompressedTexture(
65 gfx::Size& size, int data_size, void* data) OVERRIDE;
66 virtual void DeleteTexture(blink::WebGLId texture_id) OVERRIDE;
67 virtual bool CopyTextureToBitmap(blink::WebGLId texture_id,
68 gfx::JavaBitmap& bitmap) OVERRIDE;
69 virtual bool CopyTextureToBitmap(blink::WebGLId texture_id,
70 const gfx::Rect& sub_rect,
71 gfx::JavaBitmap& bitmap) OVERRIDE;
73 // LayerTreeHostClient implementation.
74 virtual void WillBeginMainFrame(int frame_id) OVERRIDE {}
75 virtual void DidBeginMainFrame() OVERRIDE {}
76 virtual void Animate(double frame_begin_time) OVERRIDE {}
77 virtual void Layout() OVERRIDE {}
78 virtual void ApplyScrollAndScale(gfx::Vector2d scroll_delta,
79 float page_scale) OVERRIDE {}
80 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback)
81 OVERRIDE;
82 virtual void DidInitializeOutputSurface(bool success) OVERRIDE {}
83 virtual void WillCommit() OVERRIDE {}
84 virtual void DidCommit() OVERRIDE;
85 virtual void DidCommitAndDrawFrame() OVERRIDE {}
86 virtual void DidCompleteSwapBuffers() OVERRIDE;
87 virtual scoped_refptr<cc::ContextProvider>
88 OffscreenContextProvider() OVERRIDE;
90 // LayerTreeHostSingleThreadClient implementation.
91 virtual void ScheduleComposite() OVERRIDE;
92 virtual void ScheduleAnimation() OVERRIDE;
93 virtual void DidPostSwapBuffers() OVERRIDE;
94 virtual void DidAbortSwapBuffers() OVERRIDE;
96 // ImageTransportFactoryAndroidObserver implementation.
97 virtual void OnLostResources() OVERRIDE;
99 private:
100 blink::WebGLId BuildBasicTexture();
101 blink::WGC3Denum GetGLFormatForBitmap(gfx::JavaBitmap& bitmap);
102 blink::WGC3Denum GetGLTypeForBitmap(gfx::JavaBitmap& bitmap);
104 scoped_refptr<cc::Layer> root_layer_;
105 scoped_ptr<cc::LayerTreeHost> host_;
107 gfx::Size size_;
108 bool has_transparent_background_;
110 ANativeWindow* window_;
111 int surface_id_;
113 CompositorClient* client_;
115 scoped_refptr<cc::ContextProvider> null_offscreen_context_provider_;
117 typedef base::ScopedPtrHashMap<cc::UIResourceId, cc::ScopedUIResource>
118 UIResourceMap;
119 UIResourceMap ui_resource_map_;
121 gfx::NativeWindow root_window_;
123 DISALLOW_COPY_AND_ASSIGN(CompositorImpl);
126 } // namespace content
128 #endif // CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_IMPL_ANDROID_H_