| 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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 Extensions3D* extensions = context.extensions(); | 137 Extensions3D* extensions = context.extensions(); |
| 138 if (!extensions->supports("GL_CHROMIUM_copy_texture") || !extensions->suppor
ts("GL_CHROMIUM_flipy") | 138 if (!extensions->supports("GL_CHROMIUM_copy_texture") || !extensions->suppor
ts("GL_CHROMIUM_flipy") |
| 139 || !extensions->canUseCopyTextureCHROMIUM(internalFormat, destType, leve
l)) | 139 || !extensions->canUseCopyTextureCHROMIUM(internalFormat, destType, leve
l)) |
| 140 return false; | 140 return false; |
| 141 | 141 |
| 142 // The canvas is stored in a premultiplied format, so unpremultiply if neces
sary. | 142 // The canvas is stored in a premultiplied format, so unpremultiply if neces
sary. |
| 143 context.pixelStorei(Extensions3D::UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM, !prem
ultiplyAlpha); | 143 context.pixelStorei(Extensions3D::UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM, !prem
ultiplyAlpha); |
| 144 | 144 |
| 145 // The canvas is stored in an inverted position, so the flip semantics are r
eversed. | 145 // The canvas is stored in an inverted position, so the flip semantics are r
eversed. |
| 146 context.pixelStorei(Extensions3D::UNPACK_FLIP_Y_CHROMIUM, !flipY); | 146 context.pixelStorei(Extensions3D::UNPACK_FLIP_Y_CHROMIUM, !flipY); |
| 147 extensions->copyTextureCHROMIUM(GraphicsContext3D::TEXTURE_2D, getBackingTex
ture(), texture, level, internalFormat, destType); | 147 extensions->copyTextureCHROMIUM(GL_TEXTURE_2D, getBackingTexture(), texture,
level, internalFormat, destType); |
| 148 | 148 |
| 149 context.pixelStorei(Extensions3D::UNPACK_FLIP_Y_CHROMIUM, false); | 149 context.pixelStorei(Extensions3D::UNPACK_FLIP_Y_CHROMIUM, false); |
| 150 context.pixelStorei(Extensions3D::UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM, false
); | 150 context.pixelStorei(Extensions3D::UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM, false
); |
| 151 context.flush(); | 151 context.flush(); |
| 152 return true; | 152 return true; |
| 153 } | 153 } |
| 154 | 154 |
| 155 static bool drawNeedsCopy(GraphicsContext* src, GraphicsContext* dst) | 155 static bool drawNeedsCopy(GraphicsContext* src, GraphicsContext* dst) |
| 156 { | 156 { |
| 157 ASSERT(dst); | 157 ASSERT(dst); |
| 158 return (src == dst); | 158 return (src == dst); |
| 159 } | 159 } |
| 160 | 160 |
| 161 Platform3DObject ImageBuffer::getBackingTexture() | 161 Platform3DObject ImageBuffer::getBackingTexture() |
| 162 { | 162 { |
| 163 return m_surface->getBackingTexture(); | 163 return m_surface->getBackingTexture(); |
| 164 } | 164 } |
| 165 | 165 |
| 166 bool ImageBuffer::copyRenderingResultsFromDrawingBuffer(DrawingBuffer* drawingBu
ffer) | 166 bool ImageBuffer::copyRenderingResultsFromDrawingBuffer(DrawingBuffer* drawingBu
ffer) |
| 167 { | 167 { |
| 168 if (!drawingBuffer) | 168 if (!drawingBuffer) |
| 169 return false; | 169 return false; |
| 170 RefPtr<GraphicsContext3D> context3D = SharedGraphicsContext3D::get(); | 170 RefPtr<GraphicsContext3D> context3D = SharedGraphicsContext3D::get(); |
| 171 Platform3DObject tex = m_surface->getBackingTexture(); | 171 Platform3DObject tex = m_surface->getBackingTexture(); |
| 172 if (!context3D || !tex) | 172 if (!context3D || !tex) |
| 173 return false; | 173 return false; |
| 174 | 174 |
| 175 return drawingBuffer->copyToPlatformTexture(*(context3D.get()), tex, Graphic
sContext3D::RGBA, | 175 return drawingBuffer->copyToPlatformTexture(*(context3D.get()), tex, GL_RGBA
, |
| 176 GraphicsContext3D::UNSIGNED_BYTE, 0, true, false); | 176 GL_UNSIGNED_BYTE, 0, true, false); |
| 177 } | 177 } |
| 178 | 178 |
| 179 void ImageBuffer::draw(GraphicsContext* context, const FloatRect& destRect, cons
t FloatRect& srcRect, | 179 void ImageBuffer::draw(GraphicsContext* context, const FloatRect& destRect, cons
t FloatRect& srcRect, |
| 180 CompositeOperator op, blink::WebBlendMode blendMode, bool useLowQualityScale
) | 180 CompositeOperator op, blink::WebBlendMode blendMode, bool useLowQualityScale
) |
| 181 { | 181 { |
| 182 if (!isValid()) | 182 if (!isValid()) |
| 183 return; | 183 return; |
| 184 | 184 |
| 185 const SkBitmap& bitmap = m_surface->bitmap(); | 185 const SkBitmap& bitmap = m_surface->bitmap(); |
| 186 RefPtr<Image> image = BitmapImage::create(NativeImageSkia::create(drawNeedsC
opy(m_context.get(), context) ? deepSkBitmapCopy(bitmap) : bitmap)); | 186 RefPtr<Image> image = BitmapImage::create(NativeImageSkia::create(drawNeedsC
opy(m_context.get(), context) ? deepSkBitmapCopy(bitmap) : bitmap)); |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 if (!encodeImage(imageData, mimeType, quality, &encodedImage)) | 431 if (!encodeImage(imageData, mimeType, quality, &encodedImage)) |
| 432 return "data:,"; | 432 return "data:,"; |
| 433 | 433 |
| 434 Vector<char> base64Data; | 434 Vector<char> base64Data; |
| 435 base64Encode(encodedImage, base64Data); | 435 base64Encode(encodedImage, base64Data); |
| 436 | 436 |
| 437 return "data:" + mimeType + ";base64," + base64Data; | 437 return "data:" + mimeType + ";base64," + base64Data; |
| 438 } | 438 } |
| 439 | 439 |
| 440 } // namespace WebCore | 440 } // namespace WebCore |
| OLD | NEW |