| 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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 void ImageBuffer::didDraw(const FloatRect& rect) const { | 201 void ImageBuffer::didDraw(const FloatRect& rect) const { |
| 202 if (m_snapshotState == DidAcquireSnapshot) | 202 if (m_snapshotState == DidAcquireSnapshot) |
| 203 m_snapshotState = DrawnToAfterSnapshot; | 203 m_snapshotState = DrawnToAfterSnapshot; |
| 204 m_surface->didDraw(rect); | 204 m_surface->didDraw(rect); |
| 205 } | 205 } |
| 206 | 206 |
| 207 WebLayer* ImageBuffer::platformLayer() const { | 207 WebLayer* ImageBuffer::platformLayer() const { |
| 208 return m_surface->layer(); | 208 return m_surface->layer(); |
| 209 } | 209 } |
| 210 | 210 |
| 211 bool ImageBuffer::copyToPlatformTexture(gpu::gles2::GLES2Interface* gl, | 211 bool ImageBuffer::copyToPlatformTexture(SnapshotReason reason, |
| 212 gpu::gles2::GLES2Interface* gl, |
| 212 GLuint texture, | 213 GLuint texture, |
| 213 GLenum internalFormat, | 214 GLenum internalFormat, |
| 214 GLenum destType, | 215 GLenum destType, |
| 215 GLint level, | 216 GLint level, |
| 216 bool premultiplyAlpha, | 217 bool premultiplyAlpha, |
| 217 bool flipY, | 218 bool flipY, |
| 218 const IntPoint& destPoint, | 219 const IntPoint& destPoint, |
| 219 const IntRect& sourceSubRectangle) { | 220 const IntRect& sourceSubRectangle) { |
| 220 if (!Extensions3DUtil::canUseCopyTextureCHROMIUM( | 221 if (!Extensions3DUtil::canUseCopyTextureCHROMIUM( |
| 221 GL_TEXTURE_2D, internalFormat, destType, level)) | 222 GL_TEXTURE_2D, internalFormat, destType, level)) |
| 222 return false; | 223 return false; |
| 223 | 224 |
| 224 if (!isSurfaceValid()) | 225 if (!isSurfaceValid()) |
| 225 return false; | 226 return false; |
| 226 | 227 |
| 227 sk_sp<const SkImage> textureImage = m_surface->newImageSnapshot( | 228 sk_sp<const SkImage> textureImage = |
| 228 PreferAcceleration, SnapshotReasonCopyToWebGLTexture); | 229 m_surface->newImageSnapshot(PreferAcceleration, reason); |
| 229 if (!textureImage) | 230 if (!textureImage) |
| 230 return false; | 231 return false; |
| 231 | 232 |
| 232 if (!m_surface->isAccelerated()) | 233 if (!m_surface->isAccelerated()) |
| 233 return false; | 234 return false; |
| 234 | 235 |
| 235 DCHECK(textureImage->isTextureBacked()); // The isAccelerated() check above | 236 DCHECK(textureImage->isTextureBacked()); // The isAccelerated() check above |
| 236 // should guarantee this. | 237 // should guarantee this. |
| 237 // Get the texture ID, flushing pending operations if needed. | 238 // Get the texture ID, flushing pending operations if needed. |
| 238 const GrGLTextureInfo* textureInfo = skia::GrBackendObjectToGrGLTextureInfo( | 239 const GrGLTextureInfo* textureInfo = skia::GrBackendObjectToGrGLTextureInfo( |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); | 563 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); |
| 563 | 564 |
| 564 Vector<unsigned char> result; | 565 Vector<unsigned char> result; |
| 565 if (!encodeImage(mimeType, quality, &result)) | 566 if (!encodeImage(mimeType, quality, &result)) |
| 566 return "data:,"; | 567 return "data:,"; |
| 567 | 568 |
| 568 return "data:" + mimeType + ";base64," + base64Encode(result); | 569 return "data:" + mimeType + ";base64," + base64Encode(result); |
| 569 } | 570 } |
| 570 | 571 |
| 571 } // namespace blink | 572 } // namespace blink |
| OLD | NEW |