| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 skiaImage = pixels.get(); | 72 skiaImage = pixels.get(); |
| 73 if (hasAlpha && premultiplyAlpha) | 73 if (hasAlpha && premultiplyAlpha) |
| 74 neededAlphaOp = AlphaDoPremultiply; | 74 neededAlphaOp = AlphaDoPremultiply; |
| 75 } else if (!premultiplyAlpha && hasAlpha) | 75 } else if (!premultiplyAlpha && hasAlpha) |
| 76 neededAlphaOp = AlphaDoUnmultiply; | 76 neededAlphaOp = AlphaDoUnmultiply; |
| 77 if (!skiaImage) | 77 if (!skiaImage) |
| 78 return false; | 78 return false; |
| 79 const SkBitmap& skiaImageRef = skiaImage->bitmap(); | 79 const SkBitmap& skiaImageRef = skiaImage->bitmap(); |
| 80 SkAutoLockPixels lock(skiaImageRef); | 80 SkAutoLockPixels lock(skiaImageRef); |
| 81 ASSERT(skiaImageRef.rowBytes() == skiaImageRef.width() * 4); | 81 ASSERT(skiaImageRef.rowBytes() == skiaImageRef.width() * 4); |
| 82 outputVector.resize(skiaImageRef.rowBytes() * skiaImageRef.height()); | 82 unsigned int packedSize; |
| 83 // Output data is tightly packed (alignment == 1). |
| 84 if (computeImageSizeInBytes(format, type, skiaImageRef.width(), skiaImageRef
.height(), 1, &packedSize, 0) != GraphicsContext3D::NO_ERROR) |
| 85 return false; |
| 86 outputVector.resize(packedSize); |
| 83 return packPixels(reinterpret_cast<const uint8_t*>(skiaImageRef.getPixels())
, | 87 return packPixels(reinterpret_cast<const uint8_t*>(skiaImageRef.getPixels())
, |
| 84 SK_B32_SHIFT ? SourceFormatRGBA8 : SourceFormatBGRA8, | 88 SK_B32_SHIFT ? SourceFormatRGBA8 : SourceFormatBGRA8, |
| 85 skiaImageRef.width(), skiaImageRef.height(), 0, | 89 skiaImageRef.width(), skiaImageRef.height(), 0, |
| 86 format, type, neededAlphaOp, outputVector.data()); | 90 format, type, neededAlphaOp, outputVector.data()); |
| 87 } | 91 } |
| 88 | 92 |
| 89 } // namespace WebCore | 93 } // namespace WebCore |
| 90 | 94 |
| 91 #endif // ENABLE(WEBGL) | 95 #endif // ENABLE(WEBGL) |
| OLD | NEW |