| 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_RENDERER_GPU_COMPOSITOR_OUTPUT_SURFACE_H_ | 5 #ifndef CONTENT_RENDERER_GPU_COMPOSITOR_OUTPUT_SURFACE_H_ |
| 6 #define CONTENT_RENDERER_GPU_COMPOSITOR_OUTPUT_SURFACE_H_ | 6 #define CONTENT_RENDERER_GPU_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 "base/threading/non_thread_safe.h" | 12 #include "base/threading/non_thread_safe.h" |
| 13 #include "base/time.h" | 13 #include "base/time.h" |
| 14 #include "cc/output_surface.h" | 14 #include "cc/output_surface.h" |
| 15 #include "cc/software_output_device.h" | |
| 16 | 15 |
| 17 namespace base { | 16 namespace base { |
| 18 class TaskRunner; | 17 class TaskRunner; |
| 19 } | 18 } |
| 20 | 19 |
| 21 namespace IPC { | 20 namespace IPC { |
| 22 class ForwardingMessageFilter; | 21 class ForwardingMessageFilter; |
| 23 class Message; | 22 class Message; |
| 24 } | 23 } |
| 25 | 24 |
| 26 namespace content { | 25 namespace content { |
| 27 | 26 |
| 28 // This class can be created only on the main thread, but then becomes pinned | 27 // This class can be created only on the main thread, but then becomes pinned |
| 29 // to a fixed thread when bindToClient is called. | 28 // to a fixed thread when bindToClient is called. |
| 30 class CompositorOutputSurface | 29 class CompositorOutputSurface |
| 31 : NON_EXPORTED_BASE(public cc::OutputSurface), | 30 : NON_EXPORTED_BASE(public cc::OutputSurface), |
| 32 NON_EXPORTED_BASE(public base::NonThreadSafe) { | 31 NON_EXPORTED_BASE(public base::NonThreadSafe) { |
| 33 public: | 32 public: |
| 34 static IPC::ForwardingMessageFilter* CreateFilter( | 33 static IPC::ForwardingMessageFilter* CreateFilter( |
| 35 base::TaskRunner* target_task_runner); | 34 base::TaskRunner* target_task_runner); |
| 36 | 35 |
| 37 CompositorOutputSurface(int32 routing_id, | 36 CompositorOutputSurface(int32 routing_id, |
| 38 WebKit::WebGraphicsContext3D* context3d, | 37 WebKit::WebGraphicsContext3D* context3d, |
| 39 cc::SoftwareOutputDevice* software); | 38 cc::SoftwareOutputDevice* software); |
| 40 virtual ~CompositorOutputSurface(); | 39 virtual ~CompositorOutputSurface(); |
| 41 | 40 |
| 42 // cc::OutputSurface implementation. | 41 // cc::OutputSurface implementation. |
| 43 virtual bool BindToClient(cc::OutputSurfaceClient* client) OVERRIDE; | 42 virtual bool BindToClient(cc::OutputSurfaceClient* client) OVERRIDE; |
| 44 virtual const struct Capabilities& Capabilities() const OVERRIDE; | |
| 45 virtual WebKit::WebGraphicsContext3D* Context3D() const OVERRIDE; | |
| 46 virtual cc::SoftwareOutputDevice* SoftwareDevice() const OVERRIDE; | |
| 47 virtual void SendFrameToParentCompositor(cc::CompositorFrame*) OVERRIDE; | 43 virtual void SendFrameToParentCompositor(cc::CompositorFrame*) OVERRIDE; |
| 48 | 44 |
| 49 private: | 45 private: |
| 50 class CompositorOutputSurfaceProxy : | 46 class CompositorOutputSurfaceProxy : |
| 51 public base::RefCountedThreadSafe<CompositorOutputSurfaceProxy> { | 47 public base::RefCountedThreadSafe<CompositorOutputSurfaceProxy> { |
| 52 public: | 48 public: |
| 53 explicit CompositorOutputSurfaceProxy( | 49 explicit CompositorOutputSurfaceProxy( |
| 54 CompositorOutputSurface* output_surface) | 50 CompositorOutputSurface* output_surface) |
| 55 : output_surface_(output_surface) {} | 51 : output_surface_(output_surface) {} |
| 56 void ClearOutputSurface() { output_surface_ = NULL; } | 52 void ClearOutputSurface() { output_surface_ = NULL; } |
| 57 void OnMessageReceived(const IPC::Message& message) { | 53 void OnMessageReceived(const IPC::Message& message) { |
| 58 if (output_surface_) | 54 if (output_surface_) |
| 59 output_surface_->OnMessageReceived(message); | 55 output_surface_->OnMessageReceived(message); |
| 60 } | 56 } |
| 61 | 57 |
| 62 private: | 58 private: |
| 63 friend class base::RefCountedThreadSafe<CompositorOutputSurfaceProxy>; | 59 friend class base::RefCountedThreadSafe<CompositorOutputSurfaceProxy>; |
| 64 ~CompositorOutputSurfaceProxy() {} | 60 ~CompositorOutputSurfaceProxy() {} |
| 65 CompositorOutputSurface* output_surface_; | 61 CompositorOutputSurface* output_surface_; |
| 66 | 62 |
| 67 DISALLOW_COPY_AND_ASSIGN(CompositorOutputSurfaceProxy); | 63 DISALLOW_COPY_AND_ASSIGN(CompositorOutputSurfaceProxy); |
| 68 }; | 64 }; |
| 69 | 65 |
| 70 void OnMessageReceived(const IPC::Message& message); | 66 void OnMessageReceived(const IPC::Message& message); |
| 71 void OnUpdateVSyncParameters( | 67 void OnUpdateVSyncParameters( |
| 72 base::TimeTicks timebase, base::TimeDelta interval); | 68 base::TimeTicks timebase, base::TimeDelta interval); |
| 73 bool Send(IPC::Message* message); | 69 bool Send(IPC::Message* message); |
| 74 | 70 |
| 75 scoped_refptr<IPC::ForwardingMessageFilter> output_surface_filter_; | 71 scoped_refptr<IPC::ForwardingMessageFilter> output_surface_filter_; |
| 76 cc::OutputSurfaceClient* client_; | |
| 77 scoped_refptr<CompositorOutputSurfaceProxy> output_surface_proxy_; | 72 scoped_refptr<CompositorOutputSurfaceProxy> output_surface_proxy_; |
| 78 int routing_id_; | 73 int routing_id_; |
| 79 struct Capabilities capabilities_; | |
| 80 scoped_ptr<WebKit::WebGraphicsContext3D> context3D_; | |
| 81 scoped_ptr<cc::SoftwareOutputDevice> software_device_; | |
| 82 }; | 74 }; |
| 83 | 75 |
| 84 } // namespace content | 76 } // namespace content |
| 85 | 77 |
| 86 #endif // CONTENT_RENDERER_GPU_COMPOSITOR_OUTPUT_SURFACE_H_ | 78 #endif // CONTENT_RENDERER_GPU_COMPOSITOR_OUTPUT_SURFACE_H_ |
| OLD | NEW |