| 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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 OwnPtr<WebGraphicsContext3DProvider> provider = adoptPtr(Platform::current()
->createSharedOffscreenGraphicsContext3DProvider()); | 203 OwnPtr<WebGraphicsContext3DProvider> provider = adoptPtr(Platform::current()
->createSharedOffscreenGraphicsContext3DProvider()); |
| 204 if (!provider) | 204 if (!provider) |
| 205 return false; | 205 return false; |
| 206 WebGraphicsContext3D* sharedContext = provider->context3d(); | 206 WebGraphicsContext3D* sharedContext = provider->context3d(); |
| 207 gpu::gles2::GLES2Interface* sharedGL = provider->contextGL(); | 207 gpu::gles2::GLES2Interface* sharedGL = provider->contextGL(); |
| 208 | 208 |
| 209 OwnPtr<WebExternalTextureMailbox> mailbox = adoptPtr(new WebExternalTextureM
ailbox); | 209 OwnPtr<WebExternalTextureMailbox> mailbox = adoptPtr(new WebExternalTextureM
ailbox); |
| 210 mailbox->textureSize = WebSize(textureImage->width(), textureImage->height()
); | 210 mailbox->textureSize = WebSize(textureImage->width(), textureImage->height()
); |
| 211 | 211 |
| 212 // 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 |
| 213 sharedContext->genMailboxCHROMIUM(mailbox->name); | 213 sharedGL->GenMailboxCHROMIUM(mailbox->name); |
| 214 sharedContext->produceTextureDirectCHROMIUM(textureInfo->fID, textureInfo->f
Target, mailbox->name); | 214 sharedGL->ProduceTextureDirectCHROMIUM(textureInfo->fID, textureInfo->fTarge
t, mailbox->name); |
| 215 const GLuint64 sharedFenceSync = sharedGL->InsertFenceSyncCHROMIUM(); | 215 const GLuint64 sharedFenceSync = sharedGL->InsertFenceSyncCHROMIUM(); |
| 216 sharedContext->flush(); | 216 sharedGL->Flush(); |
| 217 | 217 |
| 218 mailbox->validSyncToken = sharedContext->genSyncTokenCHROMIUM(sharedFenceSyn
c, mailbox->syncToken); | 218 mailbox->validSyncToken = sharedContext->genSyncTokenCHROMIUM(sharedFenceSyn
c, mailbox->syncToken); |
| 219 if (mailbox->validSyncToken) | 219 if (mailbox->validSyncToken) |
| 220 gl->WaitSyncTokenCHROMIUM(mailbox->syncToken); | 220 gl->WaitSyncTokenCHROMIUM(mailbox->syncToken); |
| 221 | 221 |
| 222 Platform3DObject sourceTexture = context->createAndConsumeTextureCHROMIUM(te
xtureInfo->fTarget, mailbox->name); | 222 Platform3DObject sourceTexture = gl->CreateAndConsumeTextureCHROMIUM(texture
Info->fTarget, mailbox->name); |
| 223 | 223 |
| 224 // The canvas is stored in a premultiplied format, so unpremultiply if neces
sary. | 224 // The canvas is stored in a premultiplied format, so unpremultiply if neces
sary. |
| 225 // The canvas is stored in an inverted position, so the flip semantics are r
eversed. | 225 // The canvas is stored in an inverted position, so the flip semantics are r
eversed. |
| 226 context->copyTextureCHROMIUM(sourceTexture, texture, internalFormat, destTyp
e, flipY ? GL_FALSE : GL_TRUE, GL_FALSE, premultiplyAlpha ? GL_FALSE : GL_TRUE); | 226 gl->CopyTextureCHROMIUM(sourceTexture, texture, internalFormat, destType, fl
ipY ? GL_FALSE : GL_TRUE, GL_FALSE, premultiplyAlpha ? GL_FALSE : GL_TRUE); |
| 227 | 227 |
| 228 context->deleteTexture(sourceTexture); | 228 context->deleteTexture(sourceTexture); |
| 229 | 229 |
| 230 const GLuint64 contextFenceSync = gl->InsertFenceSyncCHROMIUM(); | 230 const GLuint64 contextFenceSync = gl->InsertFenceSyncCHROMIUM(); |
| 231 | 231 |
| 232 context->flush(); | 232 gl->Flush(); |
| 233 | 233 |
| 234 WGC3Dbyte syncToken[24]; | 234 WGC3Dbyte syncToken[24]; |
| 235 if (context->genSyncTokenCHROMIUM(contextFenceSync, syncToken)) | 235 if (context->genSyncTokenCHROMIUM(contextFenceSync, syncToken)) |
| 236 sharedGL->WaitSyncTokenCHROMIUM(syncToken); | 236 sharedGL->WaitSyncTokenCHROMIUM(syncToken); |
| 237 | 237 |
| 238 // Undo grContext texture binding changes introduced in this function | 238 // Undo grContext texture binding changes introduced in this function |
| 239 provider->grContext()->resetContext(kTextureBinding_GrGLBackendState); | 239 provider->grContext()->resetContext(kTextureBinding_GrGLBackendState); |
| 240 | 240 |
| 241 return true; | 241 return true; |
| 242 } | 242 } |
| 243 | 243 |
| 244 bool ImageBuffer::copyRenderingResultsFromDrawingBuffer(DrawingBuffer* drawingBu
ffer, SourceDrawingBuffer sourceBuffer) | 244 bool ImageBuffer::copyRenderingResultsFromDrawingBuffer(DrawingBuffer* drawingBu
ffer, SourceDrawingBuffer sourceBuffer) |
| 245 { | 245 { |
| 246 if (!drawingBuffer || !m_surface->isAccelerated()) | 246 if (!drawingBuffer || !m_surface->isAccelerated()) |
| 247 return false; | 247 return false; |
| 248 OwnPtr<WebGraphicsContext3DProvider> provider = adoptPtr(Platform::current()
->createSharedOffscreenGraphicsContext3DProvider()); | 248 OwnPtr<WebGraphicsContext3DProvider> provider = adoptPtr(Platform::current()
->createSharedOffscreenGraphicsContext3DProvider()); |
| 249 if (!provider) | 249 if (!provider) |
| 250 return false; | 250 return false; |
| 251 WebGraphicsContext3D* context3D = provider->context3d(); | 251 WebGraphicsContext3D* context3D = provider->context3d(); |
| 252 gpu::gles2::GLES2Interface* gl = provider->contextGL(); | 252 gpu::gles2::GLES2Interface* gl = provider->contextGL(); |
| 253 Platform3DObject textureId = m_surface->getBackingTextureHandleForOverwrite(
); | 253 Platform3DObject textureId = m_surface->getBackingTextureHandleForOverwrite(
); |
| 254 if (!textureId) | 254 if (!textureId) |
| 255 return false; | 255 return false; |
| 256 | 256 |
| 257 context3D->flush(); | 257 gl->Flush(); |
| 258 | 258 |
| 259 return drawingBuffer->copyToPlatformTexture(context3D, gl, textureId, GL_RGB
A, | 259 return drawingBuffer->copyToPlatformTexture(context3D, gl, textureId, GL_RGB
A, |
| 260 GL_UNSIGNED_BYTE, 0, true, false, sourceBuffer); | 260 GL_UNSIGNED_BYTE, 0, true, false, sourceBuffer); |
| 261 } | 261 } |
| 262 | 262 |
| 263 void ImageBuffer::draw(GraphicsContext& context, const FloatRect& destRect, cons
t FloatRect* srcPtr, SkXfermode::Mode op) | 263 void ImageBuffer::draw(GraphicsContext& context, const FloatRect& destRect, cons
t FloatRect* srcPtr, SkXfermode::Mode op) |
| 264 { | 264 { |
| 265 if (!isSurfaceValid()) | 265 if (!isSurfaceValid()) |
| 266 return; | 266 return; |
| 267 | 267 |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); | 405 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); |
| 406 | 406 |
| 407 Vector<unsigned char> result; | 407 Vector<unsigned char> result; |
| 408 if (!encodeImage(mimeType, quality, &result)) | 408 if (!encodeImage(mimeType, quality, &result)) |
| 409 return "data:,"; | 409 return "data:,"; |
| 410 | 410 |
| 411 return "data:" + mimeType + ";base64," + base64Encode(result); | 411 return "data:" + mimeType + ";base64," + base64Encode(result); |
| 412 } | 412 } |
| 413 | 413 |
| 414 } // namespace blink | 414 } // namespace blink |
| OLD | NEW |