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 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 if (!extensions->supports("GL_CHROMIUM_copy_texture") || !extensions->suppor
ts("GL_CHROMIUM_flipy") | 269 if (!extensions->supports("GL_CHROMIUM_copy_texture") || !extensions->suppor
ts("GL_CHROMIUM_flipy") |
270 || !extensions->canUseCopyTextureCHROMIUM(internalFormat, destType, leve
l)) | 270 || !extensions->canUseCopyTextureCHROMIUM(internalFormat, destType, leve
l)) |
271 return false; | 271 return false; |
272 | 272 |
273 // The canvas is stored in a premultiplied format, so unpremultiply if neces
sary. | 273 // The canvas is stored in a premultiplied format, so unpremultiply if neces
sary. |
274 context.pixelStorei(Extensions3D::UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM, !prem
ultiplyAlpha); | 274 context.pixelStorei(Extensions3D::UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM, !prem
ultiplyAlpha); |
275 | 275 |
276 // The canvas is stored in an inverted position, so the flip semantics are r
eversed. | 276 // The canvas is stored in an inverted position, so the flip semantics are r
eversed. |
277 context.pixelStorei(Extensions3D::UNPACK_FLIP_Y_CHROMIUM, !flipY); | 277 context.pixelStorei(Extensions3D::UNPACK_FLIP_Y_CHROMIUM, !flipY); |
278 | 278 |
279 extensions->copyTextureCHROMIUM(GraphicsContext3D::TEXTURE_2D, sourceTexture
, texture, level, internalFormat, destType); | 279 extensions->copyTextureCHROMIUM(GL_TEXTURE_2D, sourceTexture, texture, level
, internalFormat, destType); |
280 | 280 |
281 context.pixelStorei(Extensions3D::UNPACK_FLIP_Y_CHROMIUM, false); | 281 context.pixelStorei(Extensions3D::UNPACK_FLIP_Y_CHROMIUM, false); |
282 context.pixelStorei(Extensions3D::UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM, false
); | 282 context.pixelStorei(Extensions3D::UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM, false
); |
283 context.flush(); | 283 context.flush(); |
284 return true; | 284 return true; |
285 } | 285 } |
286 | 286 |
287 static bool drawNeedsCopy(GraphicsContext* src, GraphicsContext* dst) | 287 static bool drawNeedsCopy(GraphicsContext* src, GraphicsContext* dst) |
288 { | 288 { |
289 return (src == dst); | 289 return (src == dst); |
(...skipping 11 matching lines...) Expand all Loading... |
301 | 301 |
302 bool ImageBuffer::copyRenderingResultsFromDrawingBuffer(DrawingBuffer* drawingBu
ffer) | 302 bool ImageBuffer::copyRenderingResultsFromDrawingBuffer(DrawingBuffer* drawingBu
ffer) |
303 { | 303 { |
304 if (!drawingBuffer) | 304 if (!drawingBuffer) |
305 return false; | 305 return false; |
306 RefPtr<GraphicsContext3D> context3D = SharedGraphicsContext3D::get(); | 306 RefPtr<GraphicsContext3D> context3D = SharedGraphicsContext3D::get(); |
307 Platform3DObject tex = getBackingTexture(); | 307 Platform3DObject tex = getBackingTexture(); |
308 if (!context3D || !tex) | 308 if (!context3D || !tex) |
309 return false; | 309 return false; |
310 | 310 |
311 return drawingBuffer->copyToPlatformTexture(*(context3D.get()), tex, Graphic
sContext3D::RGBA, | 311 return drawingBuffer->copyToPlatformTexture(*(context3D.get()), tex, GL_RGBA
, |
312 GraphicsContext3D::UNSIGNED_BYTE, 0, true, false); | 312 GL_UNSIGNED_BYTE, 0, true, false); |
313 } | 313 } |
314 | 314 |
315 void ImageBuffer::draw(GraphicsContext* context, const FloatRect& destRect, cons
t FloatRect& srcRect, | 315 void ImageBuffer::draw(GraphicsContext* context, const FloatRect& destRect, cons
t FloatRect& srcRect, |
316 CompositeOperator op, blink::WebBlendMode blendMode, bool useLowQualityScale
) | 316 CompositeOperator op, blink::WebBlendMode blendMode, bool useLowQualityScale
) |
317 { | 317 { |
318 if (!isValid()) | 318 if (!isValid()) |
319 return; | 319 return; |
320 | 320 |
321 const SkBitmap& bitmap = *m_context->bitmap(); | 321 const SkBitmap& bitmap = *m_context->bitmap(); |
322 RefPtr<Image> image = BitmapImage::create(NativeImageSkia::create(drawNeedsC
opy(m_context.get(), context) ? deepSkBitmapCopy(bitmap) : bitmap)); | 322 RefPtr<Image> image = BitmapImage::create(NativeImageSkia::create(drawNeedsC
opy(m_context.get(), context) ? deepSkBitmapCopy(bitmap) : bitmap)); |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 if (!encodeImage(imageData, mimeType, quality, &encodedImage)) | 566 if (!encodeImage(imageData, mimeType, quality, &encodedImage)) |
567 return "data:,"; | 567 return "data:,"; |
568 | 568 |
569 Vector<char> base64Data; | 569 Vector<char> base64Data; |
570 base64Encode(encodedImage, base64Data); | 570 base64Encode(encodedImage, base64Data); |
571 | 571 |
572 return "data:" + mimeType + ";base64," + base64Data; | 572 return "data:" + mimeType + ";base64," + base64Data; |
573 } | 573 } |
574 | 574 |
575 } // namespace WebCore | 575 } // namespace WebCore |
OLD | NEW |