OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Alex Mathews <possessedpenguinbob@gmail.com> | 2 * Copyright (C) 2008 Alex Mathews <possessedpenguinbob@gmail.com> |
3 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> | 3 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> |
4 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 4 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
5 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 | 111 |
112 PassRefPtr<ByteArray> FilterEffect::asPremultipliedImage(const IntRect& rect) | 112 PassRefPtr<ByteArray> FilterEffect::asPremultipliedImage(const IntRect& rect) |
113 { | 113 { |
114 RefPtr<ByteArray> imageData = ByteArray::create(rect.width() * rect.height()
* 4); | 114 RefPtr<ByteArray> imageData = ByteArray::create(rect.width() * rect.height()
* 4); |
115 copyPremultipliedImage(imageData.get(), rect); | 115 copyPremultipliedImage(imageData.get(), rect); |
116 return imageData.release(); | 116 return imageData.release(); |
117 } | 117 } |
118 | 118 |
119 inline void FilterEffect::copyImageBytes(ByteArray* source, ByteArray* destinati
on, const IntRect& rect) | 119 inline void FilterEffect::copyImageBytes(ByteArray* source, ByteArray* destinati
on, const IntRect& rect) |
120 { | 120 { |
121 // Copy the necessary lines. | 121 // Initialize the destination to transparent black, if not entirely covered
by the source. |
122 if (rect.x() < 0 || rect.y() < 0 || rect.maxY() > m_absolutePaintRect.width(
) || rect.maxY() > m_absolutePaintRect.height()) | 122 if (rect.x() < 0 || rect.y() < 0 || rect.maxX() > m_absolutePaintRect.width(
) || rect.maxY() > m_absolutePaintRect.height()) |
123 memset(destination->data(), 0, destination->length()); | 123 memset(destination->data(), 0, destination->length()); |
124 | 124 |
| 125 // Early return if the rect does not intersect with the source. |
| 126 if (rect.maxX() <= 0 || rect.maxY() <= 0 || rect.x() >= m_absolutePaintRect.
width() || rect.y() >= m_absolutePaintRect.height()) |
| 127 return; |
| 128 |
125 int xOrigin = rect.x(); | 129 int xOrigin = rect.x(); |
126 int xDest = 0; | 130 int xDest = 0; |
127 if (xOrigin < 0) { | 131 if (xOrigin < 0) { |
128 xDest = -xOrigin; | 132 xDest = -xOrigin; |
129 xOrigin = 0; | 133 xOrigin = 0; |
130 } | 134 } |
131 int xEnd = rect.maxX(); | 135 int xEnd = rect.maxX(); |
132 if (xEnd > m_absolutePaintRect.width()) | 136 if (xEnd > m_absolutePaintRect.width()) |
133 xEnd = m_absolutePaintRect.width(); | 137 xEnd = m_absolutePaintRect.width(); |
134 | 138 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 TextStream& FilterEffect::externalRepresentation(TextStream& ts, int) const | 259 TextStream& FilterEffect::externalRepresentation(TextStream& ts, int) const |
256 { | 260 { |
257 // FIXME: We should dump the subRegions of the filter primitives here later.
This isn't | 261 // FIXME: We should dump the subRegions of the filter primitives here later.
This isn't |
258 // possible at the moment, because we need more detailed informations from t
he target object. | 262 // possible at the moment, because we need more detailed informations from t
he target object. |
259 return ts; | 263 return ts; |
260 } | 264 } |
261 | 265 |
262 } // namespace WebCore | 266 } // namespace WebCore |
263 | 267 |
264 #endif // ENABLE(FILTERS) | 268 #endif // ENABLE(FILTERS) |
OLD | NEW |