| 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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 if (m_snapshotState == DidAcquireSnapshot) | 171 if (m_snapshotState == DidAcquireSnapshot) |
| 172 m_snapshotState = DrawnToAfterSnapshot; | 172 m_snapshotState = DrawnToAfterSnapshot; |
| 173 m_surface->didDraw(rect); | 173 m_surface->didDraw(rect); |
| 174 } | 174 } |
| 175 | 175 |
| 176 WebLayer* ImageBuffer::platformLayer() const | 176 WebLayer* ImageBuffer::platformLayer() const |
| 177 { | 177 { |
| 178 return m_surface->layer(); | 178 return m_surface->layer(); |
| 179 } | 179 } |
| 180 | 180 |
| 181 bool ImageBuffer::copyToPlatformTexture(WebGraphicsContext3D* context, Platform3
DObject texture, GLenum internalFormat, GLenum destType, GLint level, bool premu
ltiplyAlpha, bool flipY) | 181 bool ImageBuffer::copyToPlatformTexture(WebGraphicsContext3D* context, GLenum ta
rget, Platform3DObject texture, |
| 182 GLenum internalFormat, GLenum destType, GLint level, bool premultiplyAlpha,
bool flipY) |
| 182 { | 183 { |
| 183 if (!Extensions3DUtil::canUseCopyTextureCHROMIUM(GL_TEXTURE_2D, internalForm
at, destType, level)) | 184 return copyToPlatformTextureInternal(true, context, target, texture, interna
lFormat, |
| 185 destType, level, 0, 0, 0, 0, premultiplyAlpha, flipY); |
| 186 } |
| 187 |
| 188 bool ImageBuffer::copySubToPlatformTexture(WebGraphicsContext3D* context, GLenum
target, Platform3DObject texture, |
| 189 GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, bo
ol premultiplyAlpha, bool flipY) |
| 190 { |
| 191 return copyToPlatformTextureInternal(false, context, target, texture, GL_FAL
SE, GL_FALSE, level, |
| 192 xoffset, yoffset, width, height, premultiplyAlpha, flipY); |
| 193 } |
| 194 |
| 195 bool ImageBuffer::copyToPlatformTextureInternal(bool isFullCopy, WebGraphicsCont
ext3D* context, GLenum target, |
| 196 Platform3DObject texture, GLenum internalFormat, GLenum destType, GLint leve
l, GLint xoffset, GLint yoffset, |
| 197 GLsizei width, GLsizei height, bool premultiplyAlpha, bool flipY) |
| 198 { |
| 199 if (!Extensions3DUtil::canUseCopyTextureCHROMIUM(target, internalFormat, des
tType, level)) |
| 184 return false; | 200 return false; |
| 185 | 201 |
| 186 if (!isSurfaceValid()) | 202 if (!isSurfaceValid()) |
| 187 return false; | 203 return false; |
| 188 | 204 |
| 189 RefPtr<const SkImage> textureImage = m_surface->newImageSnapshot(PreferAccel
eration); | 205 RefPtr<const SkImage> textureImage = m_surface->newImageSnapshot(PreferAccel
eration); |
| 190 if (!textureImage) | 206 if (!textureImage) |
| 191 return false; | 207 return false; |
| 192 | 208 |
| 193 if (!m_surface->isAccelerated()) | 209 if (!m_surface->isAccelerated()) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 212 // Contexts may be in a different share group. We must transfer the texture
through a mailbox first | 228 // Contexts may be in a different share group. We must transfer the texture
through a mailbox first |
| 213 sharedContext->genMailboxCHROMIUM(mailbox->name); | 229 sharedContext->genMailboxCHROMIUM(mailbox->name); |
| 214 sharedContext->produceTextureDirectCHROMIUM(textureId, GL_TEXTURE_2D, mailbo
x->name); | 230 sharedContext->produceTextureDirectCHROMIUM(textureId, GL_TEXTURE_2D, mailbo
x->name); |
| 215 sharedContext->flush(); | 231 sharedContext->flush(); |
| 216 | 232 |
| 217 mailbox->syncPoint = sharedContext->insertSyncPoint(); | 233 mailbox->syncPoint = sharedContext->insertSyncPoint(); |
| 218 | 234 |
| 219 context->waitSyncPoint(mailbox->syncPoint); | 235 context->waitSyncPoint(mailbox->syncPoint); |
| 220 Platform3DObject sourceTexture = context->createAndConsumeTextureCHROMIUM(GL
_TEXTURE_2D, mailbox->name); | 236 Platform3DObject sourceTexture = context->createAndConsumeTextureCHROMIUM(GL
_TEXTURE_2D, mailbox->name); |
| 221 | 237 |
| 238 WGC3Dboolean glFlipY = flipY ? GL_FALSE : GL_TRUE; |
| 239 WGC3Dboolean glPremultiplyAlpha = premultiplyAlpha ? GL_FALSE : GL_TRUE; |
| 240 |
| 222 // The canvas is stored in a premultiplied format, so unpremultiply if neces
sary. | 241 // The canvas is stored in a premultiplied format, so unpremultiply if neces
sary. |
| 223 // The canvas is stored in an inverted position, so the flip semantics are r
eversed. | 242 // The canvas is stored in an inverted position, so the flip semantics are r
eversed. |
| 224 context->copyTextureCHROMIUM(GL_TEXTURE_2D, sourceTexture, texture, internal
Format, destType, flipY ? GL_FALSE : GL_TRUE, GL_FALSE, premultiplyAlpha ? GL_FA
LSE : GL_TRUE); | 243 if (isFullCopy) { |
| 244 context->copyTextureCHROMIUM(target, sourceTexture, texture, internalFor
mat, destType, glFlipY, GL_FALSE, glPremultiplyAlpha); |
| 245 } else { |
| 246 context->copySubTextureCHROMIUM(target, sourceTexture, texture, xoffset,
yoffset, 0, 0, width, height, glFlipY, GL_FALSE, glPremultiplyAlpha); |
| 247 } |
| 225 | 248 |
| 226 context->deleteTexture(sourceTexture); | 249 context->deleteTexture(sourceTexture); |
| 227 | 250 |
| 228 context->flush(); | 251 context->flush(); |
| 229 sharedContext->waitSyncPoint(context->insertSyncPoint()); | 252 sharedContext->waitSyncPoint(context->insertSyncPoint()); |
| 230 | 253 |
| 231 // Undo grContext texture binding changes introduced in this function | 254 // Undo grContext texture binding changes introduced in this function |
| 232 provider->grContext()->resetContext(kTextureBinding_GrGLBackendState); | 255 provider->grContext()->resetContext(kTextureBinding_GrGLBackendState); |
| 233 | 256 |
| 234 return true; | 257 return true; |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); | 399 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); |
| 377 | 400 |
| 378 Vector<char> encodedImage; | 401 Vector<char> encodedImage; |
| 379 if (!encodeImage(mimeType, quality, &encodedImage)) | 402 if (!encodeImage(mimeType, quality, &encodedImage)) |
| 380 return "data:,"; | 403 return "data:,"; |
| 381 | 404 |
| 382 return "data:" + mimeType + ";base64," + base64Encode(encodedImage); | 405 return "data:" + mimeType + ";base64," + base64Encode(encodedImage); |
| 383 } | 406 } |
| 384 | 407 |
| 385 } // namespace blink | 408 } // namespace blink |
| OLD | NEW |