Changeset 52206 in webkit
- Timestamp:
- Dec 16, 2009 11:00:25 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r52205 r52206 1 2009-12-16 Benjamin Otte <otte@gnome.org> 2 3 Reviewed by Darin Adler. 4 5 Get rid of the phase argument to Image::drawPattern. 6 https://bugs.webkit.org/show_bug.cgi?id=31187 7 8 The argument can be expressed equally well as part of the 9 patternTransform. All backends but the Qt one did exactly that 10 manually anyway. 11 12 * platform/graphics/BitmapImage.h: 13 * platform/graphics/GeneratedImage.cpp: 14 (WebCore::GeneratedImage::drawPattern): 15 * platform/graphics/GeneratedImage.h: 16 * platform/graphics/Image.cpp: 17 (WebCore::Image::drawTiled): 18 * platform/graphics/Image.h: 19 * platform/graphics/cairo/ImageCairo.cpp: 20 (WebCore::Image::drawPattern): 21 * platform/graphics/cg/ImageCG.cpp: 22 (WebCore::Image::drawPattern): 23 * platform/graphics/haiku/ImageHaiku.cpp: 24 (WebCore::Image::drawPattern): 25 * platform/graphics/qt/ImageQt.cpp: 26 (WebCore::Image::drawPattern): 27 * platform/graphics/skia/ImageSkia.cpp: 28 (WebCore::Image::drawPattern): 29 * platform/graphics/wince/GraphicsContextWince.cpp: 30 (WebCore::GraphicsContext::drawBitmapPattern): 31 * platform/graphics/wince/ImageBufferWince.cpp: 32 (WebCore::): 33 (WebCore::BufferedImage::drawPattern): 34 * platform/graphics/wx/ImageWx.cpp: 35 (WebCore::BitmapImage::drawPattern): 36 (WebCore::Image::drawPattern): 37 1 38 2009-12-16 Kenneth Russell <kbr@google.com> 2 39 -
trunk/WebCore/platform/graphics/BitmapImage.h
r51212 r52206 172 172 #if PLATFORM(WX) || (PLATFORM(WINCE) && !PLATFORM(QT)) 173 173 virtual void drawPattern(GraphicsContext*, const FloatRect& srcRect, const TransformationMatrix& patternTransform, 174 const FloatPoint& phase,ColorSpace styleColorSpace, CompositeOperator, const FloatRect& destRect);174 ColorSpace styleColorSpace, CompositeOperator, const FloatRect& destRect); 175 175 #endif 176 176 -
trunk/WebCore/platform/graphics/GeneratedImage.cpp
r51212 r52206 49 49 50 50 void GeneratedImage::drawPattern(GraphicsContext* context, const FloatRect& srcRect, const TransformationMatrix& patternTransform, 51 const FloatPoint& phase,ColorSpace styleColorSpace, CompositeOperator compositeOp, const FloatRect& destRect)51 ColorSpace styleColorSpace, CompositeOperator compositeOp, const FloatRect& destRect) 52 52 { 53 53 // Create a BitmapImage and call drawPattern on it. … … 63 63 64 64 // Now just call drawTiled on that image. 65 bitmap->drawPattern(context, srcRect, patternTransform, phase,styleColorSpace, compositeOp, destRect);65 bitmap->drawPattern(context, srcRect, patternTransform, styleColorSpace, compositeOp, destRect); 66 66 } 67 67 -
trunk/WebCore/platform/graphics/GeneratedImage.h
r51212 r52206 60 60 virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator); 61 61 virtual void drawPattern(GraphicsContext*, const FloatRect& srcRect, const TransformationMatrix& patternTransform, 62 const FloatPoint& phase,ColorSpace styleColorSpace, CompositeOperator, const FloatRect& destRect);62 ColorSpace styleColorSpace, CompositeOperator, const FloatRect& destRect); 63 63 64 64 GeneratedImage(PassRefPtr<Generator> generator, const IntSize& size) -
trunk/WebCore/platform/graphics/Image.cpp
r51212 r52206 137 137 } 138 138 139 TransformationMatrix patternTransform = TransformationMatrix().scaleNonUniform(scale.width(), scale.height()); 139 TransformationMatrix patternTransform = TransformationMatrix(); 140 patternTransform.translate(oneTileRect.x(), oneTileRect.y()); 141 patternTransform.scaleNonUniform(scale.width(), scale.height()); 142 140 143 FloatRect tileRect(FloatPoint(), intrinsicTileSize); 141 drawPattern(ctxt, tileRect, patternTransform, oneTileRect.location(),styleColorSpace, op, destRect);144 drawPattern(ctxt, tileRect, patternTransform, styleColorSpace, op, destRect); 142 145 143 146 startAnimation(); … … 159 162 160 163 FloatSize scale = calculatePatternScale(dstRect, srcRect, hRule, vRule); 161 TransformationMatrix patternTransform = TransformationMatrix().scaleNonUniform(scale.width(), scale.height());162 164 163 165 // We want to construct the phase such that the pattern is centered (when stretch is not … … 169 171 if (vRule == Image::RepeatTile) 170 172 vPhase -= fmodf(dstRect.height(), scale.height() * srcRect.height()) / 2.0f; 171 FloatPoint patternPhase(dstRect.x() - hPhase, dstRect.y() - vPhase); 173 TransformationMatrix patternTransform = TransformationMatrix(); 174 patternTransform.translate(dstRect.x() - hPhase, dstRect.y() - vPhase); 175 patternTransform.scaleNonUniform(scale.width(), scale.height()); 172 176 173 drawPattern(ctxt, srcRect, patternTransform, patternPhase,styleColorSpace, op, dstRect);177 drawPattern(ctxt, srcRect, patternTransform, styleColorSpace, op, dstRect); 174 178 175 179 startAnimation(); -
trunk/WebCore/platform/graphics/Image.h
r51212 r52206 171 171 172 172 virtual void drawPattern(GraphicsContext*, const FloatRect& srcRect, const TransformationMatrix& patternTransform, 173 const FloatPoint& phase,ColorSpace styleColorSpace, CompositeOperator, const FloatRect& destRect);173 ColorSpace styleColorSpace, CompositeOperator, const FloatRect& destRect); 174 174 175 175 private: -
trunk/WebCore/platform/graphics/cairo/ImageCairo.cpp
r51212 r52206 172 172 173 173 void Image::drawPattern(GraphicsContext* context, const FloatRect& tileRect, const TransformationMatrix& patternTransform, 174 const FloatPoint& phase,ColorSpace, CompositeOperator op, const FloatRect& destRect)174 ColorSpace, CompositeOperator op, const FloatRect& destRect) 175 175 { 176 176 cairo_surface_t* image = nativeImageForCurrentFrame(); 177 177 if (!image) // If it's too early we won't have an image yet. 178 178 return; 179 180 // Avoid NaN181 if (!isfinite(phase.x()) || !isfinite(phase.y()))182 return;183 179 184 180 cairo_t* cr = context->platformContext(); … … 201 197 cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REPEAT); 202 198 203 cairo_matrix_t pattern_matrix = cairo_matrix_t(patternTransform); 204 cairo_matrix_t phase_matrix = {1, 0, 0, 1, phase.x() + tileRect.x() * patternTransform.a(), phase.y() + tileRect.y() * patternTransform.d()}; 205 cairo_matrix_t combined; 206 cairo_matrix_multiply(&combined, &pattern_matrix, &phase_matrix); 207 cairo_matrix_invert(&combined); 208 cairo_pattern_set_matrix(pattern, &combined); 199 cairo_matrix_t patternMatrix = cairo_matrix_t(patternTransform); 200 cairo_matrix_t phaseMatrix = {1, 0, 0, 1, tileRect.x() * patternTransform.a(), tileRect.y() * patternTransform.d()}; 201 cairo_matrix_t combinedMatrix; 202 cairo_matrix_multiply(&combinedMatrix, &patternMatrix, &phaseMatrix); 203 cairo_matrix_invert(&combinedMatrix); 204 cairo_pattern_set_matrix(pattern, &combinedMatrix); 205 if (cairo_pattern_status(pattern)) { 206 cairo_pattern_destroy(pattern); 207 return; 208 } 209 209 210 210 context->setCompositeOperation(op); -
trunk/WebCore/platform/graphics/cg/ImageCG.cpp
r51313 r52206 246 246 247 247 void Image::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRect, const TransformationMatrix& patternTransform, 248 const FloatPoint& phase,ColorSpace styleColorSpace, CompositeOperator op, const FloatRect& destRect)248 ColorSpace styleColorSpace, CompositeOperator op, const FloatRect& destRect) 249 249 { 250 250 if (!nativeImageForCurrentFrame()) … … 268 268 // We have to adjust the phase to deal with the fact we're in Cartesian space now (with the bottom left corner of destRect being 269 269 // the origin). 270 float adjustedX = phase.x()- destRect.x() + tileRect.x() * narrowPrecisionToFloat(patternTransform.a()); // We translated the context so that destRect.x() is the origin, so subtract it out.271 float adjustedY = destRect.height() - (phase.y() - destRect.y() + tileRect.y() * narrowPrecisionToFloat(patternTransform.d()) + scaledTileHeight);270 float adjustedX = - destRect.x() + tileRect.x() * narrowPrecisionToFloat(patternTransform.a()); // We translated the context so that destRect.x() is the origin, so subtract it out. 271 float adjustedY = destRect.height() + destRect.y() - tileRect.y() * narrowPrecisionToFloat(patternTransform.d()) - scaledTileHeight; 272 272 273 273 CGImageRef tileImage = nativeImageForCurrentFrame(); -
trunk/WebCore/platform/graphics/haiku/ImageHaiku.cpp
r51212 r52206 110 110 } 111 111 112 void Image::drawPattern(GraphicsContext* context, const FloatRect& tileRect, const TransformationMatrix& patternTransform, const FloatPoint& srcPoint,ColorSpace, CompositeOperator op, const FloatRect& dstRect)112 void Image::drawPattern(GraphicsContext* context, const FloatRect& tileRect, const TransformationMatrix& patternTransform, ColorSpace, CompositeOperator op, const FloatRect& dstRect) 113 113 { 114 // FIXME: finish this to support also phased position (srcPoint)115 114 startAnimation(); 116 115 -
trunk/WebCore/platform/graphics/qt/ImageQt.cpp
r51212 r52206 95 95 96 96 void Image::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRect, const TransformationMatrix& patternTransform, 97 const FloatPoint& phase,ColorSpace, CompositeOperator op, const FloatRect& destRect)97 ColorSpace, CompositeOperator op, const FloatRect& destRect) 98 98 { 99 99 QPixmap* framePixmap = nativeImageForCurrentFrame(); … … 113 113 if (!pixmap.hasAlpha() && p->compositionMode() == QPainter::CompositionMode_SourceOver) 114 114 p->setCompositionMode(QPainter::CompositionMode_Source); 115 p->setBrushOrigin(phase);116 115 p->fillRect(destRect, b); 117 116 ctxt->restore(); -
trunk/WebCore/platform/graphics/skia/ImageSkia.cpp
r51212 r52206 302 302 const FloatRect& floatSrcRect, 303 303 const TransformationMatrix& patternTransform, 304 const FloatPoint& phase,305 304 ColorSpace styleColorSpace, 306 305 CompositeOperator compositeOp, … … 366 365 // the coordinate system origin as the base for the patter. If WebKit wants 367 366 // a shifted image, it will shift it from there using the patternTransform. 368 float adjustedX = phase.x() +normSrcRect.x() *367 float adjustedX = normSrcRect.x() * 369 368 narrowPrecisionToFloat(patternTransform.a()); 370 float adjustedY = phase.y() +normSrcRect.y() *369 float adjustedY = normSrcRect.y() * 371 370 narrowPrecisionToFloat(patternTransform.d()); 372 371 matrix.postTranslate(SkFloatToScalar(adjustedX), -
trunk/WebCore/platform/graphics/wince/GraphicsContextWince.cpp
r51161 r52206 1872 1872 1873 1873 void GraphicsContext::drawBitmapPattern(SharedBitmap* bmp, const FloatRect& tileRectIn, const TransformationMatrix& patternTransform, 1874 const FloatPoint& phase,CompositeOperator op, const FloatRect& destRectIn, const IntSize& origSourceSize)1874 CompositeOperator op, const FloatRect& destRectIn, const IntSize& origSourceSize) 1875 1875 { 1876 1876 if (!m_data->m_opacity) … … 1893 1893 transform.translate(moved.width(), moved.height()); 1894 1894 1895 bmp->drawPattern(dc, transform, tileRectIn, patternTransform, phase,op, destRectIn, origSourceSize);1895 bmp->drawPattern(dc, transform, tileRectIn, patternTransform, op, destRectIn, origSourceSize); 1896 1896 1897 1897 if (!bmp->hasAlpha()) -
trunk/WebCore/platform/graphics/wince/ImageBufferWince.cpp
r47968 r52206 44 44 virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, CompositeOperator); 45 45 virtual void drawPattern(GraphicsContext*, const FloatRect& srcRect, const TransformationMatrix& patternTransform, 46 const FloatPoint& phase,CompositeOperator, const FloatRect& destRect);46 CompositeOperator, const FloatRect& destRect); 47 47 48 48 const ImageBufferData* m_data; … … 57 57 58 58 void BufferedImage::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRectIn, const TransformationMatrix& patternTransform, 59 const FloatPoint& phase,CompositeOperator op, const FloatRect& destRect)60 { 61 m_data->m_bitmap->drawPattern(ctxt, tileRectIn, patternTransform, phase,op, destRect, size());59 CompositeOperator op, const FloatRect& destRect) 60 { 61 m_data->m_bitmap->drawPattern(ctxt, tileRectIn, patternTransform, op, destRect, size()); 62 62 } 63 63 -
trunk/WebCore/platform/graphics/wx/ImageWx.cpp
r51419 r52206 177 177 } 178 178 179 void BitmapImage::drawPattern(GraphicsContext* ctxt, const FloatRect& srcRect, const TransformationMatrix& patternTransform, const FloatPoint& phase,ColorSpace, CompositeOperator, const FloatRect& dstRect)179 void BitmapImage::drawPattern(GraphicsContext* ctxt, const FloatRect& srcRect, const TransformationMatrix& patternTransform, ColorSpace, CompositeOperator, const FloatRect& dstRect) 180 180 { 181 181 if (!m_source.initialized()) … … 202 202 wxGraphicsContext* gc = context->GetGraphicsContext(); 203 203 204 float adjustedX = phase.x() + srcRect.x() * 205 narrowPrecisionToFloat(patternTransform.a()); 206 float adjustedY = phase.y() + srcRect.y() * 207 narrowPrecisionToFloat(patternTransform.d()); 204 float adjustedX = srcRect.x() * narrowPrecisionToFloat(patternTransform.a()); 205 float adjustedY = srcRect.y() * narrowPrecisionToFloat(patternTransform.d()); 208 206 209 207 gc->ConcatTransform(patternTransform); … … 262 260 } 263 261 264 void Image::drawPattern(GraphicsContext*, const FloatRect& srcRect, const TransformationMatrix& patternTransform, const FloatPoint& phase,ColorSpace, CompositeOperator, const FloatRect& destRect)262 void Image::drawPattern(GraphicsContext*, const FloatRect& srcRect, const TransformationMatrix& patternTransform, ColorSpace, CompositeOperator, const FloatRect& destRect) 265 263 { 266 264 notImplemented();
Note: See TracChangeset
for help on using the changeset viewer.