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 |
| 5 #ifndef FakeWebCompositorSoftwareOutputDevice_h |
| 6 #define FakeWebCompositorSoftwareOutputDevice_h |
| 7 |
| 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "SkDevice.h" |
| 10 #include <public/WebCompositorSoftwareOutputDevice.h> |
| 11 #include <public/WebImage.h> |
| 12 #include <public/WebSize.h> |
| 13 |
| 14 namespace WebKit { |
| 15 |
| 16 class FakeWebCompositorSoftwareOutputDevice : public WebCompositorSoftwareOutput
Device { |
| 17 public: |
| 18 virtual WebImage* lock(bool forWrite) OVERRIDE |
| 19 { |
| 20 ASSERT(m_device.get()); |
| 21 m_image = m_device->accessBitmap(forWrite); |
| 22 return &m_image; |
| 23 } |
| 24 virtual void unlock() OVERRIDE |
| 25 { |
| 26 m_image.reset(); |
| 27 } |
| 28 |
| 29 virtual void didChangeViewportSize(WebSize size) OVERRIDE |
| 30 { |
| 31 if (m_device.get() && size.width == m_device->width() && size.height ==
m_device->height()) |
| 32 return; |
| 33 |
| 34 m_device.reset(new SkDevice(SkBitmap::kARGB_8888_Config, size.width, siz
e.height, true)); |
| 35 } |
| 36 |
| 37 private: |
| 38 scoped_ptr<SkDevice> m_device; |
| 39 WebImage m_image; |
| 40 }; |
| 41 |
| 42 } // namespace WebKit |
| 43 |
| 44 #endif // FakeWebCompositorSoftwareOutputDevice_h |
OLD | NEW |