| 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 FakeWebCompositorOutputSurface_h | 5 #ifndef FakeWebCompositorOutputSurface_h |
| 6 #define FakeWebCompositorOutputSurface_h | 6 #define FakeWebCompositorOutputSurface_h |
| 7 | 7 |
| 8 #include "FakeWebCompositorSoftwareOutputDevice.h" |
| 8 #include <public/WebCompositorOutputSurface.h> | 9 #include <public/WebCompositorOutputSurface.h> |
| 9 #include <public/WebGraphicsContext3D.h> | 10 #include <public/WebGraphicsContext3D.h> |
| 10 #include <wtf/OwnPtr.h> | 11 #include <wtf/OwnPtr.h> |
| 11 #include <wtf/PassOwnPtr.h> | 12 #include <wtf/PassOwnPtr.h> |
| 12 | 13 |
| 13 namespace WebKit { | 14 namespace WebKit { |
| 14 | 15 |
| 15 class FakeWebCompositorOutputSurface : public WebCompositorOutputSurface { | 16 class FakeWebCompositorOutputSurface : public WebCompositorOutputSurface { |
| 16 public: | 17 public: |
| 17 static inline PassOwnPtr<FakeWebCompositorOutputSurface> create(PassOwnPtr<W
ebGraphicsContext3D> context3D) | 18 static inline PassOwnPtr<FakeWebCompositorOutputSurface> create(PassOwnPtr<W
ebGraphicsContext3D> context3D) |
| 18 { | 19 { |
| 19 return adoptPtr(new FakeWebCompositorOutputSurface(context3D)); | 20 return adoptPtr(new FakeWebCompositorOutputSurface(context3D)); |
| 20 } | 21 } |
| 21 | 22 |
| 23 static inline PassOwnPtr<FakeWebCompositorOutputSurface> createSoftware(Pass
OwnPtr<WebCompositorSoftwareOutputDevice> softwareDevice) |
| 24 { |
| 25 return adoptPtr(new FakeWebCompositorOutputSurface(softwareDevice)); |
| 26 } |
| 22 | 27 |
| 23 virtual bool bindToClient(WebCompositorOutputSurfaceClient* client) OVERRIDE | 28 virtual bool bindToClient(WebCompositorOutputSurfaceClient* client) OVERRIDE |
| 24 { | 29 { |
| 30 if (!m_context3D) |
| 31 return true; |
| 25 ASSERT(client); | 32 ASSERT(client); |
| 26 if (!m_context3D->makeContextCurrent()) | 33 if (!m_context3D->makeContextCurrent()) |
| 27 return false; | 34 return false; |
| 28 m_client = client; | 35 m_client = client; |
| 29 return true; | 36 return true; |
| 30 } | 37 } |
| 31 | 38 |
| 32 virtual const Capabilities& capabilities() const OVERRIDE | 39 virtual const Capabilities& capabilities() const OVERRIDE |
| 33 { | 40 { |
| 34 return m_capabilities; | 41 return m_capabilities; |
| 35 } | 42 } |
| 36 | 43 |
| 37 virtual WebGraphicsContext3D* context3D() const OVERRIDE | 44 virtual WebGraphicsContext3D* context3D() const OVERRIDE |
| 38 { | 45 { |
| 39 return m_context3D.get(); | 46 return m_context3D.get(); |
| 40 } | 47 } |
| 48 virtual WebCompositorSoftwareOutputDevice* softwareDevice() const OVERRIDE |
| 49 { |
| 50 return m_softwareDevice.get(); |
| 51 } |
| 41 | 52 |
| 42 virtual void sendFrameToParentCompositor(const WebCompositorFrame&) OVERRIDE | 53 virtual void sendFrameToParentCompositor(const WebCompositorFrame&) OVERRIDE |
| 43 { | 54 { |
| 44 } | 55 } |
| 45 | 56 |
| 46 private: | 57 private: |
| 47 explicit FakeWebCompositorOutputSurface(PassOwnPtr<WebGraphicsContext3D> con
text3D) | 58 explicit FakeWebCompositorOutputSurface(PassOwnPtr<WebGraphicsContext3D> con
text3D) |
| 48 { | 59 { |
| 49 m_context3D = context3D; | 60 m_context3D = context3D; |
| 50 } | 61 } |
| 51 | 62 |
| 63 explicit FakeWebCompositorOutputSurface(PassOwnPtr<WebCompositorSoftwareOutp
utDevice> softwareDevice) |
| 64 { |
| 65 m_softwareDevice = softwareDevice; |
| 66 } |
| 67 |
| 52 OwnPtr<WebGraphicsContext3D> m_context3D; | 68 OwnPtr<WebGraphicsContext3D> m_context3D; |
| 69 OwnPtr<WebCompositorSoftwareOutputDevice> m_softwareDevice; |
| 53 Capabilities m_capabilities; | 70 Capabilities m_capabilities; |
| 54 WebCompositorOutputSurfaceClient* m_client; | 71 WebCompositorOutputSurfaceClient* m_client; |
| 55 }; | 72 }; |
| 56 | 73 |
| 57 } // namespace WebKit | 74 } // namespace WebKit |
| 58 | 75 |
| 59 #endif // FakeWebCompositorOutputSurface_h | 76 #endif // FakeWebCompositorOutputSurface_h |
| OLD | NEW |