| 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 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 805 return; | 805 return; |
| 806 | 806 |
| 807 const FloatRect src = srcPtr ? *srcPtr : image->rect(); | 807 const FloatRect src = srcPtr ? *srcPtr : image->rect(); |
| 808 | 808 |
| 809 SkPaint imagePaint = immutableState()->fillPaint(); | 809 SkPaint imagePaint = immutableState()->fillPaint(); |
| 810 imagePaint.setBlendMode(op); | 810 imagePaint.setBlendMode(op); |
| 811 imagePaint.setColor(SK_ColorBLACK); | 811 imagePaint.setColor(SK_ColorBLACK); |
| 812 imagePaint.setFilterQuality(computeFilterQuality(image, dest, src)); | 812 imagePaint.setFilterQuality(computeFilterQuality(image, dest, src)); |
| 813 imagePaint.setAntiAlias(shouldAntialias()); | 813 imagePaint.setAntiAlias(shouldAntialias()); |
| 814 image->draw(m_canvas, imagePaint, dest, src, shouldRespectImageOrientation, | 814 image->draw(m_canvas, imagePaint, dest, src, shouldRespectImageOrientation, |
| 815 Image::ClampImageToSourceRect); | 815 Image::ClampImageToSourceRect, m_colorBehavior); |
| 816 m_paintController.setImagePainted(); | 816 m_paintController.setImagePainted(); |
| 817 } | 817 } |
| 818 | 818 |
| 819 void GraphicsContext::drawImageRRect( | 819 void GraphicsContext::drawImageRRect( |
| 820 Image* image, | 820 Image* image, |
| 821 const FloatRoundedRect& dest, | 821 const FloatRoundedRect& dest, |
| 822 const FloatRect& srcRect, | 822 const FloatRect& srcRect, |
| 823 SkBlendMode op, | 823 SkBlendMode op, |
| 824 RespectImageOrientationEnum respectOrientation) { | 824 RespectImageOrientationEnum respectOrientation) { |
| 825 if (contextDisabled() || !image) | 825 if (contextDisabled() || !image) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 841 imagePaint.setColor(SK_ColorBLACK); | 841 imagePaint.setColor(SK_ColorBLACK); |
| 842 imagePaint.setFilterQuality( | 842 imagePaint.setFilterQuality( |
| 843 computeFilterQuality(image, dest.rect(), srcRect)); | 843 computeFilterQuality(image, dest.rect(), srcRect)); |
| 844 imagePaint.setAntiAlias(shouldAntialias()); | 844 imagePaint.setAntiAlias(shouldAntialias()); |
| 845 | 845 |
| 846 bool useShader = (visibleSrc == srcRect) && | 846 bool useShader = (visibleSrc == srcRect) && |
| 847 (respectOrientation == DoNotRespectImageOrientation); | 847 (respectOrientation == DoNotRespectImageOrientation); |
| 848 if (useShader) { | 848 if (useShader) { |
| 849 const SkMatrix localMatrix = SkMatrix::MakeRectToRect( | 849 const SkMatrix localMatrix = SkMatrix::MakeRectToRect( |
| 850 visibleSrc, dest.rect(), SkMatrix::kFill_ScaleToFit); | 850 visibleSrc, dest.rect(), SkMatrix::kFill_ScaleToFit); |
| 851 useShader = image->applyShader(imagePaint, localMatrix); | 851 useShader = image->applyShader(imagePaint, localMatrix, m_colorBehavior); |
| 852 } | 852 } |
| 853 | 853 |
| 854 if (useShader) { | 854 if (useShader) { |
| 855 // Shader-based fast path. | 855 // Shader-based fast path. |
| 856 m_canvas->drawRRect(dest, imagePaint); | 856 m_canvas->drawRRect(dest, imagePaint); |
| 857 } else { | 857 } else { |
| 858 // Clip-based fallback. | 858 // Clip-based fallback. |
| 859 SkAutoCanvasRestore autoRestore(m_canvas, true); | 859 SkAutoCanvasRestore autoRestore(m_canvas, true); |
| 860 m_canvas->clipRRect(dest, imagePaint.isAntiAlias()); | 860 m_canvas->clipRRect(dest, imagePaint.isAntiAlias()); |
| 861 image->draw(m_canvas, imagePaint, dest.rect(), srcRect, respectOrientation, | 861 image->draw(m_canvas, imagePaint, dest.rect(), srcRect, respectOrientation, |
| 862 Image::ClampImageToSourceRect); | 862 Image::ClampImageToSourceRect, m_colorBehavior); |
| 863 } | 863 } |
| 864 | 864 |
| 865 m_paintController.setImagePainted(); | 865 m_paintController.setImagePainted(); |
| 866 } | 866 } |
| 867 | 867 |
| 868 SkFilterQuality GraphicsContext::computeFilterQuality( | 868 SkFilterQuality GraphicsContext::computeFilterQuality( |
| 869 Image* image, | 869 Image* image, |
| 870 const FloatRect& dest, | 870 const FloatRect& dest, |
| 871 const FloatRect& src) const { | 871 const FloatRect& src) const { |
| 872 InterpolationQuality resampling; | 872 InterpolationQuality resampling; |
| (...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1414 static const SkPMColor colors[] = { | 1414 static const SkPMColor colors[] = { |
| 1415 SkPreMultiplyARGB(0x60, 0xFF, 0x00, 0x00), // More transparent red | 1415 SkPreMultiplyARGB(0x60, 0xFF, 0x00, 0x00), // More transparent red |
| 1416 SkPreMultiplyARGB(0x60, 0xC0, 0xC0, 0xC0) // More transparent gray | 1416 SkPreMultiplyARGB(0x60, 0xC0, 0xC0, 0xC0) // More transparent gray |
| 1417 }; | 1417 }; |
| 1418 | 1418 |
| 1419 return colors[index]; | 1419 return colors[index]; |
| 1420 } | 1420 } |
| 1421 #endif | 1421 #endif |
| 1422 | 1422 |
| 1423 } // namespace blink | 1423 } // namespace blink |
| OLD | NEW |