| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2003, 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2003, 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2013 Google Inc. All rights reserved. | 3 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #include "platform/graphics/GraphicsContext.h" | 27 #include "platform/graphics/GraphicsContext.h" |
| 28 | 28 |
| 29 #include "platform/geometry/FloatRect.h" | 29 #include "platform/geometry/FloatRect.h" |
| 30 #include "platform/geometry/FloatRoundedRect.h" | 30 #include "platform/geometry/FloatRoundedRect.h" |
| 31 #include "platform/geometry/IntRect.h" | 31 #include "platform/geometry/IntRect.h" |
| 32 #include "platform/graphics/ColorSpace.h" | 32 #include "platform/graphics/ColorSpace.h" |
| 33 #include "platform/graphics/GraphicsContextStateSaver.h" | 33 #include "platform/graphics/GraphicsContextStateSaver.h" |
| 34 #include "platform/graphics/ImageBuffer.h" | 34 #include "platform/graphics/ImageBuffer.h" |
| 35 #include "platform/graphics/Path.h" | 35 #include "platform/graphics/Path.h" |
| 36 #include "platform/graphics/paint/PaintController.h" | 36 #include "platform/graphics/paint/PaintController.h" |
| 37 #include "platform/image-decoders/ImageDecoder.h" |
| 37 #include "platform/tracing/TraceEvent.h" | 38 #include "platform/tracing/TraceEvent.h" |
| 38 #include "platform/weborigin/KURL.h" | 39 #include "platform/weborigin/KURL.h" |
| 39 #include "skia/ext/platform_canvas.h" | 40 #include "skia/ext/platform_canvas.h" |
| 40 #include "third_party/skia/include/core/SkAnnotation.h" | 41 #include "third_party/skia/include/core/SkAnnotation.h" |
| 41 #include "third_party/skia/include/core/SkColorFilter.h" | 42 #include "third_party/skia/include/core/SkColorFilter.h" |
| 42 #include "third_party/skia/include/core/SkData.h" | 43 #include "third_party/skia/include/core/SkData.h" |
| 43 #include "third_party/skia/include/core/SkPicture.h" | 44 #include "third_party/skia/include/core/SkPicture.h" |
| 44 #include "third_party/skia/include/core/SkPictureRecorder.h" | 45 #include "third_party/skia/include/core/SkPictureRecorder.h" |
| 45 #include "third_party/skia/include/core/SkRRect.h" | 46 #include "third_party/skia/include/core/SkRRect.h" |
| 46 #include "third_party/skia/include/core/SkRefCnt.h" | 47 #include "third_party/skia/include/core/SkRefCnt.h" |
| (...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 799 if (contextDisabled() || !image) | 800 if (contextDisabled() || !image) |
| 800 return; | 801 return; |
| 801 | 802 |
| 802 const FloatRect src = srcPtr ? *srcPtr : image->rect(); | 803 const FloatRect src = srcPtr ? *srcPtr : image->rect(); |
| 803 | 804 |
| 804 SkPaint imagePaint = immutableState()->fillPaint(); | 805 SkPaint imagePaint = immutableState()->fillPaint(); |
| 805 imagePaint.setBlendMode(op); | 806 imagePaint.setBlendMode(op); |
| 806 imagePaint.setColor(SK_ColorBLACK); | 807 imagePaint.setColor(SK_ColorBLACK); |
| 807 imagePaint.setFilterQuality(computeFilterQuality(image, dest, src)); | 808 imagePaint.setFilterQuality(computeFilterQuality(image, dest, src)); |
| 808 imagePaint.setAntiAlias(shouldAntialias()); | 809 imagePaint.setAntiAlias(shouldAntialias()); |
| 809 image->draw(m_canvas, imagePaint, dest, src, shouldRespectImageOrientation, | 810 image->drawInColorSpace( |
| 810 Image::ClampImageToSourceRect); | 811 m_canvas, imagePaint, dest, src, shouldRespectImageOrientation, |
| 812 Image::ClampImageToSourceRect, ImageDecoder::globalTargetColorSpace()); |
| 811 m_paintController.setImagePainted(); | 813 m_paintController.setImagePainted(); |
| 812 } | 814 } |
| 813 | 815 |
| 814 void GraphicsContext::drawImageRRect( | 816 void GraphicsContext::drawImageRRect( |
| 815 Image* image, | 817 Image* image, |
| 816 const FloatRoundedRect& dest, | 818 const FloatRoundedRect& dest, |
| 817 const FloatRect& srcRect, | 819 const FloatRect& srcRect, |
| 818 SkBlendMode op, | 820 SkBlendMode op, |
| 819 RespectImageOrientationEnum respectOrientation) { | 821 RespectImageOrientationEnum respectOrientation) { |
| 820 if (contextDisabled() || !image) | 822 if (contextDisabled() || !image) |
| (...skipping 26 matching lines...) Expand all Loading... |
| 847 } | 849 } |
| 848 | 850 |
| 849 if (useShader) { | 851 if (useShader) { |
| 850 // Shader-based fast path. | 852 // Shader-based fast path. |
| 851 m_canvas->drawRRect(dest, imagePaint); | 853 m_canvas->drawRRect(dest, imagePaint); |
| 852 } else { | 854 } else { |
| 853 // Clip-based fallback. | 855 // Clip-based fallback. |
| 854 SkAutoCanvasRestore autoRestore(m_canvas, true); | 856 SkAutoCanvasRestore autoRestore(m_canvas, true); |
| 855 m_canvas->clipRRect(dest, SkRegion::kIntersect_Op, | 857 m_canvas->clipRRect(dest, SkRegion::kIntersect_Op, |
| 856 imagePaint.isAntiAlias()); | 858 imagePaint.isAntiAlias()); |
| 857 image->draw(m_canvas, imagePaint, dest.rect(), srcRect, respectOrientation, | 859 image->drawInColorSpace(m_canvas, imagePaint, dest.rect(), srcRect, |
| 858 Image::ClampImageToSourceRect); | 860 respectOrientation, Image::ClampImageToSourceRect, |
| 861 ImageDecoder::globalTargetColorSpace()); |
| 859 } | 862 } |
| 860 | 863 |
| 861 m_paintController.setImagePainted(); | 864 m_paintController.setImagePainted(); |
| 862 } | 865 } |
| 863 | 866 |
| 864 SkFilterQuality GraphicsContext::computeFilterQuality( | 867 SkFilterQuality GraphicsContext::computeFilterQuality( |
| 865 Image* image, | 868 Image* image, |
| 866 const FloatRect& dest, | 869 const FloatRect& dest, |
| 867 const FloatRect& src) const { | 870 const FloatRect& src) const { |
| 868 InterpolationQuality resampling; | 871 InterpolationQuality resampling; |
| (...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1408 static const SkPMColor colors[] = { | 1411 static const SkPMColor colors[] = { |
| 1409 SkPreMultiplyARGB(0x60, 0xFF, 0x00, 0x00), // More transparent red | 1412 SkPreMultiplyARGB(0x60, 0xFF, 0x00, 0x00), // More transparent red |
| 1410 SkPreMultiplyARGB(0x60, 0xC0, 0xC0, 0xC0) // More transparent gray | 1413 SkPreMultiplyARGB(0x60, 0xC0, 0xC0, 0xC0) // More transparent gray |
| 1411 }; | 1414 }; |
| 1412 | 1415 |
| 1413 return colors[index]; | 1416 return colors[index]; |
| 1414 } | 1417 } |
| 1415 #endif | 1418 #endif |
| 1416 | 1419 |
| 1417 } // namespace blink | 1420 } // namespace blink |
| OLD | NEW |