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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 #include "platform/graphics/gpu/Extensions3DUtil.h" | 45 #include "platform/graphics/gpu/Extensions3DUtil.h" |
46 #include "platform/graphics/skia/SkiaUtils.h" | 46 #include "platform/graphics/skia/SkiaUtils.h" |
47 #include "platform/image-encoders/skia/JPEGImageEncoder.h" | 47 #include "platform/image-encoders/skia/JPEGImageEncoder.h" |
48 #include "platform/image-encoders/skia/PNGImageEncoder.h" | 48 #include "platform/image-encoders/skia/PNGImageEncoder.h" |
49 #include "platform/image-encoders/skia/WEBPImageEncoder.h" | 49 #include "platform/image-encoders/skia/WEBPImageEncoder.h" |
50 #include "public/platform/Platform.h" | 50 #include "public/platform/Platform.h" |
51 #include "public/platform/WebExternalTextureMailbox.h" | 51 #include "public/platform/WebExternalTextureMailbox.h" |
52 #include "public/platform/WebGraphicsContext3D.h" | 52 #include "public/platform/WebGraphicsContext3D.h" |
53 #include "public/platform/WebGraphicsContext3DProvider.h" | 53 #include "public/platform/WebGraphicsContext3DProvider.h" |
54 #include "third_party/skia/include/core/SkPicture.h" | 54 #include "third_party/skia/include/core/SkPicture.h" |
55 #include "third_party/skia/include/effects/SkTableColorFilter.h" | |
56 #include "wtf/ArrayBufferContents.h" | 55 #include "wtf/ArrayBufferContents.h" |
57 #include "wtf/MathExtras.h" | 56 #include "wtf/MathExtras.h" |
58 #include "wtf/Vector.h" | 57 #include "wtf/Vector.h" |
59 #include "wtf/text/Base64.h" | 58 #include "wtf/text/Base64.h" |
60 #include "wtf/text/WTFString.h" | 59 #include "wtf/text/WTFString.h" |
61 | 60 |
62 namespace blink { | 61 namespace blink { |
63 | 62 |
64 PassOwnPtr<ImageBuffer> ImageBuffer::create(PassOwnPtr<ImageBufferSurface> surfa
ce) | 63 PassOwnPtr<ImageBuffer> ImageBuffer::create(PassOwnPtr<ImageBufferSurface> surfa
ce) |
65 { | 64 { |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 m_surface->draw(context, destRect, srcRect, op, drawNeedsCopy(m_context.get(
), context)); | 280 m_surface->draw(context, destRect, srcRect, op, drawNeedsCopy(m_context.get(
), context)); |
282 } | 281 } |
283 | 282 |
284 void ImageBuffer::flush() | 283 void ImageBuffer::flush() |
285 { | 284 { |
286 if (m_surface->canvas()) { | 285 if (m_surface->canvas()) { |
287 m_surface->canvas()->flush(); | 286 m_surface->canvas()->flush(); |
288 } | 287 } |
289 } | 288 } |
290 | 289 |
291 PassRefPtr<SkColorFilter> ImageBuffer::createColorSpaceFilter(ColorSpace srcColo
rSpace, | |
292 ColorSpace dstColorSpace) | |
293 { | |
294 const uint8_t* lut = ColorSpaceUtilities::getConversionLUT(dstColorSpace, sr
cColorSpace); | |
295 if (!lut) | |
296 return nullptr; | |
297 | |
298 return adoptRef(SkTableColorFilter::CreateARGB(0, lut, lut, lut)); | |
299 } | |
300 | |
301 bool ImageBuffer::getImageData(Multiply multiplied, const IntRect& rect, WTF::Ar
rayBufferContents& contents) const | 290 bool ImageBuffer::getImageData(Multiply multiplied, const IntRect& rect, WTF::Ar
rayBufferContents& contents) const |
302 { | 291 { |
303 Checked<int, RecordOverflow> dataSize = 4; | 292 Checked<int, RecordOverflow> dataSize = 4; |
304 dataSize *= rect.width(); | 293 dataSize *= rect.width(); |
305 dataSize *= rect.height(); | 294 dataSize *= rect.height(); |
306 if (dataSize.hasOverflowed()) | 295 if (dataSize.hasOverflowed()) |
307 return false; | 296 return false; |
308 | 297 |
309 if (!isSurfaceValid()) { | 298 if (!isSurfaceValid()) { |
310 WTF::ArrayBufferContents result(rect.width() * rect.height(), 4, WTF::Ar
rayBufferContents::ZeroInitialize); | 299 WTF::ArrayBufferContents result(rect.width() * rect.height(), 4, WTF::Ar
rayBufferContents::ZeroInitialize); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); | 396 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); |
408 | 397 |
409 Vector<char> encodedImage; | 398 Vector<char> encodedImage; |
410 if (!encodeImage(*this, mimeType, quality, &encodedImage)) | 399 if (!encodeImage(*this, mimeType, quality, &encodedImage)) |
411 return "data:,"; | 400 return "data:,"; |
412 | 401 |
413 return "data:" + mimeType + ";base64," + base64Encode(encodedImage); | 402 return "data:" + mimeType + ";base64," + base64Encode(encodedImage); |
414 } | 403 } |
415 | 404 |
416 } // namespace blink | 405 } // namespace blink |
OLD | NEW |