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 "ui/android/resources/ui_resource_provider.h"
12 #include "ui/gfx/geometry/rect.h"
13 #include "ui/gfx/geometry/size.h"
14 #include "ui/gfx/native_widget_types.h"
27 class ResourceManager
;
28 class UIResourceProvider
;
32 class CompositorClient
;
34 // An interface to the browser-side compositor.
35 class CONTENT_EXPORT Compositor
{
37 virtual ~Compositor() {}
39 // Performs the global initialization needed before any compositor
40 // instance can be used. This should be called only once.
41 static void Initialize();
43 // Creates and returns a compositor instance. |root_window| needs to outlive
44 // the compositor as it manages callbacks on the compositor.
45 static Compositor
* Create(CompositorClient
* client
,
46 gfx::NativeWindow root_window
);
48 // Attaches the layer tree.
49 virtual void SetRootLayer(scoped_refptr
<cc::Layer
> root
) = 0;
51 // Set the scale factor from DIP to pixel.
52 virtual void setDeviceScaleFactor(float factor
) = 0;
54 // Set the output surface bounds.
55 virtual void SetWindowBounds(const gfx::Size
& size
) = 0;
57 // Set the output surface which the compositor renders into.
58 virtual void SetSurface(jobject surface
) = 0;
60 // Tells the view tree to assume a transparent background when rendering.
61 virtual void SetHasTransparentBackground(bool flag
) = 0;
63 // Request layout and draw. You only need to call this if you need to trigger
64 // Composite *without* having modified the layer tree.
65 virtual void SetNeedsComposite() = 0;
67 // Returns the UI resource provider associated with the compositor.
68 virtual ui::UIResourceProvider
& GetUIResourceProvider() = 0;
70 // Returns the resource manager associated with the compositor.
71 virtual ui::ResourceManager
& GetResourceManager() = 0;
77 } // namespace content
79 #endif // CONTENT_PUBLIC_BROWSER_ANDROID_COMPOSITOR_H_