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, GLenum ta
rget, Platform3DObject texture, | 181 bool ImageBuffer::copyToPlatformTexture(WebGraphicsContext3D* context, Platform3
DObject texture, GLenum internalFormat, GLenum destType, GLint level, bool premu
ltiplyAlpha, bool flipY) |
182 GLenum internalFormat, GLenum destType, GLint level, bool premultiplyAlpha,
bool flipY) | |
183 { | 182 { |
184 return copyToPlatformTextureInternal(true, context, target, texture, interna
lFormat, | 183 if (!Extensions3DUtil::canUseCopyTextureCHROMIUM(GL_TEXTURE_2D, internalForm
at, destType, level)) |
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)) | |
200 return false; | 184 return false; |
201 | 185 |
202 if (!isSurfaceValid()) | 186 if (!isSurfaceValid()) |
203 return false; | 187 return false; |
204 | 188 |
205 RefPtr<const SkImage> textureImage = m_surface->newImageSnapshot(PreferAccel
eration); | 189 RefPtr<const SkImage> textureImage = m_surface->newImageSnapshot(PreferAccel
eration); |
206 if (!textureImage) | 190 if (!textureImage) |
207 return false; | 191 return false; |
208 | 192 |
209 if (!m_surface->isAccelerated()) | 193 if (!m_surface->isAccelerated()) |
(...skipping 18 matching lines...) Expand all Loading... |
228 // Contexts may be in a different share group. We must transfer the texture
through a mailbox first | 212 // Contexts may be in a different share group. We must transfer the texture
through a mailbox first |
229 sharedContext->genMailboxCHROMIUM(mailbox->name); | 213 sharedContext->genMailboxCHROMIUM(mailbox->name); |
230 sharedContext->produceTextureDirectCHROMIUM(textureId, GL_TEXTURE_2D, mailbo
x->name); | 214 sharedContext->produceTextureDirectCHROMIUM(textureId, GL_TEXTURE_2D, mailbo
x->name); |
231 sharedContext->flush(); | 215 sharedContext->flush(); |
232 | 216 |
233 mailbox->syncPoint = sharedContext->insertSyncPoint(); | 217 mailbox->syncPoint = sharedContext->insertSyncPoint(); |
234 | 218 |
235 context->waitSyncPoint(mailbox->syncPoint); | 219 context->waitSyncPoint(mailbox->syncPoint); |
236 Platform3DObject sourceTexture = context->createAndConsumeTextureCHROMIUM(GL
_TEXTURE_2D, mailbox->name); | 220 Platform3DObject sourceTexture = context->createAndConsumeTextureCHROMIUM(GL
_TEXTURE_2D, mailbox->name); |
237 | 221 |
238 WGC3Dboolean glFlipY = flipY ? GL_FALSE : GL_TRUE; | |
239 WGC3Dboolean glPremultiplyAlpha = premultiplyAlpha ? GL_FALSE : GL_TRUE; | |
240 | |
241 // The canvas is stored in a premultiplied format, so unpremultiply if neces
sary. | 222 // The canvas is stored in a premultiplied format, so unpremultiply if neces
sary. |
242 // The canvas is stored in an inverted position, so the flip semantics are r
eversed. | 223 // The canvas is stored in an inverted position, so the flip semantics are r
eversed. |
243 if (isFullCopy) { | 224 context->copyTextureCHROMIUM(GL_TEXTURE_2D, sourceTexture, texture, internal
Format, destType, flipY ? GL_FALSE : GL_TRUE, GL_FALSE, premultiplyAlpha ? GL_FA
LSE : GL_TRUE); |
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 } | |
248 | 225 |
249 context->deleteTexture(sourceTexture); | 226 context->deleteTexture(sourceTexture); |
250 | 227 |
251 context->flush(); | 228 context->flush(); |
252 sharedContext->waitSyncPoint(context->insertSyncPoint()); | 229 sharedContext->waitSyncPoint(context->insertSyncPoint()); |
253 | 230 |
254 // Undo grContext texture binding changes introduced in this function | 231 // Undo grContext texture binding changes introduced in this function |
255 provider->grContext()->resetContext(kTextureBinding_GrGLBackendState); | 232 provider->grContext()->resetContext(kTextureBinding_GrGLBackendState); |
256 | 233 |
257 return true; | 234 return true; |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); | 374 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); |
398 | 375 |
399 Vector<unsigned char> result; | 376 Vector<unsigned char> result; |
400 if (!encodeImage(mimeType, quality, &result)) | 377 if (!encodeImage(mimeType, quality, &result)) |
401 return "data:,"; | 378 return "data:,"; |
402 | 379 |
403 return "data:" + mimeType + ";base64," + base64Encode(result); | 380 return "data:" + mimeType + ";base64," + base64Encode(result); |
404 } | 381 } |
405 | 382 |
406 } // namespace blink | 383 } // namespace blink |
OLD | NEW |