| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2010 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2010 Google Inc. All rights reserved. | 3 * Copyright (C) 2010 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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 } | 233 } |
| 234 SourceDataFormat srcDataFormat = getSourceDataFormat(componentsPerPixel, alp
haFormat, bitsPerComponent == 16, bigEndianSource); | 234 SourceDataFormat srcDataFormat = getSourceDataFormat(componentsPerPixel, alp
haFormat, bitsPerComponent == 16, bigEndianSource); |
| 235 if (srcDataFormat == SourceFormatNumFormats) | 235 if (srcDataFormat == SourceFormatNumFormats) |
| 236 return false; | 236 return false; |
| 237 | 237 |
| 238 RetainPtr<CFDataRef> pixelData; | 238 RetainPtr<CFDataRef> pixelData; |
| 239 pixelData.adoptCF(CGDataProviderCopyData(CGImageGetDataProvider(cgImage))); | 239 pixelData.adoptCF(CGDataProviderCopyData(CGImageGetDataProvider(cgImage))); |
| 240 if (!pixelData) | 240 if (!pixelData) |
| 241 return false; | 241 return false; |
| 242 const UInt8* rgba = CFDataGetBytePtr(pixelData.get()); | 242 const UInt8* rgba = CFDataGetBytePtr(pixelData.get()); |
| 243 outputVector.resize(width * height * 4); | 243 |
| 244 unsigned int packedSize; |
| 245 // Output data is tightly packed (alignment == 1). |
| 246 if (computeImageSizeInBytes(format, type, width, height, 1, &packedSize, 0)
!= GraphicsContext3D::NO_ERROR) |
| 247 return false; |
| 248 outputVector.resize(packedSize); |
| 249 |
| 244 unsigned int srcUnpackAlignment = 0; | 250 unsigned int srcUnpackAlignment = 0; |
| 245 size_t bytesPerRow = CGImageGetBytesPerRow(cgImage); | 251 size_t bytesPerRow = CGImageGetBytesPerRow(cgImage); |
| 246 unsigned int padding = bytesPerRow - bitsPerPixel / 8 * width; | 252 unsigned int padding = bytesPerRow - bitsPerPixel / 8 * width; |
| 247 if (padding) { | 253 if (padding) { |
| 248 srcUnpackAlignment = padding + 1; | 254 srcUnpackAlignment = padding + 1; |
| 249 while (bytesPerRow % srcUnpackAlignment) | 255 while (bytesPerRow % srcUnpackAlignment) |
| 250 ++srcUnpackAlignment; | 256 ++srcUnpackAlignment; |
| 251 } | 257 } |
| 252 bool rt = packPixels(rgba, srcDataFormat, width, height, srcUnpackAlignment, | 258 bool rt = packPixels(rgba, srcDataFormat, width, height, srcUnpackAlignment, |
| 253 format, type, neededAlphaOp, outputVector.data()); | 259 format, type, neededAlphaOp, outputVector.data()); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 271 CGContextSaveGState(context); | 277 CGContextSaveGState(context); |
| 272 CGContextSetBlendMode(context, kCGBlendModeCopy); | 278 CGContextSetBlendMode(context, kCGBlendModeCopy); |
| 273 CGContextSetInterpolationQuality(context, kCGInterpolationNone); | 279 CGContextSetInterpolationQuality(context, kCGInterpolationNone); |
| 274 CGContextDrawImage(context, rect, cgImage.get()); | 280 CGContextDrawImage(context, rect, cgImage.get()); |
| 275 CGContextRestoreGState(context); | 281 CGContextRestoreGState(context); |
| 276 } | 282 } |
| 277 | 283 |
| 278 } // namespace WebCore | 284 } // namespace WebCore |
| 279 | 285 |
| 280 #endif // ENABLE(WEBGL) | 286 #endif // ENABLE(WEBGL) |
| OLD | NEW |