示例#1
0
bool SkColorShader::ColorShaderContext::onChooseBlitProcs(const SkImageInfo& info,
                                                          BlitState* state) {
    uint32_t flags = SkXfermode::kSrcIsSingle_D32Flag;
    if (fPM4f.a() == 1) {
        flags |= SkXfermode::kSrcIsOpaque_D32Flag;
    }
    switch (info.colorType()) {
        case kN32_SkColorType:
            if (info.isSRGB()) {
                flags |= SkXfermode::kDstIsSRGB_D32Flag;
            }
            state->fStorage[0] = (void*)SkXfermode::GetD32Proc(state->fXfer, flags);
            state->fStorage[1] = &fPM4f;
            state->fBlitBW = D32_BlitBW;
            state->fBlitAA = D32_BlitAA;
            return true;
        case kRGBA_F16_SkColorType:
            flags |= SkXfermode::kDstIsFloat16_D64Flag;
            state->fStorage[0] = (void*)SkXfermode::GetD64Proc(state->fXfer, flags);
            state->fStorage[1] = &fPM4f;
            state->fBlitBW = D64_BlitBW;
            state->fBlitAA = D64_BlitAA;
            return true;
        default:
            return false;
    }
}
示例#2
0
 State32(const SkImageInfo& info, const SkPaint& paint, const SkShader::Context* shaderContext)
     : State4f(info, paint, shaderContext)
 {
     if (is_opaque(paint, shaderContext)) {
         fFlags |= SkXfermode::kSrcIsOpaque_D32Flag;
     }
     if (info.isSRGB()) {
         fFlags |= SkXfermode::kDstIsSRGB_D32Flag;
     }
     fProc1 = SkXfermode::GetD32Proc(fXfer, fFlags | SkXfermode::kSrcIsSingle_D32Flag);
     fProcN = SkXfermode::GetD32Proc(fXfer, fFlags);
 }
static bool choose_linear_pipeline(const SkShader::ContextRec& rec, const SkImageInfo& srcInfo) {
    // These src attributes are not supported in the new 4f context (yet)
    //
    if (srcInfo.colorType() != kRGBA_8888_SkColorType
        && srcInfo.colorType() != kBGRA_8888_SkColorType
        && srcInfo.colorType() != kIndex_8_SkColorType) {
        return false;
    }

#if 0   // later we may opt-in to the new code even if the client hasn't requested it...
    // These src attributes are only supported in the new 4f context
    //
    if (srcInfo.isSRGB() ||
        kUnpremul_SkAlphaType == srcInfo.alphaType() ||
        (4 == srcInfo.bytesPerPixel() && kN32_SkColorType != srcInfo.colorType()))
    {
        return true;
    }
#endif

    // If we get here, we can reasonably use either context, respect the caller's preference
    //
    return SkShader::ContextRec::kPM4f_DstType == rec.fPreferredDstType;
}