| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013, Google Inc. All rights reserved. | 2 * Copyright (c) 2013, Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 | 32 |
| 33 #include "platform/graphics/ImageBufferSurface.h" | 33 #include "platform/graphics/ImageBufferSurface.h" |
| 34 | 34 |
| 35 #include "platform/graphics/ImageBuffer.h" |
| 35 #include "third_party/skia/include/core/SkCanvas.h" | 36 #include "third_party/skia/include/core/SkCanvas.h" |
| 36 #include "third_party/skia/include/core/SkDevice.h" | 37 #include "third_party/skia/include/core/SkDevice.h" |
| 37 | 38 |
| 38 namespace WebCore { | 39 namespace WebCore { |
| 39 | 40 |
| 41 ImageBufferSurface::ImageBufferSurface(const IntSize& size, OpacityMode opacityM
ode) |
| 42 : m_opacityMode(opacityMode) |
| 43 , m_size(size) |
| 44 { |
| 45 setIsHidden(false); |
| 46 } |
| 47 |
| 40 void ImageBufferSurface::clear() | 48 void ImageBufferSurface::clear() |
| 41 { | 49 { |
| 42 // Clear the background transparent or opaque, as required. It would be nice
if this wasn't | 50 // Clear the background transparent or opaque, as required. It would be nice
if this wasn't |
| 43 // required, but the canvas is currently filled with the magic transparency | 51 // required, but the canvas is currently filled with the magic transparency |
| 44 // color. Can we have another way to manage this? | 52 // color. Can we have another way to manage this? |
| 45 if (isValid()) { | 53 if (isValid()) { |
| 46 if (m_opacityMode == Opaque) | 54 if (m_opacityMode == Opaque) |
| 47 canvas()->drawARGB(255, 0, 0, 0, SkXfermode::kSrc_Mode); | 55 canvas()->drawARGB(255, 0, 0, 0, SkXfermode::kSrc_Mode); |
| 48 else | 56 else |
| 49 canvas()->drawARGB(0, 0, 0, 0, SkXfermode::kClear_Mode); | 57 canvas()->drawARGB(0, 0, 0, 0, SkXfermode::kClear_Mode); |
| 50 } | 58 } |
| 51 } | 59 } |
| 52 | 60 |
| 53 const SkBitmap& ImageBufferSurface::bitmap() const | 61 const SkBitmap& ImageBufferSurface::bitmap() const |
| 54 { | 62 { |
| 55 ASSERT(canvas()); | 63 ASSERT(canvas()); |
| 56 return canvas()->getTopDevice()->accessBitmap(false); | 64 return canvas()->getTopDevice()->accessBitmap(false); |
| 57 } | 65 } |
| 58 | 66 |
| 59 const SkBitmap& ImageBufferSurface::cachedBitmap() const | 67 const SkBitmap& ImageBufferSurface::cachedBitmap() const |
| 60 { | 68 { |
| 61 DEFINE_STATIC_LOCAL(SkBitmap, nullBitmap, ()); | 69 DEFINE_STATIC_LOCAL(SkBitmap, nullBitmap, ()); |
| 62 return nullBitmap; | 70 return nullBitmap; |
| 63 } | 71 } |
| 64 | 72 |
| 65 } // namespace WebCore | 73 } // namespace WebCore |
| OLD | NEW |