Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / content / public / browser / android / compositor.h
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.
4
5 #ifndef CONTENT_PUBLIC_BROWSER_ANDROID_COMPOSITOR_H_
6 #define CONTENT_PUBLIC_BROWSER_ANDROID_COMPOSITOR_H_
7
8 #include "base/callback.h"
9 #include "cc/resources/ui_resource_bitmap.h"
10 #include "content/common/content_export.h"
11 #include "content/public/browser/android/ui_resource_provider.h"
12 #include "ui/gfx/native_widget_types.h"
13 #include "ui/gfx/rect.h"
14 #include "ui/gfx/size.h"
15
16 class SkBitmap;
17
18 namespace cc {
19 class Layer;
20 }
21
22 namespace gfx {
23 class JavaBitmap;
24 }
25
26 namespace content {
27 class CompositorClient;
28 class UIResourceProvider;
29
30 // An interface to the browser-side compositor.
31 class CONTENT_EXPORT Compositor {
32  public:
33   virtual ~Compositor() {}
34
35   // Performs the global initialization needed before any compositor
36   // instance can be used. This should be called only once.
37   static void Initialize();
38
39   // Creates and returns a compositor instance.  |root_window| needs to outlive
40   // the compositor as it manages callbacks on the compositor.
41   static Compositor* Create(CompositorClient* client,
42                             gfx::NativeWindow root_window);
43
44   // Attaches the layer tree.
45   virtual void SetRootLayer(scoped_refptr<cc::Layer> root) = 0;
46
47   // Set the scale factor from DIP to pixel.
48   virtual void setDeviceScaleFactor(float factor) = 0;
49
50   // Set the output surface bounds.
51   virtual void SetWindowBounds(const gfx::Size& size) = 0;
52
53   // Sets the window visibility. When becoming invisible, resources will get
54   // freed and other calls into the compositor are not allowed until after
55   // having been made visible again.
56   virtual void SetVisible(bool visible) = 0;
57
58   // Set the output surface which the compositor renders into.
59   virtual void SetSurface(jobject surface) = 0;
60
61   // Tells the view tree to assume a transparent background when rendering.
62   virtual void SetHasTransparentBackground(bool flag) = 0;
63
64   // Request layout and draw. You only need to call this if you need to trigger
65   // Composite *without* having modified the layer tree.
66   virtual void SetNeedsComposite() = 0;
67
68   // Returns the UI resource provider associated with the compositor.
69   virtual UIResourceProvider& GetUIResourceProvider() = 0;
70
71  protected:
72   Compositor() {}
73 };
74
75 }  // namespace content
76
77 #endif  // CONTENT_PUBLIC_BROWSER_ANDROID_COMPOSITOR_H_