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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 return false; | 200 return false; |
201 WebGraphicsContext3D* sharedContext = provider->context3d(); | 201 WebGraphicsContext3D* sharedContext = provider->context3d(); |
202 if (!sharedContext) | 202 if (!sharedContext) |
203 return false; | 203 return false; |
204 | 204 |
205 OwnPtr<WebExternalTextureMailbox> mailbox = adoptPtr(new WebExternalTextureM
ailbox); | 205 OwnPtr<WebExternalTextureMailbox> mailbox = adoptPtr(new WebExternalTextureM
ailbox); |
206 | 206 |
207 // Contexts may be in a different share group. We must transfer the texture
through a mailbox first | 207 // Contexts may be in a different share group. We must transfer the texture
through a mailbox first |
208 sharedContext->genMailboxCHROMIUM(mailbox->name); | 208 sharedContext->genMailboxCHROMIUM(mailbox->name); |
209 sharedContext->produceTextureDirectCHROMIUM(textureId, GL_TEXTURE_2D, mailbo
x->name); | 209 sharedContext->produceTextureDirectCHROMIUM(textureId, GL_TEXTURE_2D, mailbo
x->name); |
210 const WGC3Duint64 sharedFenceSync = sharedContext->insertFenceSyncCHROMIUM()
; | |
211 sharedContext->flush(); | 210 sharedContext->flush(); |
212 | 211 |
213 mailbox->validSyncToken = sharedContext->genSyncTokenCHROMIUM(sharedFenceSyn
c, mailbox->syncToken); | 212 mailbox->validSyncToken = sharedContext->insertSyncPoint(mailbox->syncToken)
; |
214 if (mailbox->validSyncToken) | 213 if (mailbox->validSyncToken) |
215 context->waitSyncTokenCHROMIUM(mailbox->syncToken); | 214 context->waitSyncToken(mailbox->syncToken); |
216 | 215 |
217 Platform3DObject sourceTexture = context->createAndConsumeTextureCHROMIUM(GL
_TEXTURE_2D, mailbox->name); | 216 Platform3DObject sourceTexture = context->createAndConsumeTextureCHROMIUM(GL
_TEXTURE_2D, mailbox->name); |
218 | 217 |
219 // The canvas is stored in a premultiplied format, so unpremultiply if neces
sary. | 218 // The canvas is stored in a premultiplied format, so unpremultiply if neces
sary. |
220 // The canvas is stored in an inverted position, so the flip semantics are r
eversed. | 219 // The canvas is stored in an inverted position, so the flip semantics are r
eversed. |
221 context->copyTextureCHROMIUM(GL_TEXTURE_2D, sourceTexture, texture, internal
Format, destType, flipY ? GL_FALSE : GL_TRUE, GL_FALSE, premultiplyAlpha ? GL_FA
LSE : GL_TRUE); | 220 context->copyTextureCHROMIUM(GL_TEXTURE_2D, sourceTexture, texture, internal
Format, destType, flipY ? GL_FALSE : GL_TRUE, GL_FALSE, premultiplyAlpha ? GL_FA
LSE : GL_TRUE); |
222 | 221 |
223 context->deleteTexture(sourceTexture); | 222 context->deleteTexture(sourceTexture); |
224 | 223 |
225 const WGC3Duint64 contextFenceSync = context->insertFenceSyncCHROMIUM(); | |
226 | |
227 context->flush(); | 224 context->flush(); |
228 | 225 |
229 WGC3Dbyte syncToken[24]; | 226 WGC3Dbyte syncToken[24]; |
230 if (context->genSyncTokenCHROMIUM(contextFenceSync, syncToken)) | 227 if (context->insertSyncPoint(syncToken)) |
231 sharedContext->waitSyncTokenCHROMIUM(syncToken); | 228 sharedContext->waitSyncToken(syncToken); |
232 | 229 |
233 // Undo grContext texture binding changes introduced in this function | 230 // Undo grContext texture binding changes introduced in this function |
234 provider->grContext()->resetContext(kTextureBinding_GrGLBackendState); | 231 provider->grContext()->resetContext(kTextureBinding_GrGLBackendState); |
235 | 232 |
236 return true; | 233 return true; |
237 } | 234 } |
238 | 235 |
239 bool ImageBuffer::copyRenderingResultsFromDrawingBuffer(DrawingBuffer* drawingBu
ffer, SourceDrawingBuffer sourceBuffer) | 236 bool ImageBuffer::copyRenderingResultsFromDrawingBuffer(DrawingBuffer* drawingBu
ffer, SourceDrawingBuffer sourceBuffer) |
240 { | 237 { |
241 if (!drawingBuffer || !m_surface->isAccelerated()) | 238 if (!drawingBuffer || !m_surface->isAccelerated()) |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); | 373 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); |
377 | 374 |
378 Vector<unsigned char> result; | 375 Vector<unsigned char> result; |
379 if (!encodeImage(mimeType, quality, &result)) | 376 if (!encodeImage(mimeType, quality, &result)) |
380 return "data:,"; | 377 return "data:,"; |
381 | 378 |
382 return "data:" + mimeType + ";base64," + base64Encode(result); | 379 return "data:" + mimeType + ";base64," + base64Encode(result); |
383 } | 380 } |
384 | 381 |
385 } // namespace blink | 382 } // namespace blink |
OLD | NEW |