| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 CC_OUTPUT_SURFACE_H_ | 5 #ifndef CC_OUTPUT_SURFACE_H_ |
| 6 #define CC_OUTPUT_SURFACE_H_ | 6 #define CC_OUTPUT_SURFACE_H_ |
| 7 | 7 |
| 8 #define USE_CC_OUTPUT_SURFACE // TODO(danakj): Remove this. | 8 #define USE_CC_OUTPUT_SURFACE // TODO(danakj): Remove this. |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" |
| 10 #include "cc/cc_export.h" | 11 #include "cc/cc_export.h" |
| 12 #include "cc/software_output_device.h" |
| 11 #include "third_party/WebKit/Source/Platform/chromium/public/WebCompositorOutput
Surface.h" | 13 #include "third_party/WebKit/Source/Platform/chromium/public/WebCompositorOutput
Surface.h" |
| 12 | 14 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3
D.h" |
| 13 namespace WebKit { | |
| 14 class WebGraphicsContext3D; | |
| 15 } | |
| 16 | 15 |
| 17 namespace cc { | 16 namespace cc { |
| 18 | 17 |
| 19 class CompositorFrame; | 18 class CompositorFrame; |
| 20 class OutputSurfaceClient; | 19 class OutputSurfaceClient; |
| 21 class SoftwareOutputDevice; | |
| 22 | 20 |
| 23 // Represents the output surface for a compositor. The compositor owns | 21 // Represents the output surface for a compositor. The compositor owns |
| 24 // and manages its destruction. Its lifetime is: | 22 // and manages its destruction. Its lifetime is: |
| 25 // 1. Created on the main thread by the LayerTreeHost through its client. | 23 // 1. Created on the main thread by the LayerTreeHost through its client. |
| 26 // 2. Passed to the compositor thread and bound to a client via BindToClient. | 24 // 2. Passed to the compositor thread and bound to a client via BindToClient. |
| 27 // From here on, it will only be used on the compositor thread. | 25 // From here on, it will only be used on the compositor thread. |
| 28 // 3. If the 3D context is lost, then the compositor will delete the output | 26 // 3. If the 3D context is lost, then the compositor will delete the output |
| 29 // surface (on the compositor thread) and go back to step 1. | 27 // surface (on the compositor thread) and go back to step 1. |
| 30 class CC_EXPORT OutputSurface : public WebKit::WebCompositorOutputSurface { | 28 class CC_EXPORT OutputSurface : public WebKit::WebCompositorOutputSurface { |
| 31 public: | 29 public: |
| 32 virtual ~OutputSurface() {} | 30 OutputSurface(scoped_ptr<WebKit::WebGraphicsContext3D> context3d); |
| 33 | 31 |
| 34 // Called by the compositor on the compositor thread. This is a place where | 32 OutputSurface(scoped_ptr<cc::SoftwareOutputDevice> software_device); |
| 35 // thread-specific data for the output surface can be initialized, since from | 33 |
| 36 // this point on the output surface will only be used on the compositor | 34 OutputSurface(scoped_ptr<WebKit::WebGraphicsContext3D> context3d, |
| 37 // thread. | 35 scoped_ptr<cc::SoftwareOutputDevice> software_device); |
| 38 virtual bool BindToClient(OutputSurfaceClient*) = 0; | 36 |
| 37 virtual ~OutputSurface(); |
| 39 | 38 |
| 40 struct Capabilities { | 39 struct Capabilities { |
| 41 Capabilities() | 40 Capabilities() |
| 42 : has_parent_compositor(false) {} | 41 : has_parent_compositor(false) {} |
| 43 | 42 |
| 44 bool has_parent_compositor; | 43 bool has_parent_compositor; |
| 45 }; | 44 }; |
| 46 | 45 |
| 47 virtual const Capabilities& Capabilities() const = 0; | 46 const Capabilities& capabilities() const { |
| 47 return capabilities_; |
| 48 } |
| 48 | 49 |
| 49 // Obtain the 3d context or the software device associated with this output | 50 // Obtain the 3d context or the software device associated with this output |
| 50 // surface. Either of these may return a null pointer, but not both. | 51 // surface. Either of these may return a null pointer, but not both. |
| 51 // In the event of a lost context, the entire output surface should be | 52 // In the event of a lost context, the entire output surface should be |
| 52 // recreated. | 53 // recreated. |
| 53 virtual WebKit::WebGraphicsContext3D* Context3D() const = 0; | 54 WebKit::WebGraphicsContext3D* context3d() const { |
| 54 virtual SoftwareOutputDevice* SoftwareDevice() const = 0; | 55 return context3d_.get(); |
| 56 } |
| 57 |
| 58 SoftwareOutputDevice* software_device() const { |
| 59 return software_device_.get(); |
| 60 } |
| 61 |
| 62 // Called by the compositor on the compositor thread. This is a place where |
| 63 // thread-specific data for the output surface can be initialized, since from |
| 64 // this point on the output surface will only be used on the compositor |
| 65 // thread. |
| 66 virtual bool BindToClient(OutputSurfaceClient*); |
| 55 | 67 |
| 56 // Sends frame data to the parent compositor. This should only be called when | 68 // Sends frame data to the parent compositor. This should only be called when |
| 57 // capabilities().has_parent_compositor. The implementation may destroy or | 69 // capabilities().has_parent_compositor. The implementation may destroy or |
| 58 // steal the contents of the CompositorFrame passed in. | 70 // steal the contents of the CompositorFrame passed in. |
| 59 virtual void SendFrameToParentCompositor(CompositorFrame*) = 0; | 71 virtual void SendFrameToParentCompositor(CompositorFrame*); |
| 60 | 72 |
| 61 // Notifies frame-rate smoothness preference. If true, all non-critical | 73 // Notifies frame-rate smoothness preference. If true, all non-critical |
| 62 // processing should be stopped, or lowered in priority. | 74 // processing should be stopped, or lowered in priority. |
| 63 virtual void UpdateSmoothnessTakesPriority(bool prefer_smoothness) {} | 75 virtual void UpdateSmoothnessTakesPriority(bool prefer_smoothness) {} |
| 76 |
| 77 protected: |
| 78 OutputSurfaceClient* client_; |
| 79 struct cc::OutputSurface::Capabilities capabilities_; |
| 80 scoped_ptr<WebKit::WebGraphicsContext3D> context3d_; |
| 81 scoped_ptr<cc::SoftwareOutputDevice> software_device_; |
| 64 }; | 82 }; |
| 65 | 83 |
| 66 } // namespace cc | 84 } // namespace cc |
| 67 | 85 |
| 68 #endif // CC_OUTPUT_SURFACE_H_ | 86 #endif // CC_OUTPUT_SURFACE_H_ |
| OLD | NEW |