| 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 "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "cc/output/compositor_frame.h" |
| 12 #include "cc/output/managed_memory_policy.h" | 13 #include "cc/output/managed_memory_policy.h" |
| 13 #include "cc/output/output_surface.h" | 14 #include "cc/output/output_surface.h" |
| 14 #include "content/public/browser/android/synchronous_compositor.h" | 15 #include "content/public/browser/android/synchronous_compositor.h" |
| 15 #include "ui/gfx/transform.h" | 16 #include "ui/gfx/transform.h" |
| 16 | 17 |
| 17 namespace cc { | 18 namespace cc { |
| 18 class ContextProvider; | 19 class ContextProvider; |
| 19 class CompositorFrameMetadata; | 20 class CompositorFrameMetadata; |
| 20 } | 21 } |
| 21 | 22 |
| 22 namespace content { | 23 namespace content { |
| 23 | 24 |
| 24 class SynchronousCompositorClient; | 25 class SynchronousCompositorClient; |
| 25 class SynchronousCompositorOutputSurface; | 26 class SynchronousCompositorOutputSurface; |
| 26 class WebGraphicsContext3DCommandBufferImpl; | 27 class WebGraphicsContext3DCommandBufferImpl; |
| 27 | 28 |
| 28 class SynchronousCompositorOutputSurfaceDelegate { | 29 class SynchronousCompositorOutputSurfaceDelegate { |
| 29 public: | 30 public: |
| 30 virtual void DidBindOutputSurface( | 31 virtual void DidBindOutputSurface( |
| 31 SynchronousCompositorOutputSurface* output_surface) = 0; | 32 SynchronousCompositorOutputSurface* output_surface) = 0; |
| 32 virtual void DidDestroySynchronousOutputSurface( | 33 virtual void DidDestroySynchronousOutputSurface( |
| 33 SynchronousCompositorOutputSurface* output_surface) = 0; | 34 SynchronousCompositorOutputSurface* output_surface) = 0; |
| 34 virtual void SetContinuousInvalidate(bool enable) = 0; | 35 virtual void SetContinuousInvalidate(bool enable) = 0; |
| 35 virtual void UpdateFrameMetaData( | |
| 36 const cc::CompositorFrameMetadata& frame_metadata) = 0; | |
| 37 virtual void DidActivatePendingTree() = 0; | 36 virtual void DidActivatePendingTree() = 0; |
| 38 | 37 |
| 39 protected: | 38 protected: |
| 40 SynchronousCompositorOutputSurfaceDelegate() {} | 39 SynchronousCompositorOutputSurfaceDelegate() {} |
| 41 virtual ~SynchronousCompositorOutputSurfaceDelegate() {} | 40 virtual ~SynchronousCompositorOutputSurfaceDelegate() {} |
| 42 }; | 41 }; |
| 43 | 42 |
| 44 // Specialization of the output surface that adapts it to implement the | 43 // Specialization of the output surface that adapts it to implement the |
| 45 // content::SynchronousCompositor public API. This class effects an "inversion | 44 // content::SynchronousCompositor public API. This class effects an "inversion |
| 46 // of control" - enabling drawing to be orchestrated by the embedding | 45 // of control" - enabling drawing to be orchestrated by the embedding |
| (...skipping 12 matching lines...) Expand all Loading... |
| 59 virtual bool ForcedDrawToSoftwareDevice() const OVERRIDE; | 58 virtual bool ForcedDrawToSoftwareDevice() const OVERRIDE; |
| 60 virtual bool BindToClient(cc::OutputSurfaceClient* surface_client) OVERRIDE; | 59 virtual bool BindToClient(cc::OutputSurfaceClient* surface_client) OVERRIDE; |
| 61 virtual void Reshape(const gfx::Size& size, float scale_factor) OVERRIDE; | 60 virtual void Reshape(const gfx::Size& size, float scale_factor) OVERRIDE; |
| 62 virtual void SetNeedsBeginFrame(bool enable) OVERRIDE; | 61 virtual void SetNeedsBeginFrame(bool enable) OVERRIDE; |
| 63 virtual void SwapBuffers(cc::CompositorFrame* frame) OVERRIDE; | 62 virtual void SwapBuffers(cc::CompositorFrame* frame) OVERRIDE; |
| 64 | 63 |
| 65 // Partial SynchronousCompositor API implementation. | 64 // Partial SynchronousCompositor API implementation. |
| 66 bool InitializeHwDraw( | 65 bool InitializeHwDraw( |
| 67 scoped_refptr<cc::ContextProvider> onscreen_context_provider); | 66 scoped_refptr<cc::ContextProvider> onscreen_context_provider); |
| 68 void ReleaseHwDraw(); | 67 void ReleaseHwDraw(); |
| 69 bool DemandDrawHw(gfx::Size surface_size, | 68 scoped_ptr<cc::CompositorFrame> DemandDrawHw(gfx::Size surface_size, |
| 70 const gfx::Transform& transform, | 69 const gfx::Transform& transform, |
| 71 gfx::Rect viewport, | 70 gfx::Rect viewport, |
| 72 gfx::Rect clip, | 71 gfx::Rect clip, |
| 73 bool stencil_enabled); | 72 bool stencil_enabled); |
| 74 bool DemandDrawSw(SkCanvas* canvas); | 73 void ReturnResources(const cc::CompositorFrameAck& frame_ack); |
| 74 scoped_ptr<cc::CompositorFrame> DemandDrawSw(SkCanvas* canvas); |
| 75 void SetMemoryPolicy(const SynchronousCompositorMemoryPolicy& policy); | 75 void SetMemoryPolicy(const SynchronousCompositorMemoryPolicy& policy); |
| 76 | 76 |
| 77 private: | 77 private: |
| 78 class SoftwareDevice; | 78 class SoftwareDevice; |
| 79 friend class SoftwareDevice; | 79 friend class SoftwareDevice; |
| 80 | 80 |
| 81 void InvokeComposite(const gfx::Transform& transform, | 81 void InvokeComposite(const gfx::Transform& transform, |
| 82 gfx::Rect viewport, | 82 gfx::Rect viewport, |
| 83 gfx::Rect clip, | 83 gfx::Rect clip, |
| 84 bool valid_for_tile_management); | 84 bool valid_for_tile_management); |
| 85 bool CalledOnValidThread() const; | 85 bool CalledOnValidThread() const; |
| 86 SynchronousCompositorOutputSurfaceDelegate* GetDelegate(); | 86 SynchronousCompositorOutputSurfaceDelegate* GetDelegate(); |
| 87 void UpdateFrameMetaData(const cc::CompositorFrameMetadata& frame_info); | |
| 88 | 87 |
| 89 int routing_id_; | 88 int routing_id_; |
| 90 bool needs_begin_frame_; | 89 bool needs_begin_frame_; |
| 91 bool invoking_composite_; | 90 bool invoking_composite_; |
| 92 bool did_swap_buffer_; | |
| 93 | 91 |
| 94 gfx::Transform cached_hw_transform_; | 92 gfx::Transform cached_hw_transform_; |
| 95 gfx::Rect cached_hw_viewport_; | 93 gfx::Rect cached_hw_viewport_; |
| 96 gfx::Rect cached_hw_clip_; | 94 gfx::Rect cached_hw_clip_; |
| 97 | 95 |
| 98 // Only valid (non-NULL) during a DemandDrawSw() call. | 96 // Only valid (non-NULL) during a DemandDrawSw() call. |
| 99 SkCanvas* current_sw_canvas_; | 97 SkCanvas* current_sw_canvas_; |
| 100 | 98 |
| 101 cc::ManagedMemoryPolicy memory_policy_; | 99 cc::ManagedMemoryPolicy memory_policy_; |
| 102 | 100 |
| 103 cc::OutputSurfaceClient* output_surface_client_; | 101 cc::OutputSurfaceClient* output_surface_client_; |
| 104 | 102 scoped_ptr<cc::CompositorFrame> frame_holder_; |
| 105 base::WeakPtrFactory<SynchronousCompositorOutputSurface> weak_ptr_factory_; | |
| 106 | 103 |
| 107 DISALLOW_COPY_AND_ASSIGN(SynchronousCompositorOutputSurface); | 104 DISALLOW_COPY_AND_ASSIGN(SynchronousCompositorOutputSurface); |
| 108 }; | 105 }; |
| 109 | 106 |
| 110 } // namespace content | 107 } // namespace content |
| 111 | 108 |
| 112 #endif // CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_OUTPUT_SURF
ACE_H_ | 109 #endif // CONTENT_BROWSER_ANDROID_IN_PROCESS_SYNCHRONOUS_COMPOSITOR_OUTPUT_SURF
ACE_H_ |
| OLD | NEW |