| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2008, Google Inc. All rights reserved. | 2 * Copyright (c) 2008, Google Inc. All rights reserved. |
| 3 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> | 3 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> |
| 4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. | 4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions are | 7 * modification, are permitted provided that the following conditions are |
| 8 * met: | 8 * met: |
| 9 * | 9 * |
| 10 * * Redistributions of source code must retain the above copyright | 10 * * Redistributions of source code must retain the above copyright |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 31 */ | 31 */ |
| 32 | 32 |
| 33 #include "platform/graphics/ImageBuffer.h" | 33 #include "platform/graphics/ImageBuffer.h" |
| 34 | 34 |
| 35 #include <memory> |
| 35 #include "gpu/command_buffer/client/gles2_interface.h" | 36 #include "gpu/command_buffer/client/gles2_interface.h" |
| 36 #include "gpu/command_buffer/common/mailbox.h" | 37 #include "gpu/command_buffer/common/mailbox.h" |
| 37 #include "gpu/command_buffer/common/sync_token.h" | 38 #include "gpu/command_buffer/common/sync_token.h" |
| 38 #include "platform/RuntimeEnabledFeatures.h" | 39 #include "platform/RuntimeEnabledFeatures.h" |
| 39 #include "platform/geometry/IntRect.h" | 40 #include "platform/geometry/IntRect.h" |
| 40 #include "platform/graphics/ExpensiveCanvasHeuristicParameters.h" | 41 #include "platform/graphics/ExpensiveCanvasHeuristicParameters.h" |
| 41 #include "platform/graphics/GraphicsContext.h" | 42 #include "platform/graphics/GraphicsContext.h" |
| 42 #include "platform/graphics/ImageBufferClient.h" | 43 #include "platform/graphics/ImageBufferClient.h" |
| 43 #include "platform/graphics/RecordingImageBufferSurface.h" | 44 #include "platform/graphics/RecordingImageBufferSurface.h" |
| 44 #include "platform/graphics/StaticBitmapImage.h" | 45 #include "platform/graphics/StaticBitmapImage.h" |
| 45 #include "platform/graphics/UnacceleratedImageBufferSurface.h" | 46 #include "platform/graphics/UnacceleratedImageBufferSurface.h" |
| 46 #include "platform/graphics/gpu/DrawingBuffer.h" | 47 #include "platform/graphics/gpu/DrawingBuffer.h" |
| 47 #include "platform/graphics/gpu/Extensions3DUtil.h" | 48 #include "platform/graphics/gpu/Extensions3DUtil.h" |
| 48 #include "platform/graphics/paint/PaintRecord.h" | 49 #include "platform/graphics/paint/PaintRecord.h" |
| 49 #include "platform/graphics/skia/SkiaUtils.h" | 50 #include "platform/graphics/skia/SkiaUtils.h" |
| 50 #include "platform/image-encoders/JPEGImageEncoder.h" | 51 #include "platform/image-encoders/JPEGImageEncoder.h" |
| 51 #include "platform/image-encoders/PNGImageEncoder.h" | 52 #include "platform/image-encoders/PNGImageEncoder.h" |
| 52 #include "platform/image-encoders/WEBPImageEncoder.h" | 53 #include "platform/image-encoders/WEBPImageEncoder.h" |
| 53 #include "platform/network/mime/MIMETypeRegistry.h" | 54 #include "platform/network/mime/MIMETypeRegistry.h" |
| 55 #include "platform/wtf/CheckedNumeric.h" |
| 56 #include "platform/wtf/MathExtras.h" |
| 57 #include "platform/wtf/PtrUtil.h" |
| 58 #include "platform/wtf/Vector.h" |
| 59 #include "platform/wtf/text/Base64.h" |
| 60 #include "platform/wtf/text/WTFString.h" |
| 61 #include "platform/wtf/typed_arrays/ArrayBufferContents.h" |
| 54 #include "public/platform/Platform.h" | 62 #include "public/platform/Platform.h" |
| 55 #include "public/platform/WebGraphicsContext3DProvider.h" | 63 #include "public/platform/WebGraphicsContext3DProvider.h" |
| 56 #include "skia/ext/texture_handle.h" | 64 #include "skia/ext/texture_handle.h" |
| 57 #include "third_party/skia/include/core/SkSwizzle.h" | 65 #include "third_party/skia/include/core/SkSwizzle.h" |
| 58 #include "third_party/skia/include/gpu/GrContext.h" | 66 #include "third_party/skia/include/gpu/GrContext.h" |
| 59 #include "third_party/skia/include/gpu/gl/GrGLTypes.h" | 67 #include "third_party/skia/include/gpu/gl/GrGLTypes.h" |
| 60 #include "wtf/CheckedNumeric.h" | |
| 61 #include "wtf/MathExtras.h" | |
| 62 #include "wtf/PtrUtil.h" | |
| 63 #include "wtf/Vector.h" | |
| 64 #include "wtf/text/Base64.h" | |
| 65 #include "wtf/text/WTFString.h" | |
| 66 #include "wtf/typed_arrays/ArrayBufferContents.h" | |
| 67 #include <memory> | |
| 68 | 68 |
| 69 namespace blink { | 69 namespace blink { |
| 70 | 70 |
| 71 std::unique_ptr<ImageBuffer> ImageBuffer::create( | 71 std::unique_ptr<ImageBuffer> ImageBuffer::create( |
| 72 std::unique_ptr<ImageBufferSurface> surface) { | 72 std::unique_ptr<ImageBufferSurface> surface) { |
| 73 if (!surface->isValid()) | 73 if (!surface->isValid()) |
| 74 return nullptr; | 74 return nullptr; |
| 75 return WTF::wrapUnique(new ImageBuffer(std::move(surface))); | 75 return WTF::wrapUnique(new ImageBuffer(std::move(surface))); |
| 76 } | 76 } |
| 77 | 77 |
| (...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 DCHECK(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); | 620 DCHECK(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); |
| 621 | 621 |
| 622 Vector<unsigned char> result; | 622 Vector<unsigned char> result; |
| 623 if (!encodeImage(mimeType, quality, &result)) | 623 if (!encodeImage(mimeType, quality, &result)) |
| 624 return "data:,"; | 624 return "data:,"; |
| 625 | 625 |
| 626 return "data:" + mimeType + ";base64," + base64Encode(result); | 626 return "data:" + mimeType + ";base64," + base64Encode(result); |
| 627 } | 627 } |
| 628 | 628 |
| 629 } // namespace blink | 629 } // namespace blink |
| OLD | NEW |