OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2008, Google Inc. All rights reserved. | 2 * Copyright (c) 2008, Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 13 matching lines...) Expand all Loading... |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "config.h" | 31 #include "config.h" |
32 #include "core/platform/graphics/skia/NativeImageSkia.h" | 32 #include "core/platform/graphics/skia/NativeImageSkia.h" |
33 | 33 |
34 #include "core/platform/FloatConversion.h" | |
35 #include "core/platform/PlatformInstrumentation.h" | 34 #include "core/platform/PlatformInstrumentation.h" |
36 #include "core/platform/chromium/TraceEvent.h" | 35 #include "core/platform/chromium/TraceEvent.h" |
37 #include "core/platform/graphics/FloatPoint.h" | 36 #include "core/platform/graphics/FloatPoint.h" |
38 #include "core/platform/graphics/FloatRect.h" | 37 #include "core/platform/graphics/FloatRect.h" |
39 #include "core/platform/graphics/FloatSize.h" | 38 #include "core/platform/graphics/FloatSize.h" |
40 #include "core/platform/graphics/GraphicsContext.h" | 39 #include "core/platform/graphics/GraphicsContext.h" |
41 #include "core/platform/graphics/Image.h" | 40 #include "core/platform/graphics/Image.h" |
42 #include "core/platform/graphics/chromium/DeferredImageDecoder.h" | 41 #include "core/platform/graphics/chromium/DeferredImageDecoder.h" |
43 #include "core/platform/graphics/skia/SkiaUtils.h" | 42 #include "core/platform/graphics/skia/SkiaUtils.h" |
44 #include "skia/ext/image_operations.h" | 43 #include "skia/ext/image_operations.h" |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 { | 319 { |
321 return !context->getTotalMatrix().rectStaysRect(); | 320 return !context->getTotalMatrix().rectStaysRect(); |
322 } | 321 } |
323 | 322 |
324 void NativeImageSkia::draw(GraphicsContext* context, const SkRect& srcRect, cons
t SkRect& destRect, SkXfermode::Mode compOp) const | 323 void NativeImageSkia::draw(GraphicsContext* context, const SkRect& srcRect, cons
t SkRect& destRect, SkXfermode::Mode compOp) const |
325 { | 324 { |
326 TRACE_EVENT0("skia", "NativeImageSkia::draw"); | 325 TRACE_EVENT0("skia", "NativeImageSkia::draw"); |
327 SkPaint paint; | 326 SkPaint paint; |
328 paint.setXfermodeMode(compOp); | 327 paint.setXfermodeMode(compOp); |
329 paint.setAlpha(context->getNormalizedAlpha()); | 328 paint.setAlpha(context->getNormalizedAlpha()); |
330 DrawLooper* drawLooper = context->drawLooper(); | 329 paint.setLooper(context->drawLooper()); |
331 if (drawLooper) { | |
332 if (drawLooper->shouldUseImageFilterToDrawBitmap(bitmap())) { | |
333 paint.setImageFilter(context->drawLooper()->imageFilter()); | |
334 } else { | |
335 paint.setLooper(drawLooper->skDrawLooper()); | |
336 } | |
337 } | |
338 // only antialias if we're rotated or skewed | 330 // only antialias if we're rotated or skewed |
339 paint.setAntiAlias(hasNon90rotation(context)); | 331 paint.setAntiAlias(hasNon90rotation(context)); |
340 | 332 |
341 ResamplingMode resampling; | 333 ResamplingMode resampling; |
342 if (context->isAccelerated()) { | 334 if (context->isAccelerated()) { |
343 resampling = LinearResampling; | 335 resampling = LinearResampling; |
344 } else if (context->printing()) { | 336 } else if (context->printing()) { |
345 resampling = NoResampling; | 337 resampling = NoResampling; |
346 } else { | 338 } else { |
347 // Take into account scale applied to the canvas when computing sampling
mode (e.g. CSS scale or page scale). | 339 // Take into account scale applied to the canvas when computing sampling
mode (e.g. CSS scale or page scale). |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 SkIRect NativeImageSkia::ImageResourceInfo::rectInSubset(const SkIRect& otherSca
ledImageSubset) | 536 SkIRect NativeImageSkia::ImageResourceInfo::rectInSubset(const SkIRect& otherSca
ledImageSubset) |
545 { | 537 { |
546 if (!scaledImageSubset.contains(otherScaledImageSubset)) | 538 if (!scaledImageSubset.contains(otherScaledImageSubset)) |
547 return SkIRect::MakeEmpty(); | 539 return SkIRect::MakeEmpty(); |
548 SkIRect subsetRect = otherScaledImageSubset; | 540 SkIRect subsetRect = otherScaledImageSubset; |
549 subsetRect.offset(-scaledImageSubset.x(), -scaledImageSubset.y()); | 541 subsetRect.offset(-scaledImageSubset.x(), -scaledImageSubset.y()); |
550 return subsetRect; | 542 return subsetRect; |
551 } | 543 } |
552 | 544 |
553 } // namespace WebCore | 545 } // namespace WebCore |
OLD | NEW |