本文整理汇总了C++中FrameEntry::data方法的典型用法代码示例。如果您正苦于以下问题:C++ FrameEntry::data方法的具体用法?C++ FrameEntry::data怎么用?C++ FrameEntry::data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FrameEntry
的用法示例。
在下文中一共展示了FrameEntry::data方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: data
void
FrameEntry::copy(const FrameEntry& other)
{
U8* dstPixels = data();
assert(dstPixels);
if (!dstPixels) {
return;
}
const U8* srcPixels = other.data();
assert(srcPixels);
if (!srcPixels) {
return;
}
const TextureRect& srcBounds = other.getKey().getTexRect();
const TextureRect& dstBounds = _key.getTexRect();
std::size_t srcRowSize = srcBounds.width();
unsigned int srcPixelSize = 4;
if ( (ImageBitDepthEnum)other.getKey().getBitDepth() == eImageBitDepthFloat ) {
srcPixelSize *= sizeof(float);
}
srcRowSize *= srcPixelSize;
std::size_t dstRowSize = srcBounds.width();
unsigned int dstPixelSize = 4;
if ( (ImageBitDepthEnum)_key.getBitDepth() == eImageBitDepthFloat ) {
dstPixelSize *= sizeof(float);
}
dstRowSize *= dstPixelSize;
// Fill with black and transparent because src might be smaller
bool filledZero = false;
if ( !srcBounds.contains(dstBounds) ) {
std::memset( dstPixels, 0, dstRowSize * dstBounds.height() );
filledZero = true;
}
if ( other.getKey().getBitDepth() != _key.getBitDepth() ) {
if (!filledZero) {
std::memset( dstPixels, 0, dstRowSize * dstBounds.height() );
}
return;
}
// Copy pixels over the intersection
RectI srcBoundsRect;
srcBoundsRect.x1 = srcBounds.x1;
srcBoundsRect.x2 = srcBounds.x2;
srcBoundsRect.y1 = srcBounds.y1;
srcBoundsRect.y2 = srcBounds.y2;
RectI roi;
if ( !dstBounds.intersect(srcBoundsRect, &roi) ) {
return;
}
dstPixels += (roi.y1 - dstBounds.y1) * dstRowSize + (roi.x1 - dstBounds.x1) * dstPixelSize;
srcPixels += (roi.y1 - srcBounds.y1) * srcRowSize + (roi.x1 - srcBounds.x1) * srcPixelSize;
std::size_t roiRowSize = dstPixelSize * roi.width();
//Align dstPixel to srcPixels point
for (int y = roi.y1; y < roi.y2; ++y,
srcPixels += srcRowSize,
dstPixels += dstRowSize) {
std::memcpy(dstPixels, srcPixels, roiRowSize);
}
} // FrameEntry::copy