Chromium Code Reviews| 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 914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 925 drawImage(image, FloatRect(IntRect(p, image->size())), FloatRect(FloatPoint( ), FloatSize(image->size())), op, shouldRespectImageOrientation); | 925 drawImage(image, FloatRect(IntRect(p, image->size())), FloatRect(FloatPoint( ), FloatSize(image->size())), op, shouldRespectImageOrientation); |
| 926 } | 926 } |
| 927 | 927 |
| 928 void GraphicsContext::drawImage(Image* image, const IntRect& r, SkXfermode::Mode op, RespectImageOrientationEnum shouldRespectImageOrientation) | 928 void GraphicsContext::drawImage(Image* image, const IntRect& r, SkXfermode::Mode op, RespectImageOrientationEnum shouldRespectImageOrientation) |
| 929 { | 929 { |
| 930 if (!image) | 930 if (!image) |
| 931 return; | 931 return; |
| 932 drawImage(image, FloatRect(r), FloatRect(FloatPoint(), FloatSize(image->size ())), op, shouldRespectImageOrientation); | 932 drawImage(image, FloatRect(r), FloatRect(FloatPoint(), FloatSize(image->size ())), op, shouldRespectImageOrientation); |
| 933 } | 933 } |
| 934 | 934 |
| 935 static FloatRect adjustRectForNegativeSize(const FloatRect& rect) | |
| 936 { | |
| 937 FloatRect norm = rect; | |
| 938 if (norm.width() < 0) { | |
| 939 norm.setX(norm.x() + norm.width()); | |
| 940 norm.setWidth(-norm.width()); | |
| 941 } | |
| 942 if (norm.height() < 0) { | |
| 943 norm.setY(norm.y() + norm.height()); | |
| 944 norm.setHeight(-norm.height()); | |
| 945 } | |
| 946 return norm; | |
| 947 } | |
| 948 | |
| 935 void GraphicsContext::drawImage(Image* image, const FloatRect& dest, const Float Rect& src, SkXfermode::Mode op, RespectImageOrientationEnum shouldRespectImageOr ientation) | 949 void GraphicsContext::drawImage(Image* image, const FloatRect& dest, const Float Rect& src, SkXfermode::Mode op, RespectImageOrientationEnum shouldRespectImageOr ientation) |
| 936 { | 950 { |
| 937 if (contextDisabled() || !image) | 951 if (contextDisabled() || !image) |
| 938 return; | 952 return; |
| 939 | 953 |
| 940 SkPaint imagePaint = immutableState()->fillPaint(); | 954 SkPaint imagePaint = immutableState()->fillPaint(); |
| 941 imagePaint.setXfermodeMode(op); | 955 imagePaint.setXfermodeMode(op); |
| 942 imagePaint.setColor(SK_ColorBLACK); | 956 imagePaint.setColor(SK_ColorBLACK); |
| 943 imagePaint.setFilterQuality(computeFilterQuality(image, dest, src)); | 957 imagePaint.setFilterQuality(computeFilterQuality(image, dest, src)); |
| 944 // Disable anti-aliasing if we're not rotated or skewed. | 958 // Disable anti-aliasing if we're not rotated or skewed. |
| 945 // TODO(junov): crbug.com/492187 This code will disable antialiasing | 959 // TODO(junov): crbug.com/492187 This code will disable antialiasing |
| 946 // regardless of whether content is pixel aligned. Is this correct? | 960 // regardless of whether content is pixel aligned. Is this correct? |
| 947 // For now, just preserving legacy behavior. | 961 // For now, just preserving legacy behavior. |
| 948 imagePaint.setAntiAlias(shouldAntialiasImages()); | 962 imagePaint.setAntiAlias(shouldAntialiasImages()); |
| 949 image->draw(m_canvas, imagePaint, dest, src, shouldRespectImageOrientation, Image::ClampImageToSourceRect); | 963 FloatRect normDest = adjustRectForNegativeSize(dest); |
|
chrishtr
2015/06/12 16:45:12
Why is the rect of negative width or height? Can i
| |
| 964 FloatRect normSrc = adjustRectForNegativeSize(src); | |
| 965 image->draw(m_canvas, imagePaint, normDest, normSrc, shouldRespectImageOrien tation, Image::ClampImageToSourceRect); | |
| 950 } | 966 } |
| 951 | 967 |
| 952 SkFilterQuality GraphicsContext::computeFilterQuality(Image* image, const FloatR ect& dest, const FloatRect& src) const | 968 SkFilterQuality GraphicsContext::computeFilterQuality(Image* image, const FloatR ect& dest, const FloatRect& src) const |
| 953 { | 969 { |
| 954 InterpolationQuality resampling; | 970 InterpolationQuality resampling; |
| 955 if (printing()) { | 971 if (printing()) { |
| 956 resampling = InterpolationNone; | 972 resampling = InterpolationNone; |
| 957 } else if (image->isLazyDecodedBitmap()) { | 973 } else if (image->isLazyDecodedBitmap()) { |
| 958 resampling = InterpolationHigh; | 974 resampling = InterpolationHigh; |
| 959 } else { | 975 } else { |
| (...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1570 static const SkPMColor colors[] = { | 1586 static const SkPMColor colors[] = { |
| 1571 SkPreMultiplyARGB(0x60, 0xFF, 0x00, 0x00), // More transparent red | 1587 SkPreMultiplyARGB(0x60, 0xFF, 0x00, 0x00), // More transparent red |
| 1572 SkPreMultiplyARGB(0x60, 0xC0, 0xC0, 0xC0) // More transparent gray | 1588 SkPreMultiplyARGB(0x60, 0xC0, 0xC0, 0xC0) // More transparent gray |
| 1573 }; | 1589 }; |
| 1574 | 1590 |
| 1575 return colors[index]; | 1591 return colors[index]; |
| 1576 } | 1592 } |
| 1577 #endif | 1593 #endif |
| 1578 | 1594 |
| 1579 } // namespace blink | 1595 } // namespace blink |
| OLD | NEW |