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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 blink::WebGraphicsContext3D* context3D = provider->context3d(); | 230 blink::WebGraphicsContext3D* context3D = provider->context3d(); |
231 Platform3DObject tex = m_surface->getBackingTexture(); | 231 Platform3DObject tex = m_surface->getBackingTexture(); |
232 if (!context3D || !tex) | 232 if (!context3D || !tex) |
233 return false; | 233 return false; |
234 | 234 |
235 m_surface->invalidateCachedBitmap(); | 235 m_surface->invalidateCachedBitmap(); |
236 return drawingBuffer->copyToPlatformTexture(context3D, tex, GL_RGBA, | 236 return drawingBuffer->copyToPlatformTexture(context3D, tex, GL_RGBA, |
237 GL_UNSIGNED_BYTE, 0, true, false, fromFrontBuffer); | 237 GL_UNSIGNED_BYTE, 0, true, false, fromFrontBuffer); |
238 } | 238 } |
239 | 239 |
240 void ImageBuffer::draw(GraphicsContext* context, const FloatRect& destRect, cons
t FloatRect* srcPtr, CompositeOperator op) | 240 void ImageBuffer::draw(GraphicsContext* context, const FloatRect& destRect, cons
t FloatRect* srcPtr, CompositeOperator op, WebBlendMode blendMode) |
241 { | 241 { |
242 if (!isSurfaceValid()) | 242 if (!isSurfaceValid()) |
243 return; | 243 return; |
244 | 244 |
245 FloatRect srcRect = srcPtr ? *srcPtr : FloatRect(FloatPoint(), size()); | 245 FloatRect srcRect = srcPtr ? *srcPtr : FloatRect(FloatPoint(), size()); |
246 RefPtr<SkPicture> picture = m_surface->getPicture(); | 246 RefPtr<SkPicture> picture = m_surface->getPicture(); |
247 if (picture) { | 247 if (picture) { |
248 context->drawPicture(picture.release(), destRect, srcRect, op, blink::We
bBlendModeNormal); | 248 context->drawPicture(picture.release(), destRect, srcRect, op, blendMode
); |
249 return; | 249 return; |
250 } | 250 } |
251 | 251 |
252 SkBitmap bitmap = m_surface->bitmap(); | 252 SkBitmap bitmap = m_surface->bitmap(); |
253 // For ImageBufferSurface that enables cachedBitmap, Use the cached Bitmap f
or CPU side usage | 253 // For ImageBufferSurface that enables cachedBitmap, Use the cached Bitmap f
or CPU side usage |
254 // if it is available, otherwise generate and use it. | 254 // if it is available, otherwise generate and use it. |
255 if (!context->isAccelerated() && m_surface->isAccelerated() && m_surface->ca
chedBitmapEnabled() && isSurfaceValid()) { | 255 if (!context->isAccelerated() && m_surface->isAccelerated() && m_surface->ca
chedBitmapEnabled() && isSurfaceValid()) { |
256 m_surface->updateCachedBitmapIfNeeded(); | 256 m_surface->updateCachedBitmapIfNeeded(); |
257 bitmap = m_surface->cachedBitmap(); | 257 bitmap = m_surface->cachedBitmap(); |
258 } | 258 } |
259 | 259 |
260 RefPtr<Image> image = BitmapImage::create(NativeImageSkia::create(drawNeedsC
opy(m_context.get(), context) ? deepSkBitmapCopy(bitmap) : bitmap)); | 260 RefPtr<Image> image = BitmapImage::create(NativeImageSkia::create(drawNeedsC
opy(m_context.get(), context) ? deepSkBitmapCopy(bitmap) : bitmap)); |
261 | 261 |
262 context->drawImage(image.get(), destRect, srcRect, op, blink::WebBlendModeNo
rmal, DoNotRespectImageOrientation); | 262 context->drawImage(image.get(), destRect, srcRect, op, blendMode, DoNotRespe
ctImageOrientation); |
263 } | 263 } |
264 | 264 |
265 void ImageBuffer::flush() | 265 void ImageBuffer::flush() |
266 { | 266 { |
267 if (m_surface->canvas()) { | 267 if (m_surface->canvas()) { |
268 m_surface->canvas()->flush(); | 268 m_surface->canvas()->flush(); |
269 } | 269 } |
270 } | 270 } |
271 | 271 |
272 void ImageBuffer::drawPattern(GraphicsContext* context, const FloatRect& srcRect
, const FloatSize& scale, | 272 void ImageBuffer::drawPattern(GraphicsContext* context, const FloatRect& srcRect
, const FloatSize& scale, |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 if (!encodeImage(imageData, mimeType, quality, &encodedImage)) | 422 if (!encodeImage(imageData, mimeType, quality, &encodedImage)) |
423 return "data:,"; | 423 return "data:,"; |
424 | 424 |
425 Vector<char> base64Data; | 425 Vector<char> base64Data; |
426 base64Encode(encodedImage, base64Data); | 426 base64Encode(encodedImage, base64Data); |
427 | 427 |
428 return "data:" + mimeType + ";base64," + base64Data; | 428 return "data:" + mimeType + ";base64," + base64Data; |
429 } | 429 } |
430 | 430 |
431 } // namespace blink | 431 } // namespace blink |
OLD | NEW |