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_PUBLIC_BROWSER_ANDROID_COMPOSITOR_H_
6 #define CONTENT_PUBLIC_BROWSER_ANDROID_COMPOSITOR_H_
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"
27 class CompositorClient;
28 class UIResourceProvider;
30 // An interface to the browser-side compositor.
31 class CONTENT_EXPORT Compositor {
33 virtual ~Compositor() {}
35 // Performs the global initialization needed before any compositor
36 // instance can be used. This should be called only once.
37 static void Initialize();
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);
44 // Attaches the layer tree.
45 virtual void SetRootLayer(scoped_refptr<cc::Layer> root) = 0;
47 // Set the scale factor from DIP to pixel.
48 virtual void setDeviceScaleFactor(float factor) = 0;
50 // Set the output surface bounds.
51 virtual void SetWindowBounds(const gfx::Size& size) = 0;
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;
58 // Set the output surface which the compositor renders into.
59 virtual void SetSurface(jobject surface) = 0;
61 // Tells the view tree to assume a transparent background when rendering.
62 virtual void SetHasTransparentBackground(bool flag) = 0;
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;
68 // Returns the UI resource provider associated with the compositor.
69 virtual UIResourceProvider& GetUIResourceProvider() = 0;
75 } // namespace content
77 #endif // CONTENT_PUBLIC_BROWSER_ANDROID_COMPOSITOR_H_