| 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/BitmapImage.h" |
| 36 #include "platform/graphics/GraphicsContext.h" |
| 35 #include "platform/graphics/ImageBuffer.h" | 37 #include "platform/graphics/ImageBuffer.h" |
| 36 #include "third_party/skia/include/core/SkCanvas.h" | 38 #include "third_party/skia/include/core/SkCanvas.h" |
| 37 #include "third_party/skia/include/core/SkDevice.h" | 39 #include "third_party/skia/include/core/SkDevice.h" |
| 38 #include "third_party/skia/include/core/SkImage.h" | 40 #include "third_party/skia/include/core/SkImage.h" |
| 39 #include "third_party/skia/include/core/SkPicture.h" | 41 #include "third_party/skia/include/core/SkPicture.h" |
| 40 | 42 |
| 41 namespace blink { | 43 namespace blink { |
| 42 | 44 |
| 43 ImageBufferSurface::ImageBufferSurface(const IntSize& size, OpacityMode opacityM
ode) | 45 ImageBufferSurface::ImageBufferSurface(const IntSize& size, OpacityMode opacityM
ode) |
| 44 : m_opacityMode(opacityMode) | 46 : m_opacityMode(opacityMode) |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 { | 81 { |
| 80 DEFINE_STATIC_LOCAL(SkBitmap, nullBitmap, ()); | 82 DEFINE_STATIC_LOCAL(SkBitmap, nullBitmap, ()); |
| 81 return nullBitmap; | 83 return nullBitmap; |
| 82 } | 84 } |
| 83 | 85 |
| 84 PassRefPtr<SkImage> ImageBufferSurface::newImageSnapshot() const | 86 PassRefPtr<SkImage> ImageBufferSurface::newImageSnapshot() const |
| 85 { | 87 { |
| 86 return nullptr; | 88 return nullptr; |
| 87 } | 89 } |
| 88 | 90 |
| 91 static SkBitmap deepSkBitmapCopy(const SkBitmap& bitmap) |
| 92 { |
| 93 SkBitmap tmp; |
| 94 if (!bitmap.deepCopyTo(&tmp)) |
| 95 bitmap.copyTo(&tmp, bitmap.colorType()); |
| 96 |
| 97 return tmp; |
| 98 } |
| 99 |
| 100 void ImageBufferSurface::draw(GraphicsContext* context, const FloatRect& destRec
t, const FloatRect& srcRect, CompositeOperator op, WebBlendMode blendMode, bool
needsCopy) |
| 101 { |
| 102 SkBitmap bmp = bitmap(); |
| 103 // For ImageBufferSurface that enables cachedBitmap, Use the cached bitmap f
or CPU side usage |
| 104 // if it is available, otherwise generate and use it. |
| 105 if (!context->isAccelerated() && isAccelerated() && cachedBitmapEnabled() &&
isValid()) { |
| 106 updateCachedBitmapIfNeeded(); |
| 107 bmp = cachedBitmap(); |
| 108 } |
| 109 |
| 110 RefPtr<Image> image = BitmapImage::create(NativeImageSkia::create(needsCopy
? deepSkBitmapCopy(bmp) : bmp)); |
| 111 |
| 112 context->drawImage(image.get(), destRect, srcRect, op, blendMode, DoNotRespe
ctImageOrientation); |
| 113 } |
| 114 |
| 89 } // namespace blink | 115 } // namespace blink |
| OLD | NEW |