| 486 | } |
| 487 | |
| 488 | void RenderTexture::onSaveToFile(std::string filename, bool isRGBA, bool forceNonPMA) |
| 489 | { |
| 490 | auto callbackFunc = [this, _filename = std::move(filename), isRGBA, forceNonPMA](RefPtr<Image> image) { |
| 491 | if (image) |
| 492 | { |
| 493 | if (forceNonPMA && image->hasPremultipliedAlpha()) |
| 494 | { |
| 495 | _director->getJobSystem()->enqueue([self = RefPtr(this), image, _filename, isRGBA, forceNonPMA]() { |
| 496 | image->reversePremultipliedAlpha(); |
| 497 | |
| 498 | Director::getInstance()->getScheduler()->runOnAxmolThread([self, image, _filename, isRGBA] { |
| 499 | image->saveToFile(_filename, !isRGBA); |
| 500 | if (self->_saveFileCallback) |
| 501 | { |
| 502 | self->_saveFileCallback(self, _filename); |
| 503 | } |
| 504 | }); |
| 505 | }); |
| 506 | } |
| 507 | else |
| 508 | { |
| 509 | image->saveToFile(_filename, !isRGBA); |
| 510 | if (_saveFileCallback) |
| 511 | { |
| 512 | _saveFileCallback(this, _filename); |
| 513 | } |
| 514 | } |
| 515 | } |
| 516 | else |
| 517 | { |
| 518 | if (_saveFileCallback) |
| 519 | { |
| 520 | _saveFileCallback(this, _filename); |
| 521 | } |
| 522 | } |
| 523 | }; |
| 524 | newImage(callbackFunc); |
| 525 | } |
| 526 | |
| 527 | /* get buffer as Image */ |
| 528 | void RenderTexture::newImage(std::function<void(RefPtr<Image>)> imageCallback, bool eglCacheHint) |
nothing calls this directly
no test coverage detected