From 7b0cf3c8602fe3ea49708a33cc2853314ed51717 Mon Sep 17 00:00:00 2001 From: vision Date: Wed, 14 May 2014 11:21:46 +0800 Subject: [PATCH] replace std::function with const std::function& --- cocos/renderer/CCRenderer.cpp | 28 ++++++++++++++-------------- cocos/renderer/CCRenderer.h | 4 ++-- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/cocos/renderer/CCRenderer.cpp b/cocos/renderer/CCRenderer.cpp index 6f4dc3301e..42753bea86 100644 --- a/cocos/renderer/CCRenderer.cpp +++ b/cocos/renderer/CCRenderer.cpp @@ -538,14 +538,14 @@ bool Renderer::checkVisibility(const Matrix &transform, const Size &size) return ret; } -void Renderer::captureScreen(std::function afterCaptured, const std::string& filename, const Rect& rect) +void Renderer::captureScreen(const std::function& afterCaptured, const std::string& filename, const Rect& rect) { _captureScreen.init(std::numeric_limits::max()); _captureScreen.func = CC_CALLBACK_0(Renderer::onCaptureScreen, this, afterCaptured, filename, true, rect); addCommand(&_captureScreen); } -void Renderer::onCaptureScreen(std::function afterCaptured, const std::string& filename, bool flipped, const Rect& rect) +void Renderer::onCaptureScreen(const std::function& 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 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) diff --git a/cocos/renderer/CCRenderer.h b/cocos/renderer/CCRenderer.h index 8d1092bd4c..2157d84b6d 100644 --- a/cocos/renderer/CCRenderer.h +++ b/cocos/renderer/CCRenderer.h @@ -119,7 +119,7 @@ public: bool checkVisibility(const Matrix& transform, const Size& size); /** capture screen */ - void captureScreen(std::function afterCaptued, const std::string& filename, const Rect& rect = Rect::ZERO); + void captureScreen(const std::function& 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 afterCaptued, const std::string& fileanme, bool flipped, const Rect& rect); + void onCaptureScreen(const std::function& afterCaptued, const std::string& fileanme, bool flipped, const Rect& rect); std::stack _commandGroupStack;