| 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_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_OUTPUT_SURFACE
_H_ | 5 #ifndef CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_OUTPUT_SURFACE
_H_ |
| 6 #define CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_OUTPUT_SURFACE
_H_ | 6 #define CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_OUTPUT_SURFACE
_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 } | 25 } |
| 26 | 26 |
| 27 namespace IPC { | 27 namespace IPC { |
| 28 class Message; | 28 class Message; |
| 29 } | 29 } |
| 30 | 30 |
| 31 namespace content { | 31 namespace content { |
| 32 | 32 |
| 33 class FrameSwapMessageQueue; | 33 class FrameSwapMessageQueue; |
| 34 class SynchronousCompositorClient; | 34 class SynchronousCompositorClient; |
| 35 class SynchronousCompositorExternalBeginFrameSource; | |
| 36 class SynchronousCompositorOutputSurface; | 35 class SynchronousCompositorOutputSurface; |
| 37 class WebGraphicsContext3DCommandBufferImpl; | 36 class WebGraphicsContext3DCommandBufferImpl; |
| 38 | 37 |
| 39 // Specialization of the output surface that adapts it to implement the | 38 // Specialization of the output surface that adapts it to implement the |
| 40 // content::SynchronousCompositor public API. This class effects an "inversion | 39 // content::SynchronousCompositor public API. This class effects an "inversion |
| 41 // of control" - enabling drawing to be orchestrated by the embedding | 40 // of control" - enabling drawing to be orchestrated by the embedding |
| 42 // layer, instead of driven by the compositor internals - hence it holds two | 41 // layer, instead of driven by the compositor internals - hence it holds two |
| 43 // 'client' pointers (|client_| in the OutputSurface baseclass and | 42 // 'client' pointers (|client_| in the OutputSurface baseclass and |
| 44 // |delegate_|) which represent the consumers of the two roles in plays. | 43 // |delegate_|) which represent the consumers of the two roles in plays. |
| 45 // This class can be created only on the main thread, but then becomes pinned | 44 // This class can be created only on the main thread, but then becomes pinned |
| 46 // to a fixed thread when BindToClient is called. | 45 // to a fixed thread when BindToClient is called. |
| 47 class SynchronousCompositorOutputSurface | 46 class SynchronousCompositorOutputSurface |
| 48 : NON_EXPORTED_BASE(public cc::OutputSurface) { | 47 : NON_EXPORTED_BASE(public cc::OutputSurface) { |
| 49 public: | 48 public: |
| 50 explicit SynchronousCompositorOutputSurface( | 49 explicit SynchronousCompositorOutputSurface( |
| 51 int routing_id, | 50 int routing_id, |
| 52 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue); | 51 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue); |
| 53 virtual ~SynchronousCompositorOutputSurface(); | 52 virtual ~SynchronousCompositorOutputSurface(); |
| 54 | 53 |
| 55 // OutputSurface. | 54 // OutputSurface. |
| 56 virtual bool BindToClient(cc::OutputSurfaceClient* surface_client) override; | 55 virtual bool BindToClient(cc::OutputSurfaceClient* surface_client) override; |
| 57 virtual void Reshape(const gfx::Size& size, float scale_factor) override; | 56 virtual void Reshape(const gfx::Size& size, float scale_factor) override; |
| 58 virtual void SwapBuffers(cc::CompositorFrame* frame) override; | 57 virtual void SwapBuffers(cc::CompositorFrame* frame) override; |
| 59 | 58 virtual void Invalidate() override; |
| 60 void SetBeginFrameSource( | |
| 61 SynchronousCompositorExternalBeginFrameSource* begin_frame_source); | |
| 62 | 59 |
| 63 // Partial SynchronousCompositor API implementation. | 60 // Partial SynchronousCompositor API implementation. |
| 64 bool InitializeHwDraw( | 61 bool InitializeHwDraw( |
| 65 scoped_refptr<cc::ContextProvider> onscreen_context_provider); | 62 scoped_refptr<cc::ContextProvider> onscreen_context_provider); |
| 66 void ReleaseHwDraw(); | 63 void ReleaseHwDraw(); |
| 67 scoped_ptr<cc::CompositorFrame> DemandDrawHw( | 64 scoped_ptr<cc::CompositorFrame> DemandDrawHw( |
| 68 gfx::Size surface_size, | 65 gfx::Size surface_size, |
| 69 const gfx::Transform& transform, | 66 const gfx::Transform& transform, |
| 70 gfx::Rect viewport, | 67 gfx::Rect viewport, |
| 71 gfx::Rect clip, | 68 gfx::Rect clip, |
| 72 gfx::Rect viewport_rect_for_tile_priority, | 69 gfx::Rect viewport_rect_for_tile_priority, |
| 73 const gfx::Transform& transform_for_tile_priority); | 70 const gfx::Transform& transform_for_tile_priority); |
| 74 void ReturnResources(const cc::CompositorFrameAck& frame_ack); | 71 void ReturnResources(const cc::CompositorFrameAck& frame_ack); |
| 75 scoped_ptr<cc::CompositorFrame> DemandDrawSw(SkCanvas* canvas); | 72 scoped_ptr<cc::CompositorFrame> DemandDrawSw(SkCanvas* canvas); |
| 76 void SetMemoryPolicy(size_t bytes_limit); | 73 void SetMemoryPolicy(size_t bytes_limit); |
| 74 void SetInvalidateCallback(const base::Closure& callback); |
| 77 void SetTreeActivationCallback(const base::Closure& callback); | 75 void SetTreeActivationCallback(const base::Closure& callback); |
| 78 void GetMessagesToDeliver(ScopedVector<IPC::Message>* messages); | 76 void GetMessagesToDeliver(ScopedVector<IPC::Message>* messages); |
| 79 | 77 |
| 80 private: | 78 private: |
| 81 class SoftwareDevice; | 79 class SoftwareDevice; |
| 82 friend class SoftwareDevice; | 80 friend class SoftwareDevice; |
| 83 | 81 |
| 84 void InvokeComposite(const gfx::Transform& transform, | 82 void InvokeComposite(const gfx::Transform& transform, |
| 85 gfx::Rect viewport, | 83 gfx::Rect viewport, |
| 86 gfx::Rect clip, | 84 gfx::Rect clip, |
| 87 gfx::Rect viewport_rect_for_tile_priority, | 85 gfx::Rect viewport_rect_for_tile_priority, |
| 88 gfx::Transform transform_for_tile_priority, | 86 gfx::Transform transform_for_tile_priority, |
| 89 bool hardware_draw); | 87 bool hardware_draw); |
| 90 bool CalledOnValidThread() const; | 88 bool CalledOnValidThread() const; |
| 91 | 89 |
| 92 const int routing_id_; | 90 const int routing_id_; |
| 93 bool registered_; | 91 bool registered_; |
| 94 | 92 |
| 95 gfx::Transform cached_hw_transform_; | 93 gfx::Transform cached_hw_transform_; |
| 96 gfx::Rect cached_hw_viewport_; | 94 gfx::Rect cached_hw_viewport_; |
| 97 gfx::Rect cached_hw_clip_; | 95 gfx::Rect cached_hw_clip_; |
| 98 gfx::Rect cached_hw_viewport_rect_for_tile_priority_; | 96 gfx::Rect cached_hw_viewport_rect_for_tile_priority_; |
| 99 gfx::Transform cached_hw_transform_for_tile_priority_; | 97 gfx::Transform cached_hw_transform_for_tile_priority_; |
| 100 | 98 |
| 101 // Only valid (non-NULL) during a DemandDrawSw() call. | 99 // Only valid (non-NULL) during a DemandDrawSw() call. |
| 102 SkCanvas* current_sw_canvas_; | 100 SkCanvas* current_sw_canvas_; |
| 103 | 101 |
| 104 cc::ManagedMemoryPolicy memory_policy_; | 102 cc::ManagedMemoryPolicy memory_policy_; |
| 105 | 103 |
| 106 cc::OutputSurfaceClient* output_surface_client_; | |
| 107 scoped_ptr<cc::CompositorFrame> frame_holder_; | 104 scoped_ptr<cc::CompositorFrame> frame_holder_; |
| 108 | 105 |
| 109 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue_; | 106 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue_; |
| 110 | 107 |
| 111 SynchronousCompositorExternalBeginFrameSource* begin_frame_source_; | 108 base::Closure invalidate_callback_; |
| 112 | 109 |
| 113 DISALLOW_COPY_AND_ASSIGN(SynchronousCompositorOutputSurface); | 110 DISALLOW_COPY_AND_ASSIGN(SynchronousCompositorOutputSurface); |
| 114 }; | 111 }; |
| 115 | 112 |
| 116 } // namespace content | 113 } // namespace content |
| 117 | 114 |
| 118 #endif // CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_OUTPUT_SURF
ACE_H_ | 115 #endif // CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_OUTPUT_SURF
ACE_H_ |
| OLD | NEW |