예제 #1
0
파일: SkGr.cpp 프로젝트: picmonkey/skia
bool GrTextureUsageSupported(const GrCaps& caps, int width, int height, SkImageUsageType usage) {
    if (caps.npotTextureTileSupport()) {
        return true;
    }
    const bool is_pow2 = SkIsPow2(width) && SkIsPow2(height);
    return is_pow2 || kUntiled_SkImageUsageType == usage;
}
예제 #2
0
파일: SkGr.cpp 프로젝트: tiftof/skia
void GrMakeKeyFromImageID(GrUniqueKey* key, uint32_t imageID,
                          U16CPU width, U16CPU height, SkIPoint origin,
                          const GrCaps& caps, SkImageUsageType usage) {
    const Stretch::Type stretches[] = {
        Stretch::kNone_Type,        // kUntiled_SkImageUsageType
        Stretch::kNearest_Type,     // kTiled_Unfiltered_SkImageUsageType
        Stretch::kBilerp_Type,      // kTiled_Filtered_SkImageUsageType
    };

    const bool isPow2 = SkIsPow2(width) && SkIsPow2(height);
    const bool needToStretch = !isPow2 &&
                               usage != kUntiled_SkImageUsageType &&
                               !caps.npotTextureTileSupport();

    if (needToStretch) {
        GrUniqueKey tmpKey;
        make_unstretched_key(&tmpKey, imageID, width, height, origin);

        Stretch stretch;
        stretch.fType = stretches[usage];
        stretch.fWidth = SkNextPow2(width);
        stretch.fHeight = SkNextPow2(height);
        if (!make_stretched_key(tmpKey, stretch, key)) {
            goto UNSTRETCHED;
        }
    } else {
        UNSTRETCHED:
        make_unstretched_key(key, imageID, width, height, origin);
    }
}