当前位置: 首页>>代码示例>>C++>>正文


C++ Patch::copy方法代码示例

本文整理汇总了C++中Patch::copy方法的典型用法代码示例。如果您正苦于以下问题:C++ Patch::copy方法的具体用法?C++ Patch::copy怎么用?C++ Patch::copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Patch的用法示例。


在下文中一共展示了Patch::copy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: get

Patch* PatchCache::get(const float bitmapWidth, const float bitmapHeight,
                       const float pixelWidth, const float pixelHeight,
                       const int32_t* xDivs, const int32_t* yDivs, const uint32_t* colors,
                       const uint32_t width, const uint32_t height, const int8_t numColors) {

    uint32_t quadCount = countQuad(xDivs, yDivs, width, height,
                                   bitmapWidth, bitmapHeight);

    int8_t transparentQuads = 0;
    uint32_t colorKey = 0;

    if (uint8_t(numColors) < sizeof(uint32_t) * 4) {
        for (int8_t i = 0; i < numColors; i++) {
            if (colors[i] == 0x0) {
                transparentQuads++;
                colorKey |= 0x1 << i;
            }
        }
    }

    // If the 9patch is made of only transparent quads
    if (transparentQuads == int8_t((width + 1) * (height + 1))) {
        return NULL;
    }

    const PatchDescription description(bitmapWidth, bitmapHeight,
                                       pixelWidth, pixelHeight, width, height, quadCount, transparentQuads, colorKey);

    ssize_t index = mCache.indexOfKey(description);
    Patch* mesh = NULL;
    if (index >= 0) {
        mesh = mCache.valueAt(index);
    }

    if (!mesh) {
        PATCH_LOGD("New patch mesh "
                   "xCount=%d yCount=%d, w=%.2f h=%.2f, bw=%.2f bh=%.2f",
                   width, height, pixelWidth, pixelHeight, bitmapWidth, bitmapHeight);

        mesh = new Patch(width, height, transparentQuads);
        mesh->updateColorKey(colorKey);
        mesh->copy(xDivs, yDivs);
        mesh->updateVertices(bitmapWidth, bitmapHeight, 0.0f, 0.0f, pixelWidth, pixelHeight);

        if (mCache.size() >= mMaxEntries) {
            delete mCache.valueAt(mCache.size() - 1);
            mCache.removeItemsAt(mCache.size() - 1, 1);
        }

        mCache.add(description, mesh);
    } else if (!mesh->matches(xDivs, yDivs, colorKey)) {
        PATCH_LOGD("Patch mesh does not match, refreshing vertices");
        PATCH_LOGD("Old patch mesh "
                   "xCount=%d yCount=%d, w=%.2f h=%.2f, bw=%.2f bh=%.2f",
                   width, height, pixelWidth, pixelHeight, bitmapWidth, bitmapHeight);
        mesh->updateVertices(bitmapWidth, bitmapHeight, 0.0f, 0.0f, pixelWidth, pixelHeight);
    }

    return mesh;
}
开发者ID:JokeLook,项目名称:framework,代码行数:60,代码来源:PatchCache.cpp


注:本文中的Patch::copy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。