Merge pull request #104 from halx99/master

Sync some good PRs from official
This commit is contained in:
HALX99 2020-06-12 12:32:46 +08:00 committed by GitHub
commit 9c94103e53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 11 deletions

View File

@ -1902,7 +1902,7 @@ void Label::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
auto textureAtlas = batchNode->getTextureAtlas();
if (!textureAtlas->getTotalQuads())
return;
continue;
auto &batch = _batchCommands[i++];
auto &&commands = batch.getCommandArray();

View File

@ -200,8 +200,10 @@ bool RenderTexture::initWithWidthAndHeight(int w, int h, backend::PixelFormat fo
_texture2D->setRenderTarget(true);
texture->release();
}
else
else {
texture->release();
break;
}
_renderTargetFlags = RenderTargetFlag::COLOR;
@ -474,16 +476,15 @@ void RenderTexture::newImage(std::function<void(Image*)> imageCallback, bool fli
// it should be cut
int savedBufferWidth = (int)s.width;
int savedBufferHeight = (int)s.height;
bool hasPremultipliedAlpha = _texture2D->hasPremultipliedAlpha();
Image *image = new (std::nothrow) Image();
auto initCallback = [&, savedBufferWidth, savedBufferHeight, imageCallback](Image* image, const unsigned char* tempData){
image->initWithRawData(tempData, savedBufferWidth * savedBufferHeight * 4, savedBufferWidth, savedBufferHeight, 8, _texture2D->hasPremultipliedAlpha());
if (image) {
_texture2D->getBackendTexture()->getBytes(0, 0, savedBufferWidth, savedBufferHeight, flipImage, [=](const unsigned char* tempData, size_t, size_t) {
image->initWithRawData(tempData, savedBufferWidth * savedBufferHeight * 4, savedBufferWidth, savedBufferHeight, 8, hasPremultipliedAlpha);
imageCallback(image);
};
auto callback = std::bind(initCallback, image, std::placeholders::_1);
_texture2D->getBackendTexture()->getBytes(0, 0, savedBufferWidth, savedBufferHeight, flipImage, callback);
});
}
// do
// {