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 853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
864 } | 864 } |
865 | 865 |
866 void GraphicsContext::drawHighlightForText(const Font& font, const TextRun& run,
const FloatPoint& point, int h, const Color& backgroundColor, int from, int to) | 866 void GraphicsContext::drawHighlightForText(const Font& font, const TextRun& run,
const FloatPoint& point, int h, const Color& backgroundColor, int from, int to) |
867 { | 867 { |
868 if (contextDisabled()) | 868 if (contextDisabled()) |
869 return; | 869 return; |
870 | 870 |
871 fillRect(font.selectionRectForText(run, point, h, from, to), backgroundColor
); | 871 fillRect(font.selectionRectForText(run, point, h, from, to), backgroundColor
); |
872 } | 872 } |
873 | 873 |
874 void GraphicsContext::drawImage(Image* image, const IntRect& r, SkXfermode::Mode
op, RespectImageOrientationEnum shouldRespectImageOrientation) | 874 void GraphicsContext::drawImage(Image* image, const IntRect& r, const KURL& url,
SkXfermode::Mode op, RespectImageOrientationEnum shouldRespectImageOrientation) |
875 { | 875 { |
876 if (!image) | 876 if (!image) |
877 return; | 877 return; |
878 drawImage(image, FloatRect(r), FloatRect(FloatPoint(), FloatSize(image->size
())), op, shouldRespectImageOrientation); | 878 drawImage(image, FloatRect(r), FloatRect(FloatPoint(), FloatSize(image->size
())), url, op, shouldRespectImageOrientation); |
879 } | 879 } |
880 | 880 |
881 void GraphicsContext::drawImage(Image* image, const FloatRect& dest, const Float
Rect& src, SkXfermode::Mode op, RespectImageOrientationEnum shouldRespectImageOr
ientation) | 881 void GraphicsContext::drawImage(Image* image, const FloatRect& dest, const Float
Rect& src, const KURL& url, SkXfermode::Mode op, RespectImageOrientationEnum sho
uldRespectImageOrientation) |
882 { | 882 { |
883 if (contextDisabled() || !image) | 883 if (contextDisabled() || !image) |
884 return; | 884 return; |
885 | 885 |
886 SkPaint imagePaint = immutableState()->fillPaint(); | 886 SkPaint imagePaint = immutableState()->fillPaint(); |
887 imagePaint.setXfermodeMode(op); | 887 imagePaint.setXfermodeMode(op); |
888 imagePaint.setColor(SK_ColorBLACK); | 888 imagePaint.setColor(SK_ColorBLACK); |
889 imagePaint.setFilterQuality(computeFilterQuality(image, dest, src)); | 889 imagePaint.setFilterQuality(computeFilterQuality(image, dest, src)); |
890 imagePaint.setAntiAlias(shouldAntialias()); | 890 imagePaint.setAntiAlias(shouldAntialias()); |
891 image->draw(m_canvas, imagePaint, dest, src, shouldRespectImageOrientation,
Image::ClampImageToSourceRect); | 891 image->draw(m_canvas, imagePaint, dest, src, shouldRespectImageOrientation,
Image::ClampImageToSourceRect, url); |
892 } | 892 } |
893 | 893 |
894 SkFilterQuality GraphicsContext::computeFilterQuality(Image* image, const FloatR
ect& dest, const FloatRect& src) const | 894 SkFilterQuality GraphicsContext::computeFilterQuality(Image* image, const FloatR
ect& dest, const FloatRect& src) const |
895 { | 895 { |
896 InterpolationQuality resampling; | 896 InterpolationQuality resampling; |
897 if (printing()) { | 897 if (printing()) { |
898 resampling = InterpolationNone; | 898 resampling = InterpolationNone; |
899 } else if (image->currentFrameIsLazyDecoded()) { | 899 } else if (image->currentFrameIsLazyDecoded()) { |
900 resampling = InterpolationHigh; | 900 resampling = InterpolationHigh; |
901 } else { | 901 } else { |
902 resampling = computeInterpolationQuality( | 902 resampling = computeInterpolationQuality( |
903 SkScalarToFloat(src.width()), SkScalarToFloat(src.height()), | 903 SkScalarToFloat(src.width()), SkScalarToFloat(src.height()), |
904 SkScalarToFloat(dest.width()), SkScalarToFloat(dest.height()), | 904 SkScalarToFloat(dest.width()), SkScalarToFloat(dest.height()), |
905 image->currentFrameIsComplete()); | 905 image->currentFrameIsComplete()); |
906 | 906 |
907 if (resampling == InterpolationNone) { | 907 if (resampling == InterpolationNone) { |
908 // FIXME: This is to not break tests (it results in the filter bitma
p flag | 908 // FIXME: This is to not break tests (it results in the filter bitma
p flag |
909 // being set to true). We need to decide if we respect Interpolation
None | 909 // being set to true). We need to decide if we respect Interpolation
None |
910 // being returned from computeInterpolationQuality. | 910 // being returned from computeInterpolationQuality. |
911 resampling = InterpolationLow; | 911 resampling = InterpolationLow; |
912 } | 912 } |
913 } | 913 } |
914 return static_cast<SkFilterQuality>(limitInterpolationQuality(this, resampli
ng)); | 914 return static_cast<SkFilterQuality>(limitInterpolationQuality(this, resampli
ng)); |
915 } | 915 } |
916 | 916 |
917 void GraphicsContext::drawTiledImage(Image* image, const IntRect& destRect, cons
t IntPoint& srcPoint, const IntSize& tileSize, SkXfermode::Mode op, const IntSiz
e& repeatSpacing) | 917 void GraphicsContext::drawTiledImage(Image* image, const IntRect& destRect, cons
t IntPoint& srcPoint, const IntSize& tileSize, const KURL& url, SkXfermode::Mode
op, const IntSize& repeatSpacing) |
918 { | 918 { |
919 if (contextDisabled() || !image) | 919 if (contextDisabled() || !image) |
920 return; | 920 return; |
921 image->drawTiled(this, destRect, srcPoint, tileSize, op, repeatSpacing); | 921 image->drawTiled(this, destRect, srcPoint, tileSize, url, op, repeatSpacing)
; |
922 } | 922 } |
923 | 923 |
924 void GraphicsContext::drawTiledImage(Image* image, const IntRect& dest, const In
tRect& srcRect, | 924 void GraphicsContext::drawTiledImage(Image* image, const IntRect& dest, const In
tRect& srcRect, |
925 const FloatSize& tileScaleFactor, Image::TileRule hRule, Image::TileRule vRu
le, SkXfermode::Mode op) | 925 const FloatSize& tileScaleFactor, const KURL& url, Image::TileRule hRule, Im
age::TileRule vRule, SkXfermode::Mode op) |
926 { | 926 { |
927 if (contextDisabled() || !image) | 927 if (contextDisabled() || !image) |
928 return; | 928 return; |
929 | 929 |
930 if (hRule == Image::StretchTile && vRule == Image::StretchTile) { | 930 if (hRule == Image::StretchTile && vRule == Image::StretchTile) { |
931 // Just do a scale. | 931 // Just do a scale. |
932 drawImage(image, dest, srcRect, op); | 932 drawImage(image, dest, srcRect, url, op); |
933 return; | 933 return; |
934 } | 934 } |
935 | 935 |
936 image->drawTiled(this, dest, srcRect, tileScaleFactor, hRule, vRule, op); | 936 image->drawTiled(this, dest, srcRect, tileScaleFactor, url, hRule, vRule, op
); |
937 } | 937 } |
938 | 938 |
939 void GraphicsContext::drawOval(const SkRect& oval, const SkPaint& paint) | 939 void GraphicsContext::drawOval(const SkRect& oval, const SkPaint& paint) |
940 { | 940 { |
941 if (contextDisabled()) | 941 if (contextDisabled()) |
942 return; | 942 return; |
943 ASSERT(m_canvas); | 943 ASSERT(m_canvas); |
944 | 944 |
945 m_canvas->drawOval(oval, paint); | 945 m_canvas->drawOval(oval, paint); |
946 } | 946 } |
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1457 static const SkPMColor colors[] = { | 1457 static const SkPMColor colors[] = { |
1458 SkPreMultiplyARGB(0x60, 0xFF, 0x00, 0x00), // More transparent red | 1458 SkPreMultiplyARGB(0x60, 0xFF, 0x00, 0x00), // More transparent red |
1459 SkPreMultiplyARGB(0x60, 0xC0, 0xC0, 0xC0) // More transparent gray | 1459 SkPreMultiplyARGB(0x60, 0xC0, 0xC0, 0xC0) // More transparent gray |
1460 }; | 1460 }; |
1461 | 1461 |
1462 return colors[index]; | 1462 return colors[index]; |
1463 } | 1463 } |
1464 #endif | 1464 #endif |
1465 | 1465 |
1466 } // namespace blink | 1466 } // namespace blink |
OLD | NEW |