GrBitmapTextGeoProc::GrBitmapTextGeoProc(const GrShaderCaps& caps,
                                         GrColor color,
                                         const sk_sp<GrTextureProxy>* proxies,
                                         int numActiveProxies,
                                         const GrSamplerState& params, GrMaskFormat format,
                                         const SkMatrix& localMatrix, bool usesW)
        : INHERITED(kGrBitmapTextGeoProc_ClassID)
        , fColor(color)
        , fLocalMatrix(localMatrix)
        , fUsesW(usesW)
        , fMaskFormat(format) {
    SkASSERT(numActiveProxies <= kMaxTextures);

    if (usesW) {
        fInPosition = {"inPosition", kFloat3_GrVertexAttribType, kFloat3_GrSLType};
    } else {
        fInPosition = {"inPosition", kFloat2_GrVertexAttribType, kFloat2_GrSLType};
    }

    fInTextureCoords = {"inTextureCoords", kUShort2_GrVertexAttribType,
                        caps.integerSupport() ? kUShort2_GrSLType : kFloat2_GrSLType };
    int cnt = 2;

    bool hasVertexColor = kA8_GrMaskFormat == fMaskFormat ||
                          kA565_GrMaskFormat == fMaskFormat;
    if (hasVertexColor) {
        fInColor = {"inColor", kUByte4_norm_GrVertexAttribType, kHalf4_GrSLType};
        ++cnt;
    }

    this->setVertexAttributeCnt(cnt);

    if (numActiveProxies) {
        fAtlasSize = proxies[0]->isize();
    }
    for (int i = 0; i < numActiveProxies; ++i) {
        SkASSERT(proxies[i]);
        SkASSERT(proxies[i]->isize() == fAtlasSize);
        fTextureSamplers[i].reset(proxies[i]->textureType(), proxies[i]->config(), params);
    }
    this->setTextureSamplerCnt(numActiveProxies);
}