Beispiel #1
0
static void make_image_keys(uint32_t imageID, const SkIRect& subset, const SkGrStretch& stretch,
                            GrUniqueKey* key, GrUniqueKey* stretchedKey) {
    make_unstretched_key(key, imageID, subset);
    if (SkGrStretch::kNone_Type != stretch.fType) {
        GrMakeStretchedKey(*key, stretch, stretchedKey);
    }
}
Beispiel #2
0
    bool onMakeStretchedKey(const SkGrStretch& stretch, GrUniqueKey* stretchedKey) override {
        if (fBitmap.isVolatile()) {
            return false;
        }

        GrUniqueKey unstretchedKey;
        make_unstretched_key(&unstretchedKey, fBitmap.getGenerationID(), fBitmap.getSubset());
        return GrMakeStretchedKey(unstretchedKey, stretch, stretchedKey);
    }
Beispiel #3
0
bool GrIsImageInCache(const GrContext* ctx, uint32_t imageID, const SkIRect& subset,
                      GrTexture* nativeTexture, const GrTextureParams* params) {
    SkGrStretch stretch;
    get_stretch(ctx, subset.width(), subset.height(), params, &stretch);

    // Handle the case where the bitmap/image is explicitly texture backed.
    if (nativeTexture) {
        if (SkGrStretch::kNone_Type == stretch.fType) {
            return true;
        }
        const GrUniqueKey& key = nativeTexture->getUniqueKey();
        if (!key.isValid()) {
            return false;
        }
        GrUniqueKey stretchedKey;
        GrMakeStretchedKey(key, stretch, &stretchedKey);
        return ctx->textureProvider()->existsTextureWithUniqueKey(stretchedKey);
    }

    GrUniqueKey key, stretchedKey;
    make_image_keys(imageID, subset, stretch, &key, &stretchedKey);
    return ctx->textureProvider()->existsTextureWithUniqueKey(
        (SkGrStretch::kNone_Type == stretch.fType) ? key : stretchedKey);
}
Beispiel #4
0
void GrMakeKeyFromImageID(GrUniqueKey* key, uint32_t imageID, const SkIRect& subset,
                          const GrCaps& caps, SkImageUsageType usage) {
    const SkGrStretch::Type stretches[] = {
        SkGrStretch::kNone_Type,        // kUntiled_SkImageUsageType
        SkGrStretch::kNearest_Type,     // kTiled_Unfiltered_SkImageUsageType
        SkGrStretch::kBilerp_Type,      // kTiled_Filtered_SkImageUsageType
    };

    if (!GrTextureUsageSupported(caps, subset.width(), subset.height(), usage)) {
        GrUniqueKey tmpKey;
        make_unstretched_key(&tmpKey, imageID, subset);

        SkGrStretch stretch;
        stretch.fType = stretches[usage];
        stretch.fWidth = SkNextPow2(subset.width());
        stretch.fHeight = SkNextPow2(subset.height());
        if (!GrMakeStretchedKey(tmpKey, stretch, key)) {
            goto UNSTRETCHED;
        }
    } else {
        UNSTRETCHED:
        make_unstretched_key(key, imageID, subset);
    }
}
Beispiel #5
0
 bool onMakeStretchedKey(const SkGrStretch& stretch, GrUniqueKey* stretchedKey) override {
     return GrMakeStretchedKey(fUnstretchedKey, stretch, stretchedKey);
 }