| 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_PUBLIC_BROWSER_ANDROID_COMPOSITOR_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_ANDROID_COMPOSITOR_H_ |
| 6 #define CONTENT_PUBLIC_BROWSER_ANDROID_COMPOSITOR_H_ | 6 #define CONTENT_PUBLIC_BROWSER_ANDROID_COMPOSITOR_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "ui/gfx/native_widget_types.h" | 9 #include "ui/gfx/native_widget_types.h" |
| 10 #include "ui/gfx/rect.h" | 10 #include "ui/gfx/rect.h" |
| 11 #include "ui/gfx/size.h" | 11 #include "ui/gfx/size.h" |
| 12 | 12 |
| 13 namespace WebKit { | 13 namespace WebKit { |
| 14 class WebLayer; | 14 class WebLayer; |
| 15 } | 15 } |
| 16 | 16 |
| 17 namespace content { | 17 namespace content { |
| 18 | 18 |
| 19 // An interface to the browser-side compositor. | 19 // An interface to the browser-side compositor. |
| 20 class Compositor { | 20 class Compositor { |
| 21 public: | 21 public: |
| 22 class Client { |
| 23 public: |
| 24 // Tells the client that it should schedule a composite. |
| 25 virtual void ScheduleComposite() = 0; |
| 26 }; |
| 27 |
| 22 virtual ~Compositor() {} | 28 virtual ~Compositor() {} |
| 23 | 29 |
| 24 // Performs the global initialization needed before any compositor | 30 // Performs the global initialization needed before any compositor |
| 25 // instance can be used. | 31 // instance can be used. |
| 26 static void Initialize(); | 32 static void Initialize(); |
| 27 | 33 |
| 28 // Creates and returns a compositor instance. | 34 // Creates and returns a compositor instance. |
| 29 static Compositor* Create(); | 35 static Compositor* Create(Client* client); |
| 30 | 36 |
| 31 // Attaches the layer tree. | 37 // Attaches the layer tree. |
| 32 virtual void SetRootLayer(WebKit::WebLayer* root) = 0; | 38 virtual void SetRootLayer(WebKit::WebLayer* root) = 0; |
| 33 | 39 |
| 34 // Set the output surface bounds. | 40 // Set the output surface bounds. |
| 35 virtual void SetWindowBounds(const gfx::Size& size) = 0; | 41 virtual void SetWindowBounds(const gfx::Size& size) = 0; |
| 36 | 42 |
| 37 // Set the output surface handle which the compositor renders into. | 43 // Set the output surface handle which the compositor renders into. |
| 38 virtual void SetWindowSurface(ANativeWindow* window) = 0; | 44 virtual void SetWindowSurface(ANativeWindow* window) = 0; |
| 39 | 45 |
| 40 // Attempts to composite and read back the result into the provided buffer. | 46 // Attempts to composite and read back the result into the provided buffer. |
| 41 // The buffer must be at least window width * height * 4 (RGBA) bytes large. | 47 // The buffer must be at least window width * height * 4 (RGBA) bytes large. |
| 42 // The buffer is not modified if false is returned. | 48 // The buffer is not modified if false is returned. |
| 43 virtual bool CompositeAndReadback(void *pixels, const gfx::Rect& rect) = 0; | 49 virtual bool CompositeAndReadback(void *pixels, const gfx::Rect& rect) = 0; |
| 44 | 50 |
| 45 // Callback to be run after the frame has been drawn. It passes back | 51 // Composite immediately. Used in single-threaded mode. |
| 46 // a synchronization point identifier. | 52 virtual void Composite() = 0; |
| 47 typedef base::Callback<void(uint32)> SurfacePresentedCallback; | |
| 48 | |
| 49 virtual void OnSurfaceUpdated(const SurfacePresentedCallback& callback) = 0; | |
| 50 | 53 |
| 51 protected: | 54 protected: |
| 52 Compositor() {} | 55 Compositor() {} |
| 53 }; | 56 }; |
| 54 | 57 |
| 55 } // namespace content | 58 } // namespace content |
| 56 | 59 |
| 57 #endif // CONTENT_PUBLIC_BROWSER_ANDROID_COMPOSITOR_H_ | 60 #endif // CONTENT_PUBLIC_BROWSER_ANDROID_COMPOSITOR_H_ |
| OLD | NEW |