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 * Copyright (C) 2011 Igalia S.L. | 4 * Copyright (C) 2011 Igalia S.L. |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 unsigned int srcUnpackAlignment = 1; | 178 unsigned int srcUnpackAlignment = 1; |
179 size_t bytesPerRow = cairo_image_surface_get_stride(imageSurface.get()); | 179 size_t bytesPerRow = cairo_image_surface_get_stride(imageSurface.get()); |
180 size_t bitsPerPixel = 32; | 180 size_t bitsPerPixel = 32; |
181 unsigned int padding = bytesPerRow - bitsPerPixel / 8 * width; | 181 unsigned int padding = bytesPerRow - bitsPerPixel / 8 * width; |
182 if (padding) { | 182 if (padding) { |
183 srcUnpackAlignment = padding + 1; | 183 srcUnpackAlignment = padding + 1; |
184 while (bytesPerRow % srcUnpackAlignment) | 184 while (bytesPerRow % srcUnpackAlignment) |
185 ++srcUnpackAlignment; | 185 ++srcUnpackAlignment; |
186 } | 186 } |
187 | 187 |
188 outputVector.resize(width * height * 4); | 188 unsigned int packedSize; |
| 189 // Output data is tightly packed (alignment == 1). |
| 190 if (computeImageSizeInBytes(format, type, width, height, 1, &packedSize, 0)
!= GraphicsContext3D::NO_ERROR) |
| 191 return false; |
| 192 outputVector.resize(packedSize); |
| 193 |
189 return packPixels(cairo_image_surface_get_data(imageSurface.get()), SourceFo
rmatBGRA8, | 194 return packPixels(cairo_image_surface_get_data(imageSurface.get()), SourceFo
rmatBGRA8, |
190 width, height, srcUnpackAlignment, format, type, alphaOp,
outputVector.data()); | 195 width, height, srcUnpackAlignment, format, type, alphaOp,
outputVector.data()); |
191 } | 196 } |
192 | 197 |
193 void GraphicsContext3D::paintToCanvas(const unsigned char* imagePixels, int imag
eWidth, int imageHeight, int canvasWidth, int canvasHeight, PlatformContextCairo
* context) | 198 void GraphicsContext3D::paintToCanvas(const unsigned char* imagePixels, int imag
eWidth, int imageHeight, int canvasWidth, int canvasHeight, PlatformContextCairo
* context) |
194 { | 199 { |
195 if (!imagePixels || imageWidth <= 0 || imageHeight <= 0 || canvasWidth <= 0
|| canvasHeight <= 0 || !context) | 200 if (!imagePixels || imageWidth <= 0 || imageHeight <= 0 || canvasWidth <= 0
|| canvasHeight <= 0 || !context) |
196 return; | 201 return; |
197 | 202 |
198 cairo_t *cr = context->cr(); | 203 cairo_t *cr = context->cr(); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 #if USE(ACCELERATED_COMPOSITING) | 249 #if USE(ACCELERATED_COMPOSITING) |
245 PlatformLayer* GraphicsContext3D::platformLayer() const | 250 PlatformLayer* GraphicsContext3D::platformLayer() const |
246 { | 251 { |
247 return m_private.get(); | 252 return m_private.get(); |
248 } | 253 } |
249 #endif | 254 #endif |
250 | 255 |
251 } // namespace WebCore | 256 } // namespace WebCore |
252 | 257 |
253 #endif // ENABLE(WEBGL) | 258 #endif // ENABLE(WEBGL) |
OLD | NEW |