ECode CSweepGradient::Copy( /* [out] */ IShader** shader) { VALIDATE_NOT_NULL(shader); AutoPtr<IShader> copy; switch (mType) { case TYPE_COLORS_AND_POSITIONS: { AutoPtr< ArrayOf<Int32> > colors = mColors->Clone(); AutoPtr<ArrayOf<Float> > positions; if (mPositions) { positions = mPositions->Clone(); } CSweepGradient::New(mCx, mCy, colors, positions, (IShader**)©); break; } case TYPE_COLOR_START_AND_COLOR_END: CSweepGradient::New(mCx, mCy, mColor0, mColor1, (IShader**)©); break; default: *shader = NULL; // throw new IllegalArgumentException("SweepGradient should be created with either " + // "colors and positions or start color and end color"); return E_ILLEGAL_ARGUMENT_EXCEPTION; } CopyLocalMatrix(copy); *shader = copy; REFCOUNT_ADD(*shader); return NOERROR; }
ECode CComposeShader::Copy( /* [out] */ IShader** shader) { VALIDATE_NOT_NULL(shader); AutoPtr<IShader> copy; switch (mType) { case TYPE_XFERMODE: { AutoPtr<IShader> c1; AutoPtr<IShader> c2; ((Shader*)mShaderA.Get())->Copy((IShader**)&c1); ((Shader*)mShaderB.Get())->Copy((IShader**)&c2); CComposeShader::New(c1, c2, mXferMode, (IShader**)©); } break; case TYPE_PORTERDUFFMODE: { AutoPtr<IShader> c1; AutoPtr<IShader> c2; ((Shader*)mShaderA.Get())->Copy((IShader**)&c1); ((Shader*)mShaderB.Get())->Copy((IShader**)&c2); CComposeShader::New(c1, c2, mPorterDuffMode, (IShader**)©); } break; default: // throw new IllegalArgumentException( // "ComposeShader should be created with either Xfermode or PorterDuffMode"); return E_ILLEGAL_ARGUMENT_EXCEPTION; } CopyLocalMatrix(copy); *shader = copy; REFCOUNT_ADD(*shader); return NOERROR; }
ECode CRadialGradient::Copy( /* [out] */ IShader** shader) { VALIDATE_NOT_NULL(shader); AutoPtr<IShader> copy; switch (mType) { case TYPE_COLORS_AND_POSITIONS: { AutoPtr<ArrayOf<Int32> > colors = mColors->Clone(); AutoPtr<ArrayOf<Float> > positions; if (mPositions) { positions = mPositions->Clone(); } CRadialGradient::New(mX, mY, mRadius, colors, positions, mTileMode, (IShader**)©); break; } case TYPE_COLOR_CENTER_AND_COLOR_EDGE: CRadialGradient::New(mX, mY, mRadius, mCenterColor, mEdgeColor, mTileMode, (IShader**)©); break; default: *shader = NULL; // throw new IllegalArgumentException("RadialGradient should be created with either " + // "colors and positions or center color and edge color"); return E_ILLEGAL_ARGUMENT_EXCEPTION; } CopyLocalMatrix(copy); *shader = copy; REFCOUNT_ADD(*shader); return NOERROR; }