| 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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 | 258 |
| 259 return result; | 259 return result; |
| 260 } | 260 } |
| 261 | 261 |
| 262 void ImageBuffer::draw(GraphicsContext* context, const FloatRect& destRect, cons
t FloatRect* srcPtr, CompositeOperator op, WebBlendMode blendMode) | 262 void ImageBuffer::draw(GraphicsContext* context, const FloatRect& destRect, cons
t FloatRect* srcPtr, CompositeOperator op, WebBlendMode blendMode) |
| 263 { | 263 { |
| 264 if (!isSurfaceValid()) | 264 if (!isSurfaceValid()) |
| 265 return; | 265 return; |
| 266 | 266 |
| 267 FloatRect srcRect = srcPtr ? *srcPtr : FloatRect(FloatPoint(), size()); | 267 FloatRect srcRect = srcPtr ? *srcPtr : FloatRect(FloatPoint(), size()); |
| 268 RefPtr<SkPicture> picture = m_surface->getPicture(); | 268 m_surface->draw(context, destRect, srcRect, op, blendMode, drawNeedsCopy(m_c
ontext.get(), context)); |
| 269 if (picture) { | |
| 270 context->drawPicture(picture.get(), destRect, srcRect, op, blendMode); | |
| 271 return; | |
| 272 } | |
| 273 | |
| 274 SkBitmap bitmap = m_surface->bitmap(); | |
| 275 // For ImageBufferSurface that enables cachedBitmap, Use the cached Bitmap f
or CPU side usage | |
| 276 // if it is available, otherwise generate and use it. | |
| 277 if (!context->isAccelerated() && m_surface->isAccelerated() && m_surface->ca
chedBitmapEnabled() && isSurfaceValid()) { | |
| 278 m_surface->updateCachedBitmapIfNeeded(); | |
| 279 bitmap = m_surface->cachedBitmap(); | |
| 280 } | |
| 281 | |
| 282 RefPtr<Image> image = BitmapImage::create(NativeImageSkia::create(drawNeedsC
opy(m_context.get(), context) ? deepSkBitmapCopy(bitmap) : bitmap)); | |
| 283 | |
| 284 context->drawImage(image.get(), destRect, srcRect, op, blendMode, DoNotRespe
ctImageOrientation); | |
| 285 } | 269 } |
| 286 | 270 |
| 287 void ImageBuffer::flush() | 271 void ImageBuffer::flush() |
| 288 { | 272 { |
| 289 if (m_surface->canvas()) { | 273 if (m_surface->canvas()) { |
| 290 m_surface->canvas()->flush(); | 274 m_surface->canvas()->flush(); |
| 291 } | 275 } |
| 292 } | 276 } |
| 293 | 277 |
| 294 void ImageBuffer::drawPattern(GraphicsContext* context, const FloatRect& srcRect
, const FloatSize& scale, | 278 void ImageBuffer::drawPattern(GraphicsContext* context, const FloatRect& srcRect
, const FloatSize& scale, |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 | 394 |
| 411 String ImageBuffer::toDataURL(const String& mimeType, const double* quality) con
st | 395 String ImageBuffer::toDataURL(const String& mimeType, const double* quality) con
st |
| 412 { | 396 { |
| 413 if (!isSurfaceValid()) | 397 if (!isSurfaceValid()) |
| 414 return "data:,"; | 398 return "data:,"; |
| 415 | 399 |
| 416 return ImageEncoder::toDataURL(m_surface->bitmap(), mimeType, quality); | 400 return ImageEncoder::toDataURL(m_surface->bitmap(), mimeType, quality); |
| 417 } | 401 } |
| 418 | 402 |
| 419 } // namespace blink | 403 } // namespace blink |
| OLD | NEW |