示例#1
0
float* ofxObject::updateMatrix(float *iParentMatrix)
{
	// if the object has multiple parents, the hierarchy tree matrix needs to be set to dirty, using mMatrixDirty.
	if (parents.size() > 1) matrixDirty = true;
  
	if (matrixDirty  ||  localMatrixDirty  || alwaysMatrixDirty) {
		if (localMatrixDirty) {
			updateLocalMatrix();
		}
    
		//matrix multiplication
		Mul(localMatrix, iParentMatrix, matrix);
    
		/*
     if(id==1)
     printf("matrix:\n%f\t%f\t%f\t%f\n%f\t%f\t%f\t%f\n%f\t%f\t%f\t%f\n%f\t%f\t%f\t%f\n",
     matrix[0], matrix[1], matrix[2], matrix[3],
     matrix[4], matrix[5], matrix[6], matrix[7],
     matrix[8], matrix[9], matrix[10], matrix[11],
     matrix[12], matrix[13], matrix[14], matrix[15]);
     */
    
		// set matrix dirty flags of all children
		for (unsigned int i = 0; i < children.size(); i++)
			children[i]->matrixDirty = true;
    
		//if(id == 1) printf("updateMatrix() %f\n", ofGetElapsedTimef());
    
		//reset matrix dirty flag
		matrixDirty = false;
	}
  
	return matrix;
}
SkiaCircularGradientShader::SkiaCircularGradientShader(float x, float y, float radius,
        uint32_t* colors, float* positions, int count, SkShader* key, SkShader::TileMode tileMode,
        SkMatrix* matrix, bool blend):
    SkiaSweepGradientShader(kCircularGradient, x, y, colors, positions, count, key,
                            tileMode, matrix, blend) {
    SkMatrix unitMatrix;
    toCircularUnitMatrix(x, y, radius, &unitMatrix);
    mUnitMatrix.load(unitMatrix);

    updateLocalMatrix(matrix);
}
SkiaSweepGradientShader::SkiaSweepGradientShader(float x, float y, uint32_t* colors,
        float* positions, int count, SkShader* key, SkMatrix* matrix, bool blend):
    SkiaShader(kSweepGradient, key, SkShader::kClamp_TileMode,
               SkShader::kClamp_TileMode, matrix, blend),
    mColors(colors), mPositions(positions), mCount(count) {
    SkMatrix unitMatrix;
    toSweepUnitMatrix(x, y, &unitMatrix);
    mUnitMatrix.load(unitMatrix);

    updateLocalMatrix(matrix);

    mIsSimple = count == 2;
}
SkiaLinearGradientShader::SkiaLinearGradientShader(float* bounds, uint32_t* colors,
        float* positions, int count, SkShader* key, SkShader::TileMode tileMode,
        SkMatrix* matrix, bool blend):
    SkiaShader(kLinearGradient, key, tileMode, tileMode, matrix, blend),
    mBounds(bounds), mColors(colors), mPositions(positions), mCount(count) {
    SkPoint points[2];
    points[0].set(bounds[0], bounds[1]);
    points[1].set(bounds[2], bounds[3]);

    SkMatrix unitMatrix;
    toUnitMatrix(points, &unitMatrix);
    mUnitMatrix.load(unitMatrix);

    updateLocalMatrix(matrix);

    mIsSimple = count == 2 && tileMode == SkShader::kClamp_TileMode;
}
SkiaBitmapShader::SkiaBitmapShader(SkBitmap* bitmap, SkShader* key, SkShader::TileMode tileX,
                                   SkShader::TileMode tileY, SkMatrix* matrix, bool blend):
    SkiaShader(kBitmap, key, tileX, tileY, matrix, blend), mBitmap(bitmap), mTexture(NULL) {
    updateLocalMatrix(matrix);
}