本文整理汇总了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;
}