| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 #include "platform/graphics/UnacceleratedImageBufferSurface.h" | 46 #include "platform/graphics/UnacceleratedImageBufferSurface.h" |
| 47 #include "platform/graphics/gpu/DrawingBuffer.h" | 47 #include "platform/graphics/gpu/DrawingBuffer.h" |
| 48 #include "platform/graphics/gpu/Extensions3DUtil.h" | 48 #include "platform/graphics/gpu/Extensions3DUtil.h" |
| 49 #include "platform/graphics/skia/SkiaUtils.h" | 49 #include "platform/graphics/skia/SkiaUtils.h" |
| 50 #include "platform/image-encoders/JPEGImageEncoder.h" | 50 #include "platform/image-encoders/JPEGImageEncoder.h" |
| 51 #include "platform/image-encoders/PNGImageEncoder.h" | 51 #include "platform/image-encoders/PNGImageEncoder.h" |
| 52 #include "platform/image-encoders/WEBPImageEncoder.h" | 52 #include "platform/image-encoders/WEBPImageEncoder.h" |
| 53 #include "public/platform/Platform.h" | 53 #include "public/platform/Platform.h" |
| 54 #include "public/platform/WebGraphicsContext3DProvider.h" | 54 #include "public/platform/WebGraphicsContext3DProvider.h" |
| 55 #include "skia/ext/texture_handle.h" | 55 #include "skia/ext/texture_handle.h" |
| 56 #include "third_party/skia/include/core/SkPicture.h" | 56 #include "skia/ext/cdl_picture.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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 return false; | 115 return false; |
| 116 CheckedNumeric<int> area = size.width(); | 116 CheckedNumeric<int> area = size.width(); |
| 117 area *= size.height(); | 117 area *= size.height(); |
| 118 if (!area.IsValid() || area.ValueOrDie() > kMaxCanvasArea) | 118 if (!area.IsValid() || area.ValueOrDie() > kMaxCanvasArea) |
| 119 return false; | 119 return false; |
| 120 if (size.width() > kMaxSkiaDim || size.height() > kMaxSkiaDim) | 120 if (size.width() > kMaxSkiaDim || size.height() > kMaxSkiaDim) |
| 121 return false; | 121 return false; |
| 122 return true; | 122 return true; |
| 123 } | 123 } |
| 124 | 124 |
| 125 SkCanvas* ImageBuffer::canvas() const { | 125 CdlCanvas* ImageBuffer::canvas() const { |
| 126 return m_surface->canvas(); | 126 return m_surface->canvas(); |
| 127 } | 127 } |
| 128 | 128 |
| 129 void ImageBuffer::disableDeferral(DisableDeferralReason reason) const { | 129 void ImageBuffer::disableDeferral(DisableDeferralReason reason) const { |
| 130 return m_surface->disableDeferral(reason); | 130 return m_surface->disableDeferral(reason); |
| 131 } | 131 } |
| 132 | 132 |
| 133 bool ImageBuffer::writePixels(const SkImageInfo& info, | 133 bool ImageBuffer::writePixels(const SkImageInfo& info, |
| 134 const void* pixels, | 134 const void* pixels, |
| 135 size_t rowBytes, | 135 size_t rowBytes, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 | 168 |
| 169 bool ImageBuffer::restoreSurface() const { | 169 bool ImageBuffer::restoreSurface() const { |
| 170 return m_surface->isValid() || m_surface->restore(); | 170 return m_surface->isValid() || m_surface->restore(); |
| 171 } | 171 } |
| 172 | 172 |
| 173 void ImageBuffer::notifySurfaceInvalid() { | 173 void ImageBuffer::notifySurfaceInvalid() { |
| 174 if (m_client) | 174 if (m_client) |
| 175 m_client->notifySurfaceInvalid(); | 175 m_client->notifySurfaceInvalid(); |
| 176 } | 176 } |
| 177 | 177 |
| 178 void ImageBuffer::resetCanvas(SkCanvas* canvas) const { | 178 void ImageBuffer::resetCanvas(CdlCanvas* canvas) const { |
| 179 if (m_client) | 179 if (m_client) |
| 180 m_client->restoreCanvasMatrixClipStack(canvas); | 180 m_client->restoreCanvasMatrixClipStack(canvas); |
| 181 } | 181 } |
| 182 | 182 |
| 183 sk_sp<SkImage> ImageBuffer::newSkImageSnapshot(AccelerationHint hint, | 183 sk_sp<SkImage> ImageBuffer::newSkImageSnapshot(AccelerationHint hint, |
| 184 SnapshotReason reason) const { | 184 SnapshotReason reason) const { |
| 185 if (m_snapshotState == InitialSnapshotState) | 185 if (m_snapshotState == InitialSnapshotState) |
| 186 m_snapshotState = DidAcquireSnapshot; | 186 m_snapshotState = DidAcquireSnapshot; |
| 187 | 187 |
| 188 if (!isSurfaceValid()) | 188 if (!isSurfaceValid()) |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); | 562 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); |
| 563 | 563 |
| 564 Vector<unsigned char> result; | 564 Vector<unsigned char> result; |
| 565 if (!encodeImage(mimeType, quality, &result)) | 565 if (!encodeImage(mimeType, quality, &result)) |
| 566 return "data:,"; | 566 return "data:,"; |
| 567 | 567 |
| 568 return "data:" + mimeType + ";base64," + base64Encode(result); | 568 return "data:" + mimeType + ";base64," + base64Encode(result); |
| 569 } | 569 } |
| 570 | 570 |
| 571 } // namespace blink | 571 } // namespace blink |
| OLD | NEW |