| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_RENDERER_ANDROID_SYNCHRONOUS_COMPOSITOR_OUTPUT_SURFACE_H_ | 5 #ifndef CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_OUTPUT_SURFACE
_H_ |
| 6 #define CONTENT_RENDERER_ANDOIRD_SYNCHRONOUS_COMPOSITOR_OUTPUT_SURFACE_H_ | 6 #define CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_OUTPUT_SURFACE
_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "cc/output/output_surface.h" | 11 #include "cc/output/output_surface.h" |
| 12 #include "content/public/renderer/android/synchronous_compositor.h" | 12 #include "content/public/renderer/android/synchronous_compositor.h" |
| 13 | 13 |
| 14 namespace content { | 14 namespace content { |
| 15 | 15 |
| 16 class SynchronousCompositorClient; | 16 class SynchronousCompositorClient; |
| 17 class SynchronousCompositorOutputSurface; |
| 17 class WebGraphicsContext3DCommandBufferImpl; | 18 class WebGraphicsContext3DCommandBufferImpl; |
| 18 | 19 |
| 20 class SynchronousCompositorOutputSurfaceDelegate { |
| 21 public: |
| 22 virtual void DidBindOutputSurface( |
| 23 SynchronousCompositorOutputSurface* output_surface) = 0; |
| 24 virtual void DidDestroySynchronousOutputSurface( |
| 25 SynchronousCompositorOutputSurface* output_surface) = 0; |
| 26 virtual void SetContinuousInvalidate(bool enable) = 0; |
| 27 |
| 28 protected: |
| 29 SynchronousCompositorOutputSurfaceDelegate() {} |
| 30 virtual ~SynchronousCompositorOutputSurfaceDelegate() {} |
| 31 }; |
| 32 |
| 19 // Specialization of the output surface that adapts it to implement the | 33 // Specialization of the output surface that adapts it to implement the |
| 20 // content::SynchronousCompositor public API. This class effects an "inversion | 34 // content::SynchronousCompositor public API. This class effects an "inversion |
| 21 // of control" - enabling drawing to be orchestrated by the embedding | 35 // of control" - enabling drawing to be orchestrated by the embedding |
| 22 // layer, instead of driven by the compositor internals - hence it holds two | 36 // layer, instead of driven by the compositor internals - hence it holds two |
| 23 // 'client' pointers (including |client_| in the OutputSurface baseclass) which | 37 // 'client' pointers (|client_| in the OutputSurface baseclass and |
| 24 // represent the consumers of the two roles in plays. | 38 // GetDelegate()) which represent the consumers of the two roles in plays. |
| 25 // This class can be created only on the main thread, but then becomes pinned | 39 // This class can be created only on the main thread, but then becomes pinned |
| 26 // to a fixed thread when BindToClient is called. | 40 // to a fixed thread when BindToClient is called. |
| 27 class SynchronousCompositorOutputSurface | 41 class SynchronousCompositorOutputSurface |
| 28 : NON_EXPORTED_BASE(public cc::OutputSurface), | 42 : NON_EXPORTED_BASE(public cc::OutputSurface) { |
| 29 NON_EXPORTED_BASE(public SynchronousCompositor) { | |
| 30 public: | 43 public: |
| 31 explicit SynchronousCompositorOutputSurface(int32 routing_id); | 44 explicit SynchronousCompositorOutputSurface(int routing_id); |
| 32 virtual ~SynchronousCompositorOutputSurface(); | 45 virtual ~SynchronousCompositorOutputSurface(); |
| 33 | 46 |
| 34 // OutputSurface. | 47 // OutputSurface. |
| 35 virtual bool ForcedDrawToSoftwareDevice() const OVERRIDE; | 48 virtual bool ForcedDrawToSoftwareDevice() const OVERRIDE; |
| 36 virtual bool BindToClient(cc::OutputSurfaceClient* surface_client) OVERRIDE; | 49 virtual bool BindToClient(cc::OutputSurfaceClient* surface_client) OVERRIDE; |
| 37 virtual void Reshape(gfx::Size size, float scale_factor) OVERRIDE; | 50 virtual void Reshape(gfx::Size size, float scale_factor) OVERRIDE; |
| 38 virtual void SendFrameToParentCompositor(cc::CompositorFrame* frame) OVERRIDE; | 51 virtual void SendFrameToParentCompositor(cc::CompositorFrame* frame) OVERRIDE; |
| 39 virtual void SetNeedsBeginFrame(bool enable) OVERRIDE; | 52 virtual void SetNeedsBeginFrame(bool enable) OVERRIDE; |
| 40 virtual void SwapBuffers(const ui::LatencyInfo& info) OVERRIDE; | 53 virtual void SwapBuffers(const ui::LatencyInfo& info) OVERRIDE; |
| 41 | 54 |
| 42 // SynchronousCompositor. | 55 // Partial SynchronousCompositor API implementation. |
| 43 virtual void SetClient(SynchronousCompositorClient* compositor_client) | 56 bool IsHwReady(); |
| 44 OVERRIDE; | 57 bool DemandDrawSw(SkCanvas* canvas); |
| 45 virtual bool IsHwReady() OVERRIDE; | 58 bool DemandDrawHw(gfx::Size view_size, |
| 46 virtual bool DemandDrawSw(SkCanvas* canvas) OVERRIDE; | 59 const gfx::Transform& transform, |
| 47 virtual bool DemandDrawHw( | 60 gfx::Rect clip); |
| 48 gfx::Size view_size, | |
| 49 const gfx::Transform& transform, | |
| 50 gfx::Rect clip) OVERRIDE; | |
| 51 | 61 |
| 52 private: | 62 private: |
| 53 class SoftwareDevice; | 63 class SoftwareDevice; |
| 54 friend class SoftwareDevice; | 64 friend class SoftwareDevice; |
| 55 | 65 |
| 56 void InvokeComposite(const gfx::Transform& transform, gfx::Rect damage_area); | 66 void InvokeComposite(const gfx::Transform& transform, gfx::Rect damage_area); |
| 57 void UpdateCompositorClientSettings(); | 67 void UpdateCompositorClientSettings(); |
| 58 void NotifyCompositorSettingsChanged(); | 68 void NotifyCompositorSettingsChanged(); |
| 59 bool CalledOnValidThread() const; | 69 bool CalledOnValidThread() const; |
| 70 SynchronousCompositorOutputSurfaceDelegate* GetDelegate(); |
| 60 | 71 |
| 61 SynchronousCompositorClient* compositor_client_; | |
| 62 int routing_id_; | 72 int routing_id_; |
| 63 bool needs_begin_frame_; | 73 bool needs_begin_frame_; |
| 64 bool did_swap_buffer_; | 74 bool did_swap_buffer_; |
| 65 | 75 |
| 66 // Only valid (non-NULL) during a DemandDrawSw() call. | 76 // Only valid (non-NULL) during a DemandDrawSw() call. |
| 67 SkCanvas* current_sw_canvas_; | 77 SkCanvas* current_sw_canvas_; |
| 68 | 78 |
| 69 DISALLOW_COPY_AND_ASSIGN(SynchronousCompositorOutputSurface); | 79 DISALLOW_COPY_AND_ASSIGN(SynchronousCompositorOutputSurface); |
| 70 }; | 80 }; |
| 71 | 81 |
| 72 } // namespace content | 82 } // namespace content |
| 73 | 83 |
| 74 #endif // CONTENT_RENDERER_ANDROID_SYNCHRONOUS_COMPOSITOR_OUTPUT_SURFACE_H_ | 84 #endif // CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_OUTPUT_SURF
ACE_H_ |
| OLD | NEW |