external/blend2d/src/blend2d/raster/blrastercontext.cpp
// Create a new `BLRasterFetchData` from a `style`.
//
// Returns a `BLRasterFetchData` instance with reference count set to 1.
Create a new `BLRasterFetchData` from a `style`.
Returns a `BLRasterFetchData` instance with reference count set to 1.
Create a new ` BLRasterFetchData ` from a ` style ` . Returns a ` BLRasterFetchData ` instance with reference count set to 1 .
static BLRasterFetchData* blRasterContextImplCreateFetchData(BLRasterContextImpl* ctxI, BLRasterContextStyleData* style) noexcept {
  const BLMatrix2D& m = style->adjustedMatrix;
  BLMatrix2D mInv;
  if (BL_UNLIKELY(BLMatrix2D::invert(mInv, m) != BL_SUCCESS))
    return nullptr;
  BLRasterFetchData* fetchData = ctxI->fetchPool.alloc();
  if (BL_UNLIKELY(!fetchData))
    return nullptr;
  BLVariantImpl* styleI = style->variant->impl;
  switch (styleI->implType) {
    case BL_IMPL_TYPE_GRADIENT: {
      BLGradientImpl* gradientI = style->gradient->impl;
      BLGradientLUT* lut = blGradientImplEnsureLut32(gradientI);
      if (BL_UNLIKELY(!lut))
        break;
      blRasterFetchDataInitGradient(fetchData, gradientI, lut, m, mInv, style->styleFormat);
      fetchData->refCount = 1;
      fetchData->destroy = blRasterFetchDataDestroyGradient;
      fetchData->gradientLut = lut->incRef();
      return fetchData;
    }
    case BL_IMPL_TYPE_PATTERN: {
      BLPatternImpl* patternI = style->pattern->impl;
      BLImageImpl* imgI = patternI->image.impl;
      BLRectI area = patternI->area;
      if (!blIsValid(area))
        area.reset(0, 0, imgI->size.w, imgI->size.h);
      if (BL_UNLIKELY(!area.w))
        break;
      blRasterFetchDataInitPatternAffine(fetchData, imgI, area, patternI->extendMode, style->quality, m, mInv);
      fetchData->refCount = 1;
      fetchData->destroy = blRasterFetchDataDestroyPattern;
      fetchData->imageI = blImplIncRef(imgI);
      return fetchData;
    }
    default:
      break;
  }
  ctxI->fetchPool.free(fetchData);
  return nullptr;
}
static BLRasterFetchData * blRasterContextImplCreateFetchData ( BLRasterContextImpl * ctxI , BLRasterContextStyleData * style ) noexcept { const BLMatrix2D & m = style -> adjustedMatrix ; BLMatrix2D mInv ; if ( BL_UNLIKELY ( BLMatrix2D :: invert ( mInv , m ) != BL_SUCCESS ) ) return nullptr ; BLRasterFetchData * fetchData = ctxI -> fetchPool . alloc ( ) ; if ( BL_UNLIKELY ( ! fetchData ) ) return nullptr ; BLVariantImpl * styleI = style -> variant -> impl ; switch ( styleI -> implType ) { case BL_IMPL_TYPE_GRADIENT : { BLGradientImpl * gradientI = style -> gradient -> impl ; BLGradientLUT * lut = blGradientImplEnsureLut32 ( gradientI ) ; if ( BL_UNLIKELY ( ! lut ) ) break ; blRasterFetchDataInitGradient ( fetchData , gradientI , lut , m , mInv , style -> styleFormat ) ; fetchData -> refCount = 1 ; fetchData -> destroy = blRasterFetchDataDestroyGradient ; fetchData -> gradientLut = lut -> incRef ( ) ; return fetchData ; } case BL_IMPL_TYPE_PATTERN : { BLPatternImpl * patternI = style -> pattern -> impl ; BLImageImpl * imgI = patternI -> image . impl ; BLRectI area = patternI -> area ; if ( ! blIsValid ( area ) ) area . reset ( 0 , 0 , imgI -> size . w , imgI -> size . h ) ; if ( BL_UNLIKELY ( ! area . w ) ) break ; blRasterFetchDataInitPatternAffine ( fetchData , imgI , area , patternI -> extendMode , style -> quality , m , mInv ) ; fetchData -> refCount = 1 ; fetchData -> destroy = blRasterFetchDataDestroyPattern ; fetchData -> imageI = blImplIncRef ( imgI ) ; return fetchData ; } default : break ; } ctxI -> fetchPool . free ( fetchData ) ; return nullptr ; }
Create a new `BLRasterFetchData` from a `style`.
Create a new ` BLRasterFetchData ` from a ` style ` .
// TODO: Failed to invert the matrix? // Zero area means to cover the whole image.