Changeset 130672 in webkit
- Timestamp:
- Oct 8, 2012, 12:14:53 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/platform/qt/TestExpectations (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r130670 r130672 1 2012-10-08 Huang Dongsung <luxtella@company100.net> 2 3 [Qt] Make ImageBufferQt use premultiplied converting functions in Color.h instead of its own mechanism. 4 https://bugs.webkit.org/show_bug.cgi?id=98582 5 6 Reviewed by Eric Seidel. 7 8 Unskipping canvas/philip/tests/2d.imageData.put.unchanged.html that is passing. 9 10 * platform/qt/TestExpectations: 11 1 12 2012-10-08 Shadi Khalek <shadi@chromium.org> 2 13 -
trunk/LayoutTests/platform/qt/TestExpectations
r130655 r130672 2107 2107 canvas/philip/tests/2d.gradient.radial.touch2.html 2108 2108 canvas/philip/tests/2d.gradient.radial.touch3.html 2109 canvas/philip/tests/2d.imageData.put.unchanged.html2110 2109 canvas/philip/tests/2d.line.cap.open.html 2111 2110 canvas/philip/tests/2d.line.join.open.html -
trunk/Source/WebCore/ChangeLog
r130668 r130672 1 2012-10-08 Huang Dongsung <luxtella@company100.net> 2 3 [Qt] Make ImageBufferQt use premultiplied converting functions in Color.h instead of its own mechanism. 4 https://bugs.webkit.org/show_bug.cgi?id=98582 5 6 Reviewed by Eric Seidel. 7 8 Only Qt port failed canvas/philip/tests/2d.imageData.put.unchanged.html because 9 ImageBufferQt converts from or to a premultiplied color using its own code. When 10 we convert twice from an unmultiplied color to a premultiplied color and then to 11 an unmultiplied color using this code, the calculated result are pretty 12 different against the input color. It is why Gtk passes this test although Qt 13 fails. Gtk port uses them in Color.h. 14 15 In addition, Qt should use the functions in Color.h to reduce duplicated codes. 16 17 Tests: canvas/philip/tests/2d.imageData.put.unchanged.html: Fixed a test case 18 19 * platform/graphics/qt/ImageBufferQt.cpp: 20 (WebCore::getImageData): 21 (WebCore::convertBGRAToRGBA): 22 (WebCore::ImageBuffer::putByteArray): 23 1 24 2012-10-08 Tab Atkins <jackalmage@gmail.com> 2 25 -
trunk/Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp
r130636 r130672 189 189 } 190 190 191 static inline quint32 convertABGRToARGB(quint32 pixel) 192 { 193 return ((pixel << 16) & 0xff0000) | ((pixel >> 16) & 0xff) | (pixel & 0xff00ff00); 194 } 195 196 static inline quint32 convertARGBToABGR(quint32 pixel) 197 { 198 return convertABGRToARGB(pixel); 199 } 200 191 201 template <Multiply multiplied> 192 202 PassRefPtr<Uint8ClampedArray> getImageData(const IntRect& rect, const ImageBufferData& imageData, const IntSize& size) … … 233 243 234 244 quint32* destRows = reinterpret_cast_ptr<quint32*>(&data[desty * rect.width() * 4 + destx * 4]); 235 236 if (multiplied == Unmultiplied) { 237 for (int y = 0; y < numRows; ++y) { 238 const quint32* scanLine = reinterpret_cast_ptr<const quint32*>(bits + (y + originy) * bytesPerLine); 239 for (int x = 0; x < numColumns; x++) { 240 QRgb pixel = scanLine[x + originx]; 241 int alpha = qAlpha(pixel); 242 // Un-premultiply and convert RGB to BGR. 243 if (alpha == 255) 244 destRows[x] = (0xFF000000 245 | (qBlue(pixel) << 16) 246 | (qGreen(pixel) << 8) 247 | (qRed(pixel))); 248 else if (alpha > 0) 249 destRows[x] = ((alpha << 24) 250 | (((255 * qBlue(pixel)) / alpha)) << 16) 251 | (((255 * qGreen(pixel)) / alpha) << 8) 252 | ((255 * qRed(pixel)) / alpha); 253 else 254 destRows[x] = 0; 255 } 256 destRows += rect.width(); 245 for (int y = 0; y < numRows; ++y) { 246 const quint32* scanLine = reinterpret_cast_ptr<const quint32*>(bits + (y + originy) * bytesPerLine); 247 for (int x = 0; x < numColumns; x++) { 248 QRgb pixel = scanLine[x + originx]; 249 Color pixelColor; 250 if (multiplied == Unmultiplied) 251 pixelColor = colorFromPremultipliedARGB(Color(qRed(pixel), qGreen(pixel), qBlue(pixel), qAlpha(pixel)).rgb()); 252 else 253 pixelColor = Color(qRed(pixel), qGreen(pixel), qBlue(pixel), qAlpha(pixel)); 254 destRows[x] = convertARGBToABGR(pixelColor.rgb()); 257 255 } 258 } else { 259 for (int y = 0; y < numRows; ++y) { 260 const quint32* scanLine = reinterpret_cast_ptr<const quint32*>(bits + (y + originy) * bytesPerLine); 261 for (int x = 0; x < numColumns; x++) { 262 QRgb pixel = scanLine[x + originx]; 263 // Convert RGB to BGR. 264 destRows[x] = ((pixel << 16) & 0xff0000) | ((pixel >> 16) & 0xff) | (pixel & 0xff00ff00); 265 266 } 267 destRows += rect.width(); 268 } 256 destRows += rect.width(); 269 257 } 270 258 … … 280 268 { 281 269 return getImageData<Premultiplied>(rect, m_data, m_size); 282 }283 284 static inline unsigned int premultiplyABGRtoARGB(unsigned int x)285 {286 unsigned int a = x >> 24;287 if (a == 255)288 return (x << 16) | ((x >> 16) & 0xff) | (x & 0xff00ff00);289 unsigned int t = (x & 0xff00ff) * a;290 t = (t + ((t >> 8) & 0xff00ff) + 0x800080) >> 8;291 t = ((t << 16) | (t >> 16)) & 0xff00ff;292 293 x = ((x >> 8) & 0xff) * a;294 x = (x + ((x >> 8) & 0xff) + 0x80);295 x &= 0xff00;296 x |= t | (a << 24);297 return x;298 270 } 299 271 … … 335 307 const quint32* srcScanLine = reinterpret_cast_ptr<const quint32*>(source->data() + originy * srcBytesPerRow + originx * 4); 336 308 337 if (multiplied == Unmultiplied) { 338 for (int y = 0; y < numRows; ++y) { 339 quint32* destScanLine = reinterpret_cast_ptr<quint32*>(bits + y * bytesPerLine); 340 for (int x = 0; x < numColumns; x++) { 341 // Premultiply and convert BGR to RGB. 342 quint32 pixel = srcScanLine[x]; 343 destScanLine[x] = premultiplyABGRtoARGB(pixel); 344 } 345 srcScanLine += sourceSize.width(); 309 for (int y = 0; y < numRows; ++y) { 310 quint32* destScanLine = reinterpret_cast_ptr<quint32*>(bits + y * bytesPerLine); 311 for (int x = 0; x < numColumns; x++) { 312 quint32 pixel = convertABGRToARGB(srcScanLine[x]); 313 if (multiplied == Unmultiplied) 314 destScanLine[x] = premultipliedARGBFromColor(Color(pixel)); 315 else 316 destScanLine[x] = pixel; 346 317 } 347 } else { 348 for (int y = 0; y < numRows; ++y) { 349 quint32* destScanLine = reinterpret_cast_ptr<quint32*>(bits + y * bytesPerLine); 350 for (int x = 0; x < numColumns; x++) { 351 // Convert BGR to RGB. 352 quint32 pixel = srcScanLine[x]; 353 destScanLine[x] = ((pixel << 16) & 0xff0000) | ((pixel >> 16) & 0xff) | (pixel & 0xff00ff00); 354 } 355 srcScanLine += sourceSize.width(); 356 } 318 srcScanLine += sourceSize.width(); 357 319 } 358 320
Note:
See TracChangeset
for help on using the changeset viewer.