| 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 } | 171 } |
| 172 | 172 |
| 173 bool ImageBuffer::copyToPlatformTexture(WebGraphicsContext3D* context, Platform3
DObject texture, GLenum internalFormat, GLenum destType, GLint level, bool premu
ltiplyAlpha, bool flipY) | 173 bool ImageBuffer::copyToPlatformTexture(WebGraphicsContext3D* context, Platform3
DObject texture, GLenum internalFormat, GLenum destType, GLint level, bool premu
ltiplyAlpha, bool flipY) |
| 174 { | 174 { |
| 175 if (!m_surface->isAccelerated() || !isSurfaceValid()) | 175 if (!m_surface->isAccelerated() || !isSurfaceValid()) |
| 176 return false; | 176 return false; |
| 177 | 177 |
| 178 if (!Extensions3DUtil::canUseCopyTextureCHROMIUM(GL_TEXTURE_2D, internalForm
at, destType, level)) | 178 if (!Extensions3DUtil::canUseCopyTextureCHROMIUM(GL_TEXTURE_2D, internalForm
at, destType, level)) |
| 179 return false; | 179 return false; |
| 180 | 180 |
| 181 RefPtr<const SkImage> textureImage = m_surface->getBackingTextureImage(); | 181 RefPtr<const SkImage> textureImage = m_surface->newImageSnapshot(); |
| 182 if (!textureImage) | 182 if (!textureImage) |
| 183 return false; | 183 return false; |
| 184 | 184 |
| 185 ASSERT(textureImage->isTextureBacked()); | 185 ASSERT(textureImage->isTextureBacked()); // isAccelerated() check above shou
ld guarantee this |
| 186 // Get the texture ID, flushing pending operations if needed. | 186 // Get the texture ID, flushing pending operations if needed. |
| 187 Platform3DObject textureId = textureImage->getTextureHandle(true); | 187 Platform3DObject textureId = textureImage->getTextureHandle(true); |
| 188 if (!textureId) | 188 if (!textureId) |
| 189 return false; | 189 return false; |
| 190 | 190 |
| 191 OwnPtr<WebGraphicsContext3DProvider> provider = adoptPtr(Platform::current()
->createSharedOffscreenGraphicsContext3DProvider()); | 191 OwnPtr<WebGraphicsContext3DProvider> provider = adoptPtr(Platform::current()
->createSharedOffscreenGraphicsContext3DProvider()); |
| 192 if (!provider) | 192 if (!provider) |
| 193 return false; | 193 return false; |
| 194 WebGraphicsContext3D* sharedContext = provider->context3d(); | 194 WebGraphicsContext3D* sharedContext = provider->context3d(); |
| 195 if (!sharedContext) | 195 if (!sharedContext) |
| (...skipping 27 matching lines...) Expand all Loading... |
| 223 sharedContext->waitSyncPoint(context->insertSyncPoint()); | 223 sharedContext->waitSyncPoint(context->insertSyncPoint()); |
| 224 | 224 |
| 225 // Undo grContext texture binding changes introduced in this function | 225 // Undo grContext texture binding changes introduced in this function |
| 226 provider->grContext()->resetContext(kTextureBinding_GrGLBackendState); | 226 provider->grContext()->resetContext(kTextureBinding_GrGLBackendState); |
| 227 | 227 |
| 228 return true; | 228 return true; |
| 229 } | 229 } |
| 230 | 230 |
| 231 bool ImageBuffer::copyRenderingResultsFromDrawingBuffer(DrawingBuffer* drawingBu
ffer, SourceDrawingBuffer sourceBuffer) | 231 bool ImageBuffer::copyRenderingResultsFromDrawingBuffer(DrawingBuffer* drawingBu
ffer, SourceDrawingBuffer sourceBuffer) |
| 232 { | 232 { |
| 233 if (!drawingBuffer) | 233 if (!drawingBuffer || !m_surface->isAccelerated()) |
| 234 return false; | 234 return false; |
| 235 OwnPtr<WebGraphicsContext3DProvider> provider = adoptPtr(Platform::current()
->createSharedOffscreenGraphicsContext3DProvider()); | 235 OwnPtr<WebGraphicsContext3DProvider> provider = adoptPtr(Platform::current()
->createSharedOffscreenGraphicsContext3DProvider()); |
| 236 if (!provider) | 236 if (!provider) |
| 237 return false; | 237 return false; |
| 238 WebGraphicsContext3D* context3D = provider->context3d(); | 238 WebGraphicsContext3D* context3D = provider->context3d(); |
| 239 RefPtr<SkImage> textureImage = m_surface->getBackingTextureImage(); | 239 RefPtr<SkImage> textureImage = m_surface->newImageSnapshot(); |
| 240 if (!context3D || !textureImage) | 240 if (!context3D || !textureImage) |
| 241 return false; | 241 return false; |
| 242 ASSERT(textureImage->isTextureBacked()); | 242 ASSERT(textureImage->isTextureBacked()); |
| 243 // Get the texture ID, flushing pending operations if needed. | 243 // Get the texture ID, flushing pending operations if needed. |
| 244 Platform3DObject textureId = textureImage->getTextureHandle(true); | 244 Platform3DObject textureId = textureImage->getTextureHandle(true); |
| 245 if (!textureId) | 245 if (!textureId) |
| 246 return false; | 246 return false; |
| 247 | 247 |
| 248 context3D->flush(); |
| 249 |
| 248 m_surface->invalidateCachedBitmap(); | 250 m_surface->invalidateCachedBitmap(); |
| 249 bool result = drawingBuffer->copyToPlatformTexture(context3D, textureId, GL_
RGBA, | 251 bool result = drawingBuffer->copyToPlatformTexture(context3D, textureId, GL_
RGBA, |
| 250 GL_UNSIGNED_BYTE, 0, true, false, sourceBuffer); | 252 GL_UNSIGNED_BYTE, 0, true, false, sourceBuffer); |
| 251 | 253 |
| 252 if (result) { | 254 if (result) { |
| 253 m_surface->didModifyBackingTexture(); | 255 m_surface->didModifyBackingTexture(); |
| 254 } | 256 } |
| 255 | 257 |
| 256 return result; | 258 return result; |
| 257 } | 259 } |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); | 383 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); |
| 382 | 384 |
| 383 Vector<char> encodedImage; | 385 Vector<char> encodedImage; |
| 384 if (!encodeImage(*this, mimeType, quality, &encodedImage)) | 386 if (!encodeImage(*this, mimeType, quality, &encodedImage)) |
| 385 return "data:,"; | 387 return "data:,"; |
| 386 | 388 |
| 387 return "data:" + mimeType + ";base64," + base64Encode(encodedImage); | 389 return "data:" + mimeType + ";base64," + base64Encode(encodedImage); |
| 388 } | 390 } |
| 389 | 391 |
| 390 } // namespace blink | 392 } // namespace blink |
| OLD | NEW |