| 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 18 matching lines...) Expand all Loading... |
| 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 "config.h" | 33 #include "config.h" |
| 34 #include "platform/graphics/ImageBuffer.h" | 34 #include "platform/graphics/ImageBuffer.h" |
| 35 | 35 |
| 36 #include "platform/MIMETypeRegistry.h" | 36 #include "platform/MIMETypeRegistry.h" |
| 37 #include "platform/geometry/IntRect.h" | 37 #include "platform/geometry/IntRect.h" |
| 38 #include "platform/graphics/BitmapImage.h" | 38 #include "platform/graphics/BitmapImage.h" |
| 39 #include "platform/graphics/Extensions3D.h" | |
| 40 #include "platform/graphics/GraphicsContext.h" | 39 #include "platform/graphics/GraphicsContext.h" |
| 41 #include "platform/graphics/GraphicsContext3D.h" | 40 #include "platform/graphics/GraphicsContext3D.h" |
| 42 #include "platform/graphics/UnacceleratedImageBufferSurface.h" | 41 #include "platform/graphics/UnacceleratedImageBufferSurface.h" |
| 43 #include "platform/graphics/gpu/DrawingBuffer.h" | 42 #include "platform/graphics/gpu/DrawingBuffer.h" |
| 44 #include "platform/graphics/gpu/SharedGraphicsContext3D.h" | 43 #include "platform/graphics/gpu/SharedGraphicsContext3D.h" |
| 45 #include "platform/graphics/skia/NativeImageSkia.h" | 44 #include "platform/graphics/skia/NativeImageSkia.h" |
| 46 #include "platform/graphics/skia/SkiaUtils.h" | 45 #include "platform/graphics/skia/SkiaUtils.h" |
| 47 #include "platform/image-encoders/skia/JPEGImageEncoder.h" | 46 #include "platform/image-encoders/skia/JPEGImageEncoder.h" |
| 48 #include "platform/image-encoders/skia/PNGImageEncoder.h" | 47 #include "platform/image-encoders/skia/PNGImageEncoder.h" |
| 49 #include "platform/image-encoders/skia/WEBPImageEncoder.h" | 48 #include "platform/image-encoders/skia/WEBPImageEncoder.h" |
| 50 #include "public/platform/Platform.h" | 49 #include "public/platform/Platform.h" |
| 50 #include "public/platform/WebGraphicsContext3D.h" |
| 51 #include "third_party/skia/include/effects/SkTableColorFilter.h" | 51 #include "third_party/skia/include/effects/SkTableColorFilter.h" |
| 52 #include "wtf/MathExtras.h" | 52 #include "wtf/MathExtras.h" |
| 53 #include "wtf/text/Base64.h" | 53 #include "wtf/text/Base64.h" |
| 54 #include "wtf/text/WTFString.h" | 54 #include "wtf/text/WTFString.h" |
| 55 | 55 |
| 56 using namespace std; | 56 using namespace std; |
| 57 | 57 |
| 58 namespace WebCore { | 58 namespace WebCore { |
| 59 | 59 |
| 60 PassOwnPtr<ImageBuffer> ImageBuffer::create(PassOwnPtr<ImageBufferSurface> surfa
ce) | 60 PassOwnPtr<ImageBuffer> ImageBuffer::create(PassOwnPtr<ImageBufferSurface> surfa
ce) |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 } | 127 } |
| 128 | 128 |
| 129 bool ImageBuffer::copyToPlatformTexture(GraphicsContext3D& context, Platform3DOb
ject texture, GLenum internalFormat, GLenum destType, GLint level, bool premulti
plyAlpha, bool flipY) | 129 bool ImageBuffer::copyToPlatformTexture(GraphicsContext3D& context, Platform3DOb
ject texture, GLenum internalFormat, GLenum destType, GLint level, bool premulti
plyAlpha, bool flipY) |
| 130 { | 130 { |
| 131 if (!m_surface->isAccelerated() || !platformLayer() || !isValid()) | 131 if (!m_surface->isAccelerated() || !platformLayer() || !isValid()) |
| 132 return false; | 132 return false; |
| 133 | 133 |
| 134 if (!context.makeContextCurrent()) | 134 if (!context.makeContextCurrent()) |
| 135 return false; | 135 return false; |
| 136 | 136 |
| 137 Extensions3D* extensions = context.extensions(); | 137 if (!context.supportsExtension("GL_CHROMIUM_copy_texture") || !context.suppo
rtsExtension("GL_CHROMIUM_flipy") |
| 138 if (!extensions->supports("GL_CHROMIUM_copy_texture") || !extensions->suppor
ts("GL_CHROMIUM_flipy") | 138 || !context.canUseCopyTextureCHROMIUM(internalFormat, destType, level)) |
| 139 || !extensions->canUseCopyTextureCHROMIUM(internalFormat, destType, leve
l)) | |
| 140 return false; | 139 return false; |
| 141 | 140 |
| 142 // The canvas is stored in a premultiplied format, so unpremultiply if neces
sary. | 141 // The canvas is stored in a premultiplied format, so unpremultiply if neces
sary. |
| 143 context.pixelStorei(Extensions3D::UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM, !prem
ultiplyAlpha); | 142 context.pixelStorei(GC3D_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM, !premultiplyAl
pha); |
| 144 | 143 |
| 145 // The canvas is stored in an inverted position, so the flip semantics are r
eversed. | 144 // The canvas is stored in an inverted position, so the flip semantics are r
eversed. |
| 146 context.pixelStorei(Extensions3D::UNPACK_FLIP_Y_CHROMIUM, !flipY); | 145 context.pixelStorei(GC3D_UNPACK_FLIP_Y_CHROMIUM, !flipY); |
| 147 extensions->copyTextureCHROMIUM(GL_TEXTURE_2D, getBackingTexture(), texture,
level, internalFormat, destType); | 146 context.webContext()->copyTextureCHROMIUM(GL_TEXTURE_2D, getBackingTexture()
, texture, level, internalFormat, destType); |
| 148 | 147 |
| 149 context.pixelStorei(Extensions3D::UNPACK_FLIP_Y_CHROMIUM, false); | 148 context.pixelStorei(GC3D_UNPACK_FLIP_Y_CHROMIUM, false); |
| 150 context.pixelStorei(Extensions3D::UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM, false
); | 149 context.pixelStorei(GC3D_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM, false); |
| 151 context.flush(); | 150 context.flush(); |
| 152 return true; | 151 return true; |
| 153 } | 152 } |
| 154 | 153 |
| 155 static bool drawNeedsCopy(GraphicsContext* src, GraphicsContext* dst) | 154 static bool drawNeedsCopy(GraphicsContext* src, GraphicsContext* dst) |
| 156 { | 155 { |
| 157 ASSERT(dst); | 156 ASSERT(dst); |
| 158 return (src == dst); | 157 return (src == dst); |
| 159 } | 158 } |
| 160 | 159 |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 if (!encodeImage(imageData, mimeType, quality, &encodedImage)) | 438 if (!encodeImage(imageData, mimeType, quality, &encodedImage)) |
| 440 return "data:,"; | 439 return "data:,"; |
| 441 | 440 |
| 442 Vector<char> base64Data; | 441 Vector<char> base64Data; |
| 443 base64Encode(encodedImage, base64Data); | 442 base64Encode(encodedImage, base64Data); |
| 444 | 443 |
| 445 return "data:" + mimeType + ";base64," + base64Data; | 444 return "data:" + mimeType + ";base64," + base64Data; |
| 446 } | 445 } |
| 447 | 446 |
| 448 } // namespace WebCore | 447 } // namespace WebCore |
| OLD | NEW |