mirror of https://github.com/axmolengine/axmol.git
replace std::function with const std::function&
This commit is contained in:
parent
e7df247d65
commit
7b0cf3c860
|
@ -538,14 +538,14 @@ bool Renderer::checkVisibility(const Matrix &transform, const Size &size)
|
|||
return ret;
|
||||
}
|
||||
|
||||
void Renderer::captureScreen(std::function<void(bool, const std::string&)> afterCaptured, const std::string& filename, const Rect& rect)
|
||||
void Renderer::captureScreen(const std::function<void(bool, const std::string&)>& afterCaptured, const std::string& filename, const Rect& rect)
|
||||
{
|
||||
_captureScreen.init(std::numeric_limits<float>::max());
|
||||
_captureScreen.func = CC_CALLBACK_0(Renderer::onCaptureScreen, this, afterCaptured, filename, true, rect);
|
||||
addCommand(&_captureScreen);
|
||||
}
|
||||
|
||||
void Renderer::onCaptureScreen(std::function<void(bool, const std::string&)> afterCaptured, const std::string& filename, bool flipped, const Rect& rect)
|
||||
void Renderer::onCaptureScreen(const std::function<void(bool, const std::string&)>& afterCaptured, const std::string& filename, bool flipped, const Rect& rect)
|
||||
{
|
||||
// Generally the user specifiy the rect with design resolution, thus we have to convert it
|
||||
// into a significant value which is metered by pixel.
|
||||
|
@ -573,23 +573,23 @@ void Renderer::onCaptureScreen(std::function<void(bool, const std::string&)> aft
|
|||
|
||||
do
|
||||
{
|
||||
GLubyte* buffer = new GLubyte[width * height * 4];
|
||||
if (!buffer)
|
||||
{
|
||||
CC_SAFE_DELETE_ARRAY(buffer);
|
||||
break;
|
||||
}
|
||||
GLubyte* buffer = new GLubyte[width * height * 4];
|
||||
if (!buffer)
|
||||
{
|
||||
CC_SAFE_DELETE_ARRAY(buffer);
|
||||
break;
|
||||
}
|
||||
|
||||
glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
||||
glReadPixels(originx, originy, width, height, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
|
||||
glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
||||
glReadPixels(originx, originy, width, height, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
|
||||
|
||||
if (flipped)
|
||||
{
|
||||
if (flipped)
|
||||
{
|
||||
GLubyte* flippedBuffer = new GLubyte[width * height * 4];
|
||||
if (!flippedBuffer)
|
||||
{
|
||||
CC_SAFE_DELETE(flippedBuffer);
|
||||
break;
|
||||
CC_SAFE_DELETE(flippedBuffer);
|
||||
break;
|
||||
}
|
||||
|
||||
for (int row = 0; row < height; ++row)
|
||||
|
|
|
@ -119,7 +119,7 @@ public:
|
|||
bool checkVisibility(const Matrix& transform, const Size& size);
|
||||
|
||||
/** capture screen */
|
||||
void captureScreen(std::function<void(bool, const std::string&)> afterCaptued, const std::string& filename, const Rect& rect = Rect::ZERO);
|
||||
void captureScreen(const std::function<void(bool, const std::string&)>& afterCaptued, const std::string& filename, const Rect& rect = Rect::ZERO);
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -139,7 +139,7 @@ protected:
|
|||
|
||||
void convertToWorldCoordinates(V3F_C4B_T2F_Quad* quads, ssize_t quantity, const Matrix& modelView);
|
||||
|
||||
void onCaptureScreen(std::function<void(bool, const std::string&)> afterCaptued, const std::string& fileanme, bool flipped, const Rect& rect);
|
||||
void onCaptureScreen(const std::function<void(bool, const std::string&)>& afterCaptued, const std::string& fileanme, bool flipped, const Rect& rect);
|
||||
|
||||
std::stack<int> _commandGroupStack;
|
||||
|
||||
|
|
Loading…
Reference in New Issue