| 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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 m_snapshotState = DrawnToAfterSnapshot; | 193 m_snapshotState = DrawnToAfterSnapshot; |
| 194 m_surface->didDraw(rect); | 194 m_surface->didDraw(rect); |
| 195 } | 195 } |
| 196 | 196 |
| 197 WebLayer* ImageBuffer::platformLayer() const { | 197 WebLayer* ImageBuffer::platformLayer() const { |
| 198 return m_surface->layer(); | 198 return m_surface->layer(); |
| 199 } | 199 } |
| 200 | 200 |
| 201 bool ImageBuffer::copyToPlatformTexture(SnapshotReason reason, | 201 bool ImageBuffer::copyToPlatformTexture(SnapshotReason reason, |
| 202 gpu::gles2::GLES2Interface* gl, | 202 gpu::gles2::GLES2Interface* gl, |
| 203 GLenum target, |
| 203 GLuint texture, | 204 GLuint texture, |
| 204 GLenum internalFormat, | |
| 205 GLenum destType, | |
| 206 GLint level, | |
| 207 bool premultiplyAlpha, | 205 bool premultiplyAlpha, |
| 208 bool flipY, | 206 bool flipY, |
| 209 const IntPoint& destPoint, | 207 const IntPoint& destPoint, |
| 210 const IntRect& sourceSubRectangle) { | 208 const IntRect& sourceSubRectangle) { |
| 211 if (!Extensions3DUtil::canUseCopyTextureCHROMIUM( | 209 if (!Extensions3DUtil::canUseCopyTextureCHROMIUM(target)) |
| 212 GL_TEXTURE_2D, internalFormat, destType, level)) | |
| 213 return false; | 210 return false; |
| 214 | 211 |
| 215 if (!isSurfaceValid()) | 212 if (!isSurfaceValid()) |
| 216 return false; | 213 return false; |
| 217 | 214 |
| 218 sk_sp<const SkImage> textureImage = | 215 sk_sp<const SkImage> textureImage = |
| 219 m_surface->newImageSnapshot(PreferAcceleration, reason); | 216 m_surface->newImageSnapshot(PreferAcceleration, reason); |
| 220 if (!textureImage) | 217 if (!textureImage) |
| 221 return false; | 218 return false; |
| 222 | 219 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 253 | 250 |
| 254 GLuint sourceTexture = | 251 GLuint sourceTexture = |
| 255 gl->CreateAndConsumeTextureCHROMIUM(textureInfo->fTarget, mailbox.name); | 252 gl->CreateAndConsumeTextureCHROMIUM(textureInfo->fTarget, mailbox.name); |
| 256 | 253 |
| 257 // The canvas is stored in a premultiplied format, so unpremultiply if | 254 // The canvas is stored in a premultiplied format, so unpremultiply if |
| 258 // necessary. The canvas is also stored in an inverted position, so the flip | 255 // necessary. The canvas is also stored in an inverted position, so the flip |
| 259 // semantics are reversed. | 256 // semantics are reversed. |
| 260 // It is expected that callers of this method have already allocated | 257 // It is expected that callers of this method have already allocated |
| 261 // the platform texture with the appropriate size. | 258 // the platform texture with the appropriate size. |
| 262 gl->CopySubTextureCHROMIUM( | 259 gl->CopySubTextureCHROMIUM( |
| 263 sourceTexture, 0, GL_TEXTURE_2D, texture, 0, destPoint.x(), destPoint.y(), | 260 sourceTexture, 0, target, texture, 0, destPoint.x(), destPoint.y(), |
| 264 sourceSubRectangle.x(), sourceSubRectangle.y(), | 261 sourceSubRectangle.x(), sourceSubRectangle.y(), |
| 265 sourceSubRectangle.width(), sourceSubRectangle.height(), | 262 sourceSubRectangle.width(), sourceSubRectangle.height(), |
| 266 flipY ? GL_FALSE : GL_TRUE, GL_FALSE, | 263 flipY ? GL_FALSE : GL_TRUE, GL_FALSE, |
| 267 premultiplyAlpha ? GL_FALSE : GL_TRUE); | 264 premultiplyAlpha ? GL_FALSE : GL_TRUE); |
| 268 | 265 |
| 269 gl->DeleteTextures(1, &sourceTexture); | 266 gl->DeleteTextures(1, &sourceTexture); |
| 270 | 267 |
| 271 const GLuint64 contextFenceSync = gl->InsertFenceSyncCHROMIUM(); | 268 const GLuint64 contextFenceSync = gl->InsertFenceSyncCHROMIUM(); |
| 272 | 269 |
| 273 gl->Flush(); | 270 gl->Flush(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 297 if (!provider) | 294 if (!provider) |
| 298 return false; | 295 return false; |
| 299 gpu::gles2::GLES2Interface* gl = provider->contextGL(); | 296 gpu::gles2::GLES2Interface* gl = provider->contextGL(); |
| 300 GLuint textureId = m_surface->getBackingTextureHandleForOverwrite(); | 297 GLuint textureId = m_surface->getBackingTextureHandleForOverwrite(); |
| 301 if (!textureId) | 298 if (!textureId) |
| 302 return false; | 299 return false; |
| 303 | 300 |
| 304 gl->Flush(); | 301 gl->Flush(); |
| 305 | 302 |
| 306 return drawingBuffer->copyToPlatformTexture( | 303 return drawingBuffer->copyToPlatformTexture( |
| 307 gl, textureId, GL_RGBA, GL_UNSIGNED_BYTE, 0, true, false, IntPoint(0, 0), | 304 gl, GL_TEXTURE_2D, textureId, true, false, IntPoint(0, 0), |
| 308 IntRect(IntPoint(0, 0), drawingBuffer->size()), sourceBuffer); | 305 IntRect(IntPoint(0, 0), drawingBuffer->size()), sourceBuffer); |
| 309 } | 306 } |
| 310 | 307 |
| 311 void ImageBuffer::draw(GraphicsContext& context, | 308 void ImageBuffer::draw(GraphicsContext& context, |
| 312 const FloatRect& destRect, | 309 const FloatRect& destRect, |
| 313 const FloatRect* srcPtr, | 310 const FloatRect* srcPtr, |
| 314 SkBlendMode op) { | 311 SkBlendMode op) { |
| 315 if (!isSurfaceValid()) | 312 if (!isSurfaceValid()) |
| 316 return; | 313 return; |
| 317 | 314 |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 DCHECK(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); | 603 DCHECK(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); |
| 607 | 604 |
| 608 Vector<unsigned char> result; | 605 Vector<unsigned char> result; |
| 609 if (!encodeImage(mimeType, quality, &result)) | 606 if (!encodeImage(mimeType, quality, &result)) |
| 610 return "data:,"; | 607 return "data:,"; |
| 611 | 608 |
| 612 return "data:" + mimeType + ";base64," + base64Encode(result); | 609 return "data:" + mimeType + ";base64," + base64Encode(result); |
| 613 } | 610 } |
| 614 | 611 |
| 615 } // namespace blink | 612 } // namespace blink |
| OLD | NEW |