| 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 27 matching lines...) Expand all Loading... |
| 38 #include "platform/RuntimeEnabledFeatures.h" | 38 #include "platform/RuntimeEnabledFeatures.h" |
| 39 #include "platform/geometry/IntRect.h" | 39 #include "platform/geometry/IntRect.h" |
| 40 #include "platform/graphics/ExpensiveCanvasHeuristicParameters.h" | 40 #include "platform/graphics/ExpensiveCanvasHeuristicParameters.h" |
| 41 #include "platform/graphics/GraphicsContext.h" | 41 #include "platform/graphics/GraphicsContext.h" |
| 42 #include "platform/graphics/ImageBufferClient.h" | 42 #include "platform/graphics/ImageBufferClient.h" |
| 43 #include "platform/graphics/RecordingImageBufferSurface.h" | 43 #include "platform/graphics/RecordingImageBufferSurface.h" |
| 44 #include "platform/graphics/StaticBitmapImage.h" | 44 #include "platform/graphics/StaticBitmapImage.h" |
| 45 #include "platform/graphics/UnacceleratedImageBufferSurface.h" | 45 #include "platform/graphics/UnacceleratedImageBufferSurface.h" |
| 46 #include "platform/graphics/gpu/DrawingBuffer.h" | 46 #include "platform/graphics/gpu/DrawingBuffer.h" |
| 47 #include "platform/graphics/gpu/Extensions3DUtil.h" | 47 #include "platform/graphics/gpu/Extensions3DUtil.h" |
| 48 #include "platform/graphics/paint/PaintRecord.h" |
| 48 #include "platform/graphics/skia/SkiaUtils.h" | 49 #include "platform/graphics/skia/SkiaUtils.h" |
| 49 #include "platform/image-encoders/JPEGImageEncoder.h" | 50 #include "platform/image-encoders/JPEGImageEncoder.h" |
| 50 #include "platform/image-encoders/PNGImageEncoder.h" | 51 #include "platform/image-encoders/PNGImageEncoder.h" |
| 51 #include "platform/image-encoders/WEBPImageEncoder.h" | 52 #include "platform/image-encoders/WEBPImageEncoder.h" |
| 52 #include "platform/network/mime/MIMETypeRegistry.h" | 53 #include "platform/network/mime/MIMETypeRegistry.h" |
| 53 #include "public/platform/Platform.h" | 54 #include "public/platform/Platform.h" |
| 54 #include "public/platform/WebGraphicsContext3DProvider.h" | 55 #include "public/platform/WebGraphicsContext3DProvider.h" |
| 55 #include "skia/ext/texture_handle.h" | 56 #include "skia/ext/texture_handle.h" |
| 56 #include "third_party/skia/include/core/SkPicture.h" | |
| 57 #include "third_party/skia/include/core/SkSwizzle.h" | 57 #include "third_party/skia/include/core/SkSwizzle.h" |
| 58 #include "third_party/skia/include/gpu/GrContext.h" | 58 #include "third_party/skia/include/gpu/GrContext.h" |
| 59 #include "third_party/skia/include/gpu/gl/GrGLTypes.h" | 59 #include "third_party/skia/include/gpu/gl/GrGLTypes.h" |
| 60 #include "wtf/CheckedNumeric.h" | 60 #include "wtf/CheckedNumeric.h" |
| 61 #include "wtf/MathExtras.h" | 61 #include "wtf/MathExtras.h" |
| 62 #include "wtf/PtrUtil.h" | 62 #include "wtf/PtrUtil.h" |
| 63 #include "wtf/Vector.h" | 63 #include "wtf/Vector.h" |
| 64 #include "wtf/text/Base64.h" | 64 #include "wtf/text/Base64.h" |
| 65 #include "wtf/text/WTFString.h" | 65 #include "wtf/text/WTFString.h" |
| 66 #include "wtf/typed_arrays/ArrayBufferContents.h" | 66 #include "wtf/typed_arrays/ArrayBufferContents.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 return false; | 123 return false; |
| 124 CheckedNumeric<int> area = size.width(); | 124 CheckedNumeric<int> area = size.width(); |
| 125 area *= size.height(); | 125 area *= size.height(); |
| 126 if (!area.IsValid() || area.ValueOrDie() > kMaxCanvasArea) | 126 if (!area.IsValid() || area.ValueOrDie() > kMaxCanvasArea) |
| 127 return false; | 127 return false; |
| 128 if (size.width() > kMaxSkiaDim || size.height() > kMaxSkiaDim) | 128 if (size.width() > kMaxSkiaDim || size.height() > kMaxSkiaDim) |
| 129 return false; | 129 return false; |
| 130 return true; | 130 return true; |
| 131 } | 131 } |
| 132 | 132 |
| 133 SkCanvas* ImageBuffer::canvas() const { | 133 PaintCanvas* ImageBuffer::canvas() const { |
| 134 return m_surface->canvas(); | 134 return m_surface->canvas(); |
| 135 } | 135 } |
| 136 | 136 |
| 137 void ImageBuffer::disableDeferral(DisableDeferralReason reason) const { | 137 void ImageBuffer::disableDeferral(DisableDeferralReason reason) const { |
| 138 return m_surface->disableDeferral(reason); | 138 return m_surface->disableDeferral(reason); |
| 139 } | 139 } |
| 140 | 140 |
| 141 bool ImageBuffer::writePixels(const SkImageInfo& info, | 141 bool ImageBuffer::writePixels(const SkImageInfo& info, |
| 142 const void* pixels, | 142 const void* pixels, |
| 143 size_t rowBytes, | 143 size_t rowBytes, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 166 | 166 |
| 167 bool ImageBuffer::restoreSurface() const { | 167 bool ImageBuffer::restoreSurface() const { |
| 168 return m_surface->isValid() || m_surface->restore(); | 168 return m_surface->isValid() || m_surface->restore(); |
| 169 } | 169 } |
| 170 | 170 |
| 171 void ImageBuffer::notifySurfaceInvalid() { | 171 void ImageBuffer::notifySurfaceInvalid() { |
| 172 if (m_client) | 172 if (m_client) |
| 173 m_client->notifySurfaceInvalid(); | 173 m_client->notifySurfaceInvalid(); |
| 174 } | 174 } |
| 175 | 175 |
| 176 void ImageBuffer::resetCanvas(SkCanvas* canvas) const { | 176 void ImageBuffer::resetCanvas(PaintCanvas* canvas) const { |
| 177 if (m_client) | 177 if (m_client) |
| 178 m_client->restoreCanvasMatrixClipStack(canvas); | 178 m_client->restoreCanvasMatrixClipStack(canvas); |
| 179 } | 179 } |
| 180 | 180 |
| 181 sk_sp<SkImage> ImageBuffer::newSkImageSnapshot(AccelerationHint hint, | 181 sk_sp<SkImage> ImageBuffer::newSkImageSnapshot(AccelerationHint hint, |
| 182 SnapshotReason reason) const { | 182 SnapshotReason reason) const { |
| 183 if (m_snapshotState == InitialSnapshotState) | 183 if (m_snapshotState == InitialSnapshotState) |
| 184 m_snapshotState = DidAcquireSnapshot; | 184 m_snapshotState = DidAcquireSnapshot; |
| 185 | 185 |
| 186 if (!isSurfaceValid()) | 186 if (!isSurfaceValid()) |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 DCHECK(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); | 597 DCHECK(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); |
| 598 | 598 |
| 599 Vector<unsigned char> result; | 599 Vector<unsigned char> result; |
| 600 if (!encodeImage(mimeType, quality, &result)) | 600 if (!encodeImage(mimeType, quality, &result)) |
| 601 return "data:,"; | 601 return "data:,"; |
| 602 | 602 |
| 603 return "data:" + mimeType + ";base64," + base64Encode(result); | 603 return "data:" + mimeType + ";base64," + base64Encode(result); |
| 604 } | 604 } |
| 605 | 605 |
| 606 } // namespace blink | 606 } // namespace blink |
| OLD | NEW |