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(); auto textureAtlas = batchNode->getTextureAtlas();
if (!textureAtlas->getTotalQuads()) if (!textureAtlas->getTotalQuads())
return; continue;
auto &batch = _batchCommands[i++]; auto &batch = _batchCommands[i++];
auto &&commands = batch.getCommandArray(); auto &&commands = batch.getCommandArray();

View File

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