Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_SYNCHRONOUS_COMPOSITOR_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_ANDROID_SYNCHRONOUS_COMPOSITOR_H_ |
| 6 #define CONTENT_PUBLIC_BROWSER_ANDROID_SYNCHRONOUS_COMPOSITOR_H_ | 6 #define CONTENT_PUBLIC_BROWSER_ANDROID_SYNCHRONOUS_COMPOSITOR_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 | 11 |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/synchronization/waitable_event.h" | |
| 13 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 14 #include "cc/resources/returned_resource.h" | 15 #include "cc/resources/returned_resource.h" |
| 15 #include "content/common/content_export.h" | 16 #include "content/common/content_export.h" |
| 16 #include "ui/gfx/geometry/rect.h" | 17 #include "ui/gfx/geometry/rect.h" |
| 17 #include "ui/gfx/geometry/size.h" | 18 #include "ui/gfx/geometry/size.h" |
| 18 | 19 |
| 19 class SkCanvas; | 20 class SkCanvas; |
| 20 | 21 |
| 21 namespace cc { | 22 namespace cc { |
| 22 class CompositorFrame; | 23 class CompositorFrame; |
| 23 class CompositorFrameAck; | 24 class CompositorFrameAck; |
| 24 } | 25 } |
| 25 | 26 |
| 26 namespace gfx { | 27 namespace gfx { |
| 27 class Point; | 28 class Point; |
| 28 class ScrollOffset; | 29 class ScrollOffset; |
| 29 class Transform; | 30 class Transform; |
| 30 }; | 31 }; |
| 31 | 32 |
| 32 namespace content { | 33 namespace content { |
| 33 | 34 |
| 34 class SynchronousCompositorClient; | 35 class SynchronousCompositorClient; |
| 35 class WebContents; | 36 class WebContents; |
| 37 class FrameFuture; | |
|
boliu
2016/09/16 16:26:12
remove, this class does not actually exist
ojars
2016/09/19 22:02:37
Done.
| |
| 36 | 38 |
| 37 // Interface for embedders that wish to direct compositing operations | 39 // Interface for embedders that wish to direct compositing operations |
| 38 // synchronously under their own control. Only meaningful when the | 40 // synchronously under their own control. Only meaningful when the |
| 39 // kEnableSyncrhonousRendererCompositor flag is specified. | 41 // kEnableSyncrhonousRendererCompositor flag is specified. |
| 40 class CONTENT_EXPORT SynchronousCompositor { | 42 class CONTENT_EXPORT SynchronousCompositor { |
| 41 public: | 43 public: |
| 42 // Must be called once per WebContents instance. Will create the compositor | 44 // Must be called once per WebContents instance. Will create the compositor |
| 43 // instance as needed, but only if |client| is non-nullptr. | 45 // instance as needed, but only if |client| is non-nullptr. |
| 44 static void SetClientForWebContents(WebContents* contents, | 46 static void SetClientForWebContents(WebContents* contents, |
| 45 SynchronousCompositorClient* client); | 47 SynchronousCompositorClient* client); |
| 46 | 48 |
| 47 struct Frame { | 49 struct Frame { |
| 48 Frame(); | 50 Frame(); |
| 49 ~Frame(); | 51 ~Frame(); |
| 50 | 52 |
| 51 // Movable type. | 53 // Movable type. |
| 52 Frame(Frame&& rhs); | 54 Frame(Frame&& rhs); |
| 53 Frame& operator=(Frame&& rhs); | 55 Frame& operator=(Frame&& rhs); |
| 54 | 56 |
| 55 uint32_t output_surface_id; | 57 uint32_t output_surface_id; |
| 56 std::unique_ptr<cc::CompositorFrame> frame; | 58 std::unique_ptr<cc::CompositorFrame> frame; |
| 57 | 59 |
| 58 private: | 60 private: |
| 59 DISALLOW_COPY_AND_ASSIGN(Frame); | 61 DISALLOW_COPY_AND_ASSIGN(Frame); |
| 60 }; | 62 }; |
| 61 | 63 |
| 64 class FrameFuture : public base::RefCountedThreadSafe<FrameFuture> { | |
| 65 public: | |
| 66 FrameFuture(); | |
| 67 void setFrame(std::unique_ptr<SynchronousCompositor::Frame> frame); | |
| 68 SynchronousCompositor::Frame* getFrame(); | |
| 69 bool hasFrame(); | |
| 70 | |
| 71 private: | |
| 72 base::WaitableEvent waitable_event_; | |
| 73 std::unique_ptr<content::SynchronousCompositor::Frame> frame_; | |
| 74 friend class base::RefCountedThreadSafe<FrameFuture>; | |
| 75 ~FrameFuture(); | |
| 76 }; | |
| 77 | |
| 62 // "On demand" hardware draw. Parameters are used by compositor for this draw. | 78 // "On demand" hardware draw. Parameters are used by compositor for this draw. |
| 63 // |viewport_size| is the current size to improve results during resize. | 79 // |viewport_size| is the current size to improve results during resize. |
| 64 // |viewport_rect_for_tile_priority| and |transform_for_tile_priority| are | 80 // |viewport_rect_for_tile_priority| and |transform_for_tile_priority| are |
| 65 // used to customize the tiling decisions of compositor. | 81 // used to customize the tiling decisions of compositor. |
| 66 virtual Frame DemandDrawHw( | 82 // TODO(ojars): update this and the next documentation |
| 83 virtual scoped_refptr<FrameFuture> DemandDrawHw( | |
| 67 const gfx::Size& viewport_size, | 84 const gfx::Size& viewport_size, |
| 68 const gfx::Rect& viewport_rect_for_tile_priority, | 85 const gfx::Rect& viewport_rect_for_tile_priority, |
| 69 const gfx::Transform& transform_for_tile_priority) = 0; | 86 const gfx::Transform& transform_for_tile_priority) = 0; |
| 70 | 87 |
| 71 // Same as DemandDrawHw, but uses asynchronous IPC messages. Calls | 88 // Same as DemandDrawHw, but uses asynchronous IPC messages. Calls |
| 72 // SynchronousCompositorClient::OnDrawHardwareProcessFrame to return the | 89 // SynchronousCompositorClient::OnDrawHardwareProcessFrame to return the |
| 73 // frame. | 90 // frame. |
| 74 virtual void DemandDrawHwAsync( | 91 virtual scoped_refptr<FrameFuture> DemandDrawHwAsync( |
| 75 const gfx::Size& viewport_size, | 92 const gfx::Size& viewport_size, |
| 76 const gfx::Rect& viewport_rect_for_tile_priority, | 93 const gfx::Rect& viewport_rect_for_tile_priority, |
| 77 const gfx::Transform& transform_for_tile_priority) = 0; | 94 const gfx::Transform& transform_for_tile_priority) = 0; |
| 78 | 95 |
| 79 // For delegated rendering, return resources from parent compositor to this. | 96 // For delegated rendering, return resources from parent compositor to this. |
| 80 // Note that all resources must be returned before ReleaseHwDraw. | 97 // Note that all resources must be returned before ReleaseHwDraw. |
| 81 virtual void ReturnResources(uint32_t output_surface_id, | 98 virtual void ReturnResources(uint32_t output_surface_id, |
| 82 const cc::ReturnedResourceArray& resources) = 0; | 99 const cc::ReturnedResourceArray& resources) = 0; |
| 83 | 100 |
| 84 // "On demand" SW draw, into the supplied canvas (observing the transform | 101 // "On demand" SW draw, into the supplied canvas (observing the transform |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 102 // and if any input animation is active, it should tick now. | 119 // and if any input animation is active, it should tick now. |
| 103 virtual void OnComputeScroll(base::TimeTicks animation_time) = 0; | 120 virtual void OnComputeScroll(base::TimeTicks animation_time) = 0; |
| 104 | 121 |
| 105 protected: | 122 protected: |
| 106 virtual ~SynchronousCompositor() {} | 123 virtual ~SynchronousCompositor() {} |
| 107 }; | 124 }; |
| 108 | 125 |
| 109 } // namespace content | 126 } // namespace content |
| 110 | 127 |
| 111 #endif // CONTENT_PUBLIC_BROWSER_ANDROID_SYNCHRONOUS_COMPOSITOR_H_ | 128 #endif // CONTENT_PUBLIC_BROWSER_ANDROID_SYNCHRONOUS_COMPOSITOR_H_ |
| OLD | NEW |