Ejemplo n.º 1
0
GrResourceKey GrTexture::ComputeKey(const GrGpu* gpu,
                                    const GrTextureParams* params,
                                    const GrTextureDesc& desc,
                                    const GrCacheID& cacheID) {
    GrResourceKey::ResourceFlags flags = get_texture_flags(gpu, params, desc);
    return GrResourceKey(cacheID, texture_resource_type(), flags);
}
Ejemplo n.º 2
0
GrResourceKey GrStencilBuffer::ComputeKey(int width,
                                          int height,
                                          int sampleCnt) {
    GrCacheID id(GrStencilBuffer::GetResourceType());
    gen_stencil_key_values(width, height, sampleCnt, &id);

    uint32_t v[4];
    id.toRaw(v);
    return GrResourceKey(v);
}
Ejemplo n.º 3
0
GrResourceKey GrTexture::ComputeKey(const GrGpu* gpu,
                                    const GrTextureParams* params,
                                    const GrTextureDesc& desc,
                                    const GrCacheData& cacheData,
                                    bool scratch) {
    GrCacheID id(GrTexture::GetResourceType());
    gen_texture_key_values(gpu, params, desc, cacheData, scratch, &id);

    uint32_t v[4];
    id.toRaw(v);
    return GrResourceKey(v);
}
Ejemplo n.º 4
0
GrResourceKey GrStencilBuffer::ComputeKey(int width,
                                          int height,
                                          int sampleCnt) {
    // All SBs are created internally to attach to RTs so they all use the same domain.
    static const GrResourceKey::ResourceType gStencilBufferResourceType =
        GrResourceKey::GenerateResourceType();
    GrCacheID id;
    gen_cache_id(width, height, sampleCnt, &id);

    // we don't use any flags for SBs currently.
    return GrResourceKey(id, gStencilBufferResourceType, 0);
}
Ejemplo n.º 5
0
GrResourceKey GrTexture::ComputeScratchKey(const GrTextureDesc& desc) {
    GrCacheID::Key idKey;
    // Instead of a client-provided key of the texture contents we create a key from the
    // descriptor.
    GR_STATIC_ASSERT(sizeof(idKey) >= 16);
    GrAssert(desc.fHeight < (1 << 16));
    GrAssert(desc.fWidth < (1 << 16));
    idKey.fData32[0] = (desc.fWidth) | (desc.fHeight << 16);
    idKey.fData32[1] = desc.fConfig | desc.fSampleCnt << 16;
    idKey.fData32[2] = desc.fFlags;
    idKey.fData32[3] = resolve_origin(desc);    // Only needs 2 bits actually
    static const int kPadSize = sizeof(idKey) - 16;
    GR_STATIC_ASSERT(kPadSize >= 0);
    memset(idKey.fData8 + 16, 0, kPadSize);

    GrCacheID cacheID(GrResourceKey::ScratchDomain(), idKey);
    return GrResourceKey(cacheID, texture_resource_type(), 0);
}
static GrPathRange* get_gr_glyphs(GrContext* ctx,
                                  const SkTypeface* typeface,
                                  const SkDescriptor* desc,
                                  const SkStrokeRec& stroke) {
    static const GrCacheID::Domain gGlyphsDomain = GrCacheID::GenerateDomain();

    GrCacheID::Key key;
    uint64_t* keyData = key.fData64;
    keyData[0] = desc ? desc->getChecksum() : 0;
    keyData[0] = (keyData[0] << 32) | (typeface ? typeface->uniqueID() : 0);
    keyData[1] = GrPath::ComputeStrokeKey(stroke);
    GrResourceKey resourceKey = GrResourceKey(GrCacheID(gGlyphsDomain, key),
                                              GrPathRange::resourceType(), 0);

    SkAutoTUnref<GrPathRange> glyphs(
        static_cast<GrPathRange*>(ctx->findAndRefCachedResource(resourceKey)));
    if (NULL == glyphs || (NULL != desc && !glyphs->isEqualTo(*desc))) {
        glyphs.reset(ctx->getGpu()->pathRendering()->createGlyphs(typeface, desc, stroke));
        ctx->addResourceToCache(resourceKey, glyphs);
    }

    return glyphs.detach();
}