Changeset 64506 in webkit
- Timestamp:
- Aug 2, 2010 4:51:56 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r64504 r64506 1 2010-08-02 Martin Robinson <mrobinson@igalia.com> 2 3 Reviewed by Xan Lopez. 4 5 [GTK] Use GdkPixbuf for ImageBuffer::toDataURL 6 https://bugs.webkit.org/show_bug.cgi?id=43088 7 8 * platform/gtk/Skipped: Generate results for a toDataURL test and unskip it. 9 1 10 2010-08-02 Anders Carlsson <andersca@apple.com> 2 11 -
trunk/LayoutTests/platform/gtk/Skipped
r64459 r64506 1082 1082 fast/canvas/canvas-zoom.html 1083 1083 fast/canvas/pointInPath.html 1084 fast/canvas/toDataURL-supportedTypes.html1085 1084 fast/css/css1_forward_compatible_parsing.html 1086 1085 fast/css/invalid-percentage-property.html -
trunk/WebCore/ChangeLog
r64505 r64506 1 2010-08-02 Martin Robinson <mrobinson@igalia.com> 2 3 Reviewed by Xan Lopez. 4 5 [GTK] Use GdkPixbuf for ImageBuffer::toDataURL 6 https://bugs.webkit.org/show_bug.cgi?id=43088 7 8 Implement ImageBuffer::toDataURL with GdkPixbuf instead of Cairo. This 9 allows the method to support a larger variety of image types. 10 11 * GNUmakefile.am: Add new files to the source list. 12 * platform/MIMETypeRegistry.cpp: 13 (WebCore::initializeSupportedImageMIMETypesForEncoding): 14 Add the list of image types supported by GTK. 15 * platform/graphics/cairo/ImageBufferCairo.cpp: 16 * platform/graphics/gtk/CairoUtilities.cpp: Added. 17 (getCairoSurfacePixel): Move this method from ImageGtk.cpp. 18 (getGdkPixbufPixel): Move this method from ImageGtk.cpp. 19 (cairoImageSurfaceToGdkPixbuf): Move this method from ImageGtk.cpp. 20 * platform/graphics/gtk/CairoUtilities.h: Added. 21 * platform/graphics/gtk/ImageBufferGtk.cpp: Added. 22 (WebCore::ImageBuffer::toDataURL): Use GdkPixbuf to do the conversion to a data url. 23 * platform/graphics/gtk/ImageGtk.cpp: 24 (WebCore::BitmapImage::getGdkPixbuf): Use the new helper method in CairoUtilities.h. 25 1 26 2010-08-02 Xan Lopez <xlopez@igalia.com> 2 27 -
trunk/WebCore/GNUmakefile.am
r64471 r64506 2433 2433 WebCore/platform/graphics/cairo/TransformationMatrixCairo.cpp \ 2434 2434 WebCore/platform/graphics/gtk/ColorGtk.cpp \ 2435 WebCore/platform/graphics/gtk/CairoUtilities.cpp \ 2436 WebCore/platform/graphics/gtk/CairoUtilities.h \ 2435 2437 WebCore/platform/graphics/gtk/FontGtk.cpp \ 2436 2438 WebCore/platform/graphics/gtk/IconGtk.cpp \ 2439 WebCore/platform/graphics/gtk/ImageBufferGtk.cpp \ 2437 2440 WebCore/platform/graphics/gtk/ImageGtk.cpp \ 2438 2441 WebCore/platform/graphics/gtk/IntPointGtk.cpp \ -
trunk/WebCore/platform/MIMETypeRegistry.cpp
r63239 r64506 157 157 158 158 supportedImageMIMETypesForEncoding->remove("application/octet-stream"); 159 #elif PLATFORM(GTK) 160 supportedImageMIMETypesForEncoding->add("image/png"); 161 supportedImageMIMETypesForEncoding->add("image/jpeg"); 162 supportedImageMIMETypesForEncoding->add("image/tiff"); 163 supportedImageMIMETypesForEncoding->add("image/bmp"); 164 supportedImageMIMETypesForEncoding->add("image/ico"); 159 165 #elif PLATFORM(CAIRO) 160 166 supportedImageMIMETypesForEncoding->add("image/png"); -
trunk/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp
r60675 r64506 278 278 } 279 279 280 #if !PLATFORM(GTK) 280 281 static cairo_status_t writeFunction(void* closure, const unsigned char* data, unsigned int length) 281 282 { … … 304 305 return "data:" + actualMimeType + ";base64," + String(out.data(), out.size()); 305 306 } 307 #endif 306 308 307 309 } // namespace WebCore -
trunk/WebCore/platform/graphics/gtk/ImageGtk.cpp
r59868 r64506 27 27 28 28 #include "BitmapImage.h" 29 #include "CairoUtilities.h" 29 30 #include "GOwnPtr.h" 30 31 #include "SharedBuffer.h" … … 173 174 } 174 175 175 static inline unsigned char* getCairoSurfacePixel(unsigned char* data, unsigned x, unsigned y, unsigned rowStride)176 {177 return data + (y * rowStride) + x * 4;178 }179 180 static inline guchar* getGdkPixbufPixel(guchar* data, unsigned x, unsigned y, unsigned rowStride)181 {182 return data + (y * rowStride) + x * 4;183 }184 185 176 GdkPixbuf* BitmapImage::getGdkPixbuf() 186 177 { 187 int width = cairo_image_surface_get_width(frameAtIndex(currentFrame())); 188 int height = cairo_image_surface_get_height(frameAtIndex(currentFrame())); 189 unsigned char* surfaceData = cairo_image_surface_get_data(frameAtIndex(currentFrame())); 190 int surfaceRowStride = cairo_image_surface_get_stride(frameAtIndex(currentFrame())); 191 192 GdkPixbuf* dest = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, width, height); 193 if (!dest) 194 return 0; 195 196 guchar* pixbufData = gdk_pixbuf_get_pixels(dest); 197 int pixbufRowStride = gdk_pixbuf_get_rowstride(dest); 198 199 /* From: http://cairographics.org/manual/cairo-image-surface.html#cairo-format-t 200 * "CAIRO_FORMAT_ARGB32: each pixel is a 32-bit quantity, with alpha in 201 * the upper 8 bits, then red, then green, then blue. The 32-bit 202 * quantities are stored native-endian. Pre-multiplied alpha is used. 203 * (That is, 50% transparent red is 0x80800000, not 0x80ff0000.)" 204 * 205 * See http://developer.gimp.org/api/2.0/gdk-pixbuf/gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf 206 * for information on the structure of GdkPixbufs stored with GDK_COLORSPACE_RGB. 207 * 208 * RGB color channels in CAIRO_FORMAT_ARGB32 are stored based on the 209 * endianness of the machine and are also multiplied by the alpha channel. 210 * To properly transfer the data from the Cairo surface we must divide each 211 * of the RGB channels by the alpha channel and then reorder all channels 212 * if this machine is little-endian. 213 */ 214 for (int y = 0; y < height; y++) { 215 for (int x = 0; x < width; x++) { 216 unsigned char* source = getCairoSurfacePixel(surfaceData, x, y, surfaceRowStride); 217 guchar* dest = getGdkPixbufPixel(pixbufData, x, y, pixbufRowStride); 218 219 #if G_BYTE_ORDER == G_LITTLE_ENDIAN 220 guchar alpha = source[3]; 221 dest[0] = alpha ? ((source[2] * 255) / alpha) : 0; 222 dest[1] = alpha ? ((source[1] * 255) / alpha) : 0; 223 dest[2] = alpha ? ((source[0] * 255) / alpha) : 0; 224 dest[3] = alpha; 225 #else 226 guchar alpha = source[0]; 227 dest[0] = alpha ? ((source[1] * 255) / alpha) : 0; 228 dest[1] = alpha ? ((source[2] * 255) / alpha) : 0; 229 dest[2] = alpha ? ((source[3] * 255) / alpha) : 0; 230 dest[3] = alpha; 231 #endif 232 } 233 } 234 235 return dest; 178 return cairoImageSurfaceToGdkPixbuf(frameAtIndex(currentFrame())); 236 179 } 237 180
Note: See TracChangeset
for help on using the changeset viewer.