| 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 | 156 |
| 157 const SkBitmap& bitmap = m_surface->bitmap(); | 157 const SkBitmap& bitmap = m_surface->bitmap(); |
| 158 return BitmapImage::create(NativeImageSkia::create(copyBehavior == CopyBacki
ngStore ? deepSkBitmapCopy(bitmap) : bitmap)); | 158 return BitmapImage::create(NativeImageSkia::create(copyBehavior == CopyBacki
ngStore ? deepSkBitmapCopy(bitmap) : bitmap)); |
| 159 } | 159 } |
| 160 | 160 |
| 161 BackingStoreCopy ImageBuffer::fastCopyImageMode() | 161 BackingStoreCopy ImageBuffer::fastCopyImageMode() |
| 162 { | 162 { |
| 163 return DontCopyBackingStore; | 163 return DontCopyBackingStore; |
| 164 } | 164 } |
| 165 | 165 |
| 166 blink::WebLayer* ImageBuffer::platformLayer() const | 166 WebLayer* ImageBuffer::platformLayer() const |
| 167 { | 167 { |
| 168 return m_surface->layer(); | 168 return m_surface->layer(); |
| 169 } | 169 } |
| 170 | 170 |
| 171 bool ImageBuffer::copyToPlatformTexture(blink::WebGraphicsContext3D* context, Pl
atform3DObject texture, GLenum internalFormat, GLenum destType, GLint level, boo
l premultiplyAlpha, bool flipY) | 171 bool ImageBuffer::copyToPlatformTexture(WebGraphicsContext3D* context, Platform3
DObject texture, GLenum internalFormat, GLenum destType, GLint level, bool premu
ltiplyAlpha, bool flipY) |
| 172 { | 172 { |
| 173 if (!m_surface->isAccelerated() || !platformLayer() || !isSurfaceValid()) | 173 if (!m_surface->isAccelerated() || !platformLayer() || !isSurfaceValid()) |
| 174 return false; | 174 return false; |
| 175 | 175 |
| 176 if (!Extensions3DUtil::canUseCopyTextureCHROMIUM(internalFormat, destType, l
evel)) | 176 if (!Extensions3DUtil::canUseCopyTextureCHROMIUM(internalFormat, destType, l
evel)) |
| 177 return false; | 177 return false; |
| 178 | 178 |
| 179 OwnPtr<blink::WebGraphicsContext3DProvider> provider = adoptPtr(blink::Platf
orm::current()->createSharedOffscreenGraphicsContext3DProvider()); | 179 OwnPtr<WebGraphicsContext3DProvider> provider = adoptPtr(Platform::current()
->createSharedOffscreenGraphicsContext3DProvider()); |
| 180 if (!provider) | 180 if (!provider) |
| 181 return false; | 181 return false; |
| 182 blink::WebGraphicsContext3D* sharedContext = provider->context3d(); | 182 WebGraphicsContext3D* sharedContext = provider->context3d(); |
| 183 if (!sharedContext || !sharedContext->makeContextCurrent()) | 183 if (!sharedContext || !sharedContext->makeContextCurrent()) |
| 184 return false; | 184 return false; |
| 185 | 185 |
| 186 OwnPtr<blink::WebExternalTextureMailbox> mailbox = adoptPtr(new blink::WebEx
ternalTextureMailbox); | 186 OwnPtr<WebExternalTextureMailbox> mailbox = adoptPtr(new WebExternalTextureM
ailbox); |
| 187 | 187 |
| 188 // Contexts may be in a different share group. We must transfer the texture
through a mailbox first | 188 // Contexts may be in a different share group. We must transfer the texture
through a mailbox first |
| 189 sharedContext->genMailboxCHROMIUM(mailbox->name); | 189 sharedContext->genMailboxCHROMIUM(mailbox->name); |
| 190 sharedContext->produceTextureDirectCHROMIUM(getBackingTexture(), GL_TEXTURE_
2D, mailbox->name); | 190 sharedContext->produceTextureDirectCHROMIUM(getBackingTexture(), GL_TEXTURE_
2D, mailbox->name); |
| 191 sharedContext->flush(); | 191 sharedContext->flush(); |
| 192 | 192 |
| 193 mailbox->syncPoint = sharedContext->insertSyncPoint(); | 193 mailbox->syncPoint = sharedContext->insertSyncPoint(); |
| 194 | 194 |
| 195 if (!context->makeContextCurrent()) | 195 if (!context->makeContextCurrent()) |
| 196 return false; | 196 return false; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 227 | 227 |
| 228 Platform3DObject ImageBuffer::getBackingTexture() | 228 Platform3DObject ImageBuffer::getBackingTexture() |
| 229 { | 229 { |
| 230 return m_surface->getBackingTexture(); | 230 return m_surface->getBackingTexture(); |
| 231 } | 231 } |
| 232 | 232 |
| 233 bool ImageBuffer::copyRenderingResultsFromDrawingBuffer(DrawingBuffer* drawingBu
ffer, bool fromFrontBuffer) | 233 bool ImageBuffer::copyRenderingResultsFromDrawingBuffer(DrawingBuffer* drawingBu
ffer, bool fromFrontBuffer) |
| 234 { | 234 { |
| 235 if (!drawingBuffer) | 235 if (!drawingBuffer) |
| 236 return false; | 236 return false; |
| 237 OwnPtr<blink::WebGraphicsContext3DProvider> provider = adoptPtr(blink::Platf
orm::current()->createSharedOffscreenGraphicsContext3DProvider()); | 237 OwnPtr<WebGraphicsContext3DProvider> provider = adoptPtr(Platform::current()
->createSharedOffscreenGraphicsContext3DProvider()); |
| 238 if (!provider) | 238 if (!provider) |
| 239 return false; | 239 return false; |
| 240 blink::WebGraphicsContext3D* context3D = provider->context3d(); | 240 WebGraphicsContext3D* context3D = provider->context3d(); |
| 241 Platform3DObject tex = m_surface->getBackingTexture(); | 241 Platform3DObject tex = m_surface->getBackingTexture(); |
| 242 if (!context3D || !tex) | 242 if (!context3D || !tex) |
| 243 return false; | 243 return false; |
| 244 | 244 |
| 245 m_surface->invalidateCachedBitmap(); | 245 m_surface->invalidateCachedBitmap(); |
| 246 return drawingBuffer->copyToPlatformTexture(context3D, tex, GL_RGBA, | 246 return drawingBuffer->copyToPlatformTexture(context3D, tex, GL_RGBA, |
| 247 GL_UNSIGNED_BYTE, 0, true, false, fromFrontBuffer); | 247 GL_UNSIGNED_BYTE, 0, true, false, fromFrontBuffer); |
| 248 } | 248 } |
| 249 | 249 |
| 250 void ImageBuffer::draw(GraphicsContext* context, const FloatRect& destRect, cons
t FloatRect* srcPtr, CompositeOperator op, WebBlendMode blendMode) | 250 void ImageBuffer::draw(GraphicsContext* context, const FloatRect& destRect, cons
t FloatRect* srcPtr, CompositeOperator op, WebBlendMode blendMode) |
| (...skipping 22 matching lines...) Expand all Loading... |
| 273 } | 273 } |
| 274 | 274 |
| 275 void ImageBuffer::flush() | 275 void ImageBuffer::flush() |
| 276 { | 276 { |
| 277 if (m_surface->canvas()) { | 277 if (m_surface->canvas()) { |
| 278 m_surface->canvas()->flush(); | 278 m_surface->canvas()->flush(); |
| 279 } | 279 } |
| 280 } | 280 } |
| 281 | 281 |
| 282 void ImageBuffer::drawPattern(GraphicsContext* context, const FloatRect& srcRect
, const FloatSize& scale, | 282 void ImageBuffer::drawPattern(GraphicsContext* context, const FloatRect& srcRect
, const FloatSize& scale, |
| 283 const FloatPoint& phase, CompositeOperator op, const FloatRect& destRect, bl
ink::WebBlendMode blendMode, const IntSize& repeatSpacing) | 283 const FloatPoint& phase, CompositeOperator op, const FloatRect& destRect, We
bBlendMode blendMode, const IntSize& repeatSpacing) |
| 284 { | 284 { |
| 285 if (!isSurfaceValid()) | 285 if (!isSurfaceValid()) |
| 286 return; | 286 return; |
| 287 | 287 |
| 288 const SkBitmap& bitmap = m_surface->bitmap(); | 288 const SkBitmap& bitmap = m_surface->bitmap(); |
| 289 RefPtr<Image> image = BitmapImage::create(NativeImageSkia::create(drawNeedsC
opy(m_context.get(), context) ? deepSkBitmapCopy(bitmap) : bitmap)); | 289 RefPtr<Image> image = BitmapImage::create(NativeImageSkia::create(drawNeedsC
opy(m_context.get(), context) ? deepSkBitmapCopy(bitmap) : bitmap)); |
| 290 image->drawPattern(context, srcRect, scale, phase, op, destRect, blendMode,
repeatSpacing); | 290 image->drawPattern(context, srcRect, scale, phase, op, destRect, blendMode,
repeatSpacing); |
| 291 } | 291 } |
| 292 | 292 |
| 293 void ImageBuffer::transformColorSpace(ColorSpace srcColorSpace, ColorSpace dstCo
lorSpace) | 293 void ImageBuffer::transformColorSpace(ColorSpace srcColorSpace, ColorSpace dstCo
lorSpace) |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 if (!encodeImage(imageData, mimeType, quality, &encodedImage)) | 434 if (!encodeImage(imageData, mimeType, quality, &encodedImage)) |
| 435 return "data:,"; | 435 return "data:,"; |
| 436 | 436 |
| 437 Vector<char> base64Data; | 437 Vector<char> base64Data; |
| 438 base64Encode(encodedImage, base64Data); | 438 base64Encode(encodedImage, base64Data); |
| 439 | 439 |
| 440 return "data:" + mimeType + ";base64," + base64Data; | 440 return "data:" + mimeType + ";base64," + base64Data; |
| 441 } | 441 } |
| 442 | 442 |
| 443 } // namespace blink | 443 } // namespace blink |
| OLD | NEW |