SkPDFAlphaFunctionShader::SkPDFAlphaFunctionShader(SkPDFShader::State* state) : fState(state) { SkRect bbox; bbox.set(fState.get()->fBBox); fColorShader.reset( SkPDFShader::GetPDFShaderByState(state->CreateOpaqueState())); // Create resource dict with alpha graphics state as G0 and // pattern shader as P0, then write content stream. SkAutoTUnref<SkPDFGraphicState> alphaGs(CreateSMaskGraphicState()); fResourceDict.reset( get_gradient_resource_dict(fColorShader.get(), alphaGs.get())); SkAutoTUnref<SkStream> colorStream( create_pattern_fill_content(0, bbox)); setData(colorStream.get()); populate_tiling_pattern_dict(this, bbox, fResourceDict.get(), SkMatrix::I()); }
SkPDFAlphaFunctionShader* SkPDFAlphaFunctionShader::Create( SkPDFCanon* canon, SkScalar dpi, SkAutoTDelete<SkPDFShader::State>* autoState) { const SkPDFShader::State& state = **autoState; SkRect bbox; bbox.set(state.fBBox); SkAutoTDelete<SkPDFShader::State> opaqueState(state.CreateOpaqueState()); SkAutoTUnref<SkPDFObject> colorShader( get_pdf_shader_by_state(canon, dpi, &opaqueState)); if (!colorShader) { return NULL; } // Create resource dict with alpha graphics state as G0 and // pattern shader as P0, then write content stream. SkAutoTUnref<SkPDFObject> alphaGs( create_smask_graphic_state(canon, dpi, state)); SkPDFAlphaFunctionShader* alphaFunctionShader = SkNEW_ARGS(SkPDFAlphaFunctionShader, (autoState->detach())); SkAutoTUnref<SkPDFDict> resourceDict( get_gradient_resource_dict(colorShader.get(), alphaGs.get())); SkAutoTDelete<SkStream> colorStream( create_pattern_fill_content(0, bbox)); alphaFunctionShader->setData(colorStream.get()); populate_tiling_pattern_dict(alphaFunctionShader, bbox, resourceDict.get(), SkMatrix::I()); canon->addAlphaShader(alphaFunctionShader); return alphaFunctionShader; }