| 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 } | 105 } |
| 106 | 106 |
| 107 void ImageBuffer::clip(GraphicsContext* context, const FloatRect& rect) const | 107 void ImageBuffer::clip(GraphicsContext* context, const FloatRect& rect) const |
| 108 { | 108 { |
| 109 context->platformContext()->beginLayerClippedToImage(rect, this); | 109 context->platformContext()->beginLayerClippedToImage(rect, this); |
| 110 } | 110 } |
| 111 | 111 |
| 112 void ImageBuffer::draw(GraphicsContext* context, ColorSpace styleColorSpace, con
st FloatRect& destRect, const FloatRect& srcRect, | 112 void ImageBuffer::draw(GraphicsContext* context, ColorSpace styleColorSpace, con
st FloatRect& destRect, const FloatRect& srcRect, |
| 113 CompositeOperator op, bool useLowQualityScale) | 113 CompositeOperator op, bool useLowQualityScale) |
| 114 { | 114 { |
| 115 // Set both graphics contexts current. This looks a little weird, but is |
| 116 // necessary since we may be drawing from an accelerated to |
| 117 // non-accelerated context (e.g., printing), or vice versa. Note that it |
| 118 // only works because the context is actually the same underlying context |
| 119 // (or null), since we use one context for accelerated drawing. If that |
| 120 // assumption changes, we'll have to revisit this code. |
| 121 context->platformContext()->makeGrContextCurrent(); |
| 115 m_context->platformContext()->makeGrContextCurrent(); | 122 m_context->platformContext()->makeGrContextCurrent(); |
| 116 SkDevice* srcDevice = m_context->platformContext()->canvas()->getDevice(); | 123 RefPtr<Image> image = BitmapImageSingleFrameSkia::create(*m_data.m_platformC
ontext.bitmap(), context == m_context); |
| 117 SkBitmap bitmap = srcDevice->accessBitmap(false); | |
| 118 SkAutoLockPixels bitmapLock(bitmap); | |
| 119 context->platformContext()->makeGrContextCurrent(); | |
| 120 RefPtr<Image> image = BitmapImageSingleFrameSkia::create(bitmap, context ==
m_context); | |
| 121 context->drawImage(image.get(), styleColorSpace, destRect, srcRect, op, useL
owQualityScale); | 124 context->drawImage(image.get(), styleColorSpace, destRect, srcRect, op, useL
owQualityScale); |
| 122 } | 125 } |
| 123 | 126 |
| 124 void ImageBuffer::drawPattern(GraphicsContext* context, const FloatRect& srcRect
, const AffineTransform& patternTransform, | 127 void ImageBuffer::drawPattern(GraphicsContext* context, const FloatRect& srcRect
, const AffineTransform& patternTransform, |
| 125 const FloatPoint& phase, ColorSpace styleColorSpac
e, CompositeOperator op, const FloatRect& destRect) | 128 const FloatPoint& phase, ColorSpace styleColorSpac
e, CompositeOperator op, const FloatRect& destRect) |
| 126 { | 129 { |
| 127 context->platformContext()->makeGrContextCurrent(); | 130 context->platformContext()->makeGrContextCurrent(); |
| 128 RefPtr<Image> image = BitmapImageSingleFrameSkia::create(*m_data.m_platformC
ontext.bitmap(), context == m_context); | 131 RefPtr<Image> image = BitmapImageSingleFrameSkia::create(*m_data.m_platformC
ontext.bitmap(), context == m_context); |
| 129 image->drawPattern(context, srcRect, patternTransform, phase, styleColorSpac
e, op, destRect); | 132 image->drawPattern(context, srcRect, patternTransform, phase, styleColorSpac
e, op, destRect); |
| 130 } | 133 } |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 | 376 |
| 374 return ImageToDataURL(bitmap, mimeType, quality); | 377 return ImageToDataURL(bitmap, mimeType, quality); |
| 375 } | 378 } |
| 376 | 379 |
| 377 String ImageDataToDataURL(const ImageData& source, const String& mimeType, const
double* quality) | 380 String ImageDataToDataURL(const ImageData& source, const String& mimeType, const
double* quality) |
| 378 { | 381 { |
| 379 return ImageToDataURL(source, mimeType, quality); | 382 return ImageToDataURL(source, mimeType, quality); |
| 380 } | 383 } |
| 381 | 384 |
| 382 } // namespace WebCore | 385 } // namespace WebCore |
| OLD | NEW |