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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 if (!provider) | 163 if (!provider) |
164 return false; | 164 return false; |
165 blink::WebGraphicsContext3D* sharedContext = provider->context3d(); | 165 blink::WebGraphicsContext3D* sharedContext = provider->context3d(); |
166 if (!sharedContext || !sharedContext->makeContextCurrent()) | 166 if (!sharedContext || !sharedContext->makeContextCurrent()) |
167 return false; | 167 return false; |
168 | 168 |
169 OwnPtr<blink::WebExternalTextureMailbox> mailbox = adoptPtr(new blink::WebEx
ternalTextureMailbox); | 169 OwnPtr<blink::WebExternalTextureMailbox> mailbox = adoptPtr(new blink::WebEx
ternalTextureMailbox); |
170 | 170 |
171 // Contexts may be in a different share group. We must transfer the texture
through a mailbox first | 171 // Contexts may be in a different share group. We must transfer the texture
through a mailbox first |
172 sharedContext->genMailboxCHROMIUM(mailbox->name); | 172 sharedContext->genMailboxCHROMIUM(mailbox->name); |
173 sharedContext->bindTexture(GL_TEXTURE_2D, getBackingTexture()); | 173 sharedContext->produceTextureDirectCHROMIUM(getBackingTexture(), GL_TEXTURE_
2D, mailbox->name); |
174 sharedContext->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox->name); | |
175 sharedContext->flush(); | 174 sharedContext->flush(); |
176 | 175 |
177 mailbox->syncPoint = sharedContext->insertSyncPoint(); | 176 mailbox->syncPoint = sharedContext->insertSyncPoint(); |
178 | 177 |
179 if (!context->makeContextCurrent()) | 178 if (!context->makeContextCurrent()) |
180 return false; | 179 return false; |
181 | 180 |
182 Platform3DObject sourceTexture = context->createTexture(); | |
183 | |
184 context->bindTexture(GL_TEXTURE_2D, sourceTexture); | |
185 | |
186 context->waitSyncPoint(mailbox->syncPoint); | 181 context->waitSyncPoint(mailbox->syncPoint); |
187 context->consumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox->name); | 182 Platform3DObject sourceTexture = context->createAndConsumeTextureCHROMIUM(GL
_TEXTURE_2D, mailbox->name); |
188 | 183 |
189 // The canvas is stored in a premultiplied format, so unpremultiply if neces
sary. | 184 // The canvas is stored in a premultiplied format, so unpremultiply if neces
sary. |
190 context->pixelStorei(GC3D_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM, !premultiplyA
lpha); | 185 context->pixelStorei(GC3D_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM, !premultiplyA
lpha); |
191 | 186 |
192 // The canvas is stored in an inverted position, so the flip semantics are r
eversed. | 187 // The canvas is stored in an inverted position, so the flip semantics are r
eversed. |
193 context->pixelStorei(GC3D_UNPACK_FLIP_Y_CHROMIUM, !flipY); | 188 context->pixelStorei(GC3D_UNPACK_FLIP_Y_CHROMIUM, !flipY); |
194 context->copyTextureCHROMIUM(GL_TEXTURE_2D, sourceTexture, texture, level, i
nternalFormat, destType); | 189 context->copyTextureCHROMIUM(GL_TEXTURE_2D, sourceTexture, texture, level, i
nternalFormat, destType); |
195 | 190 |
196 context->pixelStorei(GC3D_UNPACK_FLIP_Y_CHROMIUM, false); | 191 context->pixelStorei(GC3D_UNPACK_FLIP_Y_CHROMIUM, false); |
197 context->pixelStorei(GC3D_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM, false); | 192 context->pixelStorei(GC3D_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM, false); |
198 | 193 |
199 context->bindTexture(GL_TEXTURE_2D, 0); | |
200 context->deleteTexture(sourceTexture); | 194 context->deleteTexture(sourceTexture); |
201 | 195 |
202 context->flush(); | 196 context->flush(); |
203 sharedContext->waitSyncPoint(context->insertSyncPoint()); | 197 sharedContext->waitSyncPoint(context->insertSyncPoint()); |
204 | 198 |
205 // Undo grContext texture binding changes introduced in this function | 199 // Undo grContext texture binding changes introduced in this function |
206 provider->grContext()->resetContext(kTextureBinding_GrGLBackendState); | 200 provider->grContext()->resetContext(kTextureBinding_GrGLBackendState); |
207 | 201 |
208 return true; | 202 return true; |
209 } | 203 } |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 if (!encodeImage(imageData, mimeType, quality, &encodedImage)) | 420 if (!encodeImage(imageData, mimeType, quality, &encodedImage)) |
427 return "data:,"; | 421 return "data:,"; |
428 | 422 |
429 Vector<char> base64Data; | 423 Vector<char> base64Data; |
430 base64Encode(encodedImage, base64Data); | 424 base64Encode(encodedImage, base64Data); |
431 | 425 |
432 return "data:" + mimeType + ";base64," + base64Data; | 426 return "data:" + mimeType + ";base64," + base64Data; |
433 } | 427 } |
434 | 428 |
435 } // namespace WebCore | 429 } // namespace WebCore |
OLD | NEW |