| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 | 67 |
| 68 uint8_t blendR = blendChannel(SkGetPackedR32(src), srcA, SkGetPackedR32(dst)
, dstFactorA, scale); | 68 uint8_t blendR = blendChannel(SkGetPackedR32(src), srcA, SkGetPackedR32(dst)
, dstFactorA, scale); |
| 69 uint8_t blendG = blendChannel(SkGetPackedG32(src), srcA, SkGetPackedG32(dst)
, dstFactorA, scale); | 69 uint8_t blendG = blendChannel(SkGetPackedG32(src), srcA, SkGetPackedG32(dst)
, dstFactorA, scale); |
| 70 uint8_t blendB = blendChannel(SkGetPackedB32(src), srcA, SkGetPackedB32(dst)
, dstFactorA, scale); | 70 uint8_t blendB = blendChannel(SkGetPackedB32(src), srcA, SkGetPackedB32(dst)
, dstFactorA, scale); |
| 71 | 71 |
| 72 return SkPackARGB32NoCheck(blendA, blendR, blendG, blendB); | 72 return SkPackARGB32NoCheck(blendA, blendR, blendG, blendB); |
| 73 } | 73 } |
| 74 | 74 |
| 75 // Returns two point ranges (<left, width> pairs) at row 'canvasY', that belong
to 'src' but not 'dst'. | 75 // Returns two point ranges (<left, width> pairs) at row 'canvasY', that belong
to 'src' but not 'dst'. |
| 76 // A point range is empty if the corresponding width is 0. | 76 // A point range is empty if the corresponding width is 0. |
| 77 inline void findBlendRangeAtRow(const WebCore::IntRect& src, const WebCore::IntR
ect& dst, int canvasY, int& left1, int& width1, int& left2, int& width2) | 77 inline void findBlendRangeAtRow(const blink::IntRect& src, const blink::IntRect&
dst, int canvasY, int& left1, int& width1, int& left2, int& width2) |
| 78 { | 78 { |
| 79 ASSERT_WITH_SECURITY_IMPLICATION(canvasY >= src.y() && canvasY < src.maxY())
; | 79 ASSERT_WITH_SECURITY_IMPLICATION(canvasY >= src.y() && canvasY < src.maxY())
; |
| 80 left1 = -1; | 80 left1 = -1; |
| 81 width1 = 0; | 81 width1 = 0; |
| 82 left2 = -1; | 82 left2 = -1; |
| 83 width2 = 0; | 83 width2 = 0; |
| 84 | 84 |
| 85 if (canvasY < dst.y() || canvasY >= dst.maxY() || src.x() >= dst.maxX() || s
rc.maxX() <= dst.x()) { | 85 if (canvasY < dst.y() || canvasY >= dst.maxY() || src.x() >= dst.maxX() || s
rc.maxX() <= dst.x()) { |
| 86 left1 = src.x(); | 86 left1 = src.x(); |
| 87 width1 = src.width(); | 87 width1 = src.width(); |
| 88 return; | 88 return; |
| 89 } | 89 } |
| 90 | 90 |
| 91 if (src.x() < dst.x()) { | 91 if (src.x() < dst.x()) { |
| 92 left1 = src.x(); | 92 left1 = src.x(); |
| 93 width1 = dst.x() - src.x(); | 93 width1 = dst.x() - src.x(); |
| 94 } | 94 } |
| 95 | 95 |
| 96 if (src.maxX() > dst.maxX()) { | 96 if (src.maxX() > dst.maxX()) { |
| 97 left2 = dst.maxX(); | 97 left2 = dst.maxX(); |
| 98 width2 = src.maxX() - dst.maxX(); | 98 width2 = src.maxX() - dst.maxX(); |
| 99 } | 99 } |
| 100 } | 100 } |
| 101 | 101 |
| 102 void alphaBlendPremultiplied(WebCore::ImageFrame& src, WebCore::ImageFrame& dst,
int canvasY, int left, int width) | 102 void alphaBlendPremultiplied(blink::ImageFrame& src, blink::ImageFrame& dst, int
canvasY, int left, int width) |
| 103 { | 103 { |
| 104 for (int x = 0; x < width; ++x) { | 104 for (int x = 0; x < width; ++x) { |
| 105 int canvasX = left + x; | 105 int canvasX = left + x; |
| 106 WebCore::ImageFrame::PixelData& pixel = *src.getAddr(canvasX, canvasY); | 106 blink::ImageFrame::PixelData& pixel = *src.getAddr(canvasX, canvasY); |
| 107 if (SkGetPackedA32(pixel) != 0xff) { | 107 if (SkGetPackedA32(pixel) != 0xff) { |
| 108 WebCore::ImageFrame::PixelData prevPixel = *dst.getAddr(canvasX, can
vasY); | 108 blink::ImageFrame::PixelData prevPixel = *dst.getAddr(canvasX, canva
sY); |
| 109 pixel = SkPMSrcOver(pixel, prevPixel); | 109 pixel = SkPMSrcOver(pixel, prevPixel); |
| 110 } | 110 } |
| 111 } | 111 } |
| 112 } | 112 } |
| 113 | 113 |
| 114 void alphaBlendNonPremultiplied(WebCore::ImageFrame& src, WebCore::ImageFrame& d
st, int canvasY, int left, int width) | 114 void alphaBlendNonPremultiplied(blink::ImageFrame& src, blink::ImageFrame& dst,
int canvasY, int left, int width) |
| 115 { | 115 { |
| 116 for (int x = 0; x < width; ++x) { | 116 for (int x = 0; x < width; ++x) { |
| 117 int canvasX = left + x; | 117 int canvasX = left + x; |
| 118 WebCore::ImageFrame::PixelData& pixel = *src.getAddr(canvasX, canvasY); | 118 blink::ImageFrame::PixelData& pixel = *src.getAddr(canvasX, canvasY); |
| 119 if (SkGetPackedA32(pixel) != 0xff) { | 119 if (SkGetPackedA32(pixel) != 0xff) { |
| 120 WebCore::ImageFrame::PixelData prevPixel = *dst.getAddr(canvasX, can
vasY); | 120 blink::ImageFrame::PixelData prevPixel = *dst.getAddr(canvasX, canva
sY); |
| 121 pixel = blendSrcOverDstNonPremultiplied(pixel, prevPixel); | 121 pixel = blendSrcOverDstNonPremultiplied(pixel, prevPixel); |
| 122 } | 122 } |
| 123 } | 123 } |
| 124 } | 124 } |
| 125 | 125 |
| 126 namespace WebCore { | 126 namespace blink { |
| 127 | 127 |
| 128 WEBPImageDecoder::WEBPImageDecoder(ImageSource::AlphaOption alphaOption, | 128 WEBPImageDecoder::WEBPImageDecoder(ImageSource::AlphaOption alphaOption, |
| 129 ImageSource::GammaAndColorProfileOption gammaAndColorProfileOption, | 129 ImageSource::GammaAndColorProfileOption gammaAndColorProfileOption, |
| 130 size_t maxDecodedBytes) | 130 size_t maxDecodedBytes) |
| 131 : ImageDecoder(alphaOption, gammaAndColorProfileOption, maxDecodedBytes) | 131 : ImageDecoder(alphaOption, gammaAndColorProfileOption, maxDecodedBytes) |
| 132 , m_decoder(0) | 132 , m_decoder(0) |
| 133 , m_formatFlags(0) | 133 , m_formatFlags(0) |
| 134 , m_frameBackgroundHasAlpha(false) | 134 , m_frameBackgroundHasAlpha(false) |
| 135 , m_hasColorProfile(false) | 135 , m_hasColorProfile(false) |
| 136 #if USE(QCMSLIB) | 136 #if USE(QCMSLIB) |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 applyPostProcessing(frameIndex); | 603 applyPostProcessing(frameIndex); |
| 604 return false; | 604 return false; |
| 605 } | 605 } |
| 606 // FALLTHROUGH | 606 // FALLTHROUGH |
| 607 default: | 607 default: |
| 608 clear(); | 608 clear(); |
| 609 return setFailed(); | 609 return setFailed(); |
| 610 } | 610 } |
| 611 } | 611 } |
| 612 | 612 |
| 613 } // namespace WebCore | 613 } // namespace blink |
| OLD | NEW |