From a6e4b31b0d9f2b080278587469fa84461046202b Mon Sep 17 00:00:00 2001 From: Haneol Park Date: Tue, 25 Nov 2014 20:42:03 +0900 Subject: [PATCH] Additional unnecessary set dirty of ui widgets --- cocos/ui/UIButton.cpp | 10 +++++++--- cocos/ui/UICheckBox.cpp | 10 +++++----- cocos/ui/UILoadingBar.cpp | 10 +++++++++- cocos/ui/UITextAtlas.cpp | 4 ++++ cocos/ui/UITextBMFont.cpp | 4 ++++ 5 files changed, 29 insertions(+), 9 deletions(-) diff --git a/cocos/ui/UIButton.cpp b/cocos/ui/UIButton.cpp index 81e637522e..1d4a45fafb 100644 --- a/cocos/ui/UIButton.cpp +++ b/cocos/ui/UIButton.cpp @@ -216,7 +216,7 @@ void Button::loadTextures(const std::string& normal, void Button::loadTextureNormal(const std::string& normal,TextureResType texType) { - if (normal.empty()) + if (normal.empty() || (_normalFileName == normal && _normalTexType == texType)) { return; } @@ -256,7 +256,7 @@ void Button::loadTextureNormal(const std::string& normal,TextureResType texType) void Button::loadTexturePressed(const std::string& selected,TextureResType texType) { - if (selected.empty()) + if (selected.empty() || (_clickedFileName == selected && _pressedTexType == texType)) { return; } @@ -285,7 +285,7 @@ void Button::loadTexturePressed(const std::string& selected,TextureResType texTy void Button::loadTextureDisabled(const std::string& disabled,TextureResType texType) { - if (disabled.empty()) + if (disabled.empty() || (_disabledFileName == disabled && _disabledTexType == texType)) { return; } @@ -741,6 +741,10 @@ void Button::setPressedActionEnabled(bool enabled) void Button::setTitleText(const std::string& text) { + if (text == getTitleText()) + { + return; + } _titleRenderer->setString(text); updateContentSize(); } diff --git a/cocos/ui/UICheckBox.cpp b/cocos/ui/UICheckBox.cpp index bc9431057b..7ab5206851 100644 --- a/cocos/ui/UICheckBox.cpp +++ b/cocos/ui/UICheckBox.cpp @@ -165,7 +165,7 @@ void CheckBox::loadTextures(const std::string& backGround, void CheckBox::loadTextureBackGround(const std::string& backGround,TextureResType texType) { - if (backGround.empty()) + if (backGround.empty() || (_backGroundFileName == backGround && _backGroundTexType == texType)) { return; } @@ -191,7 +191,7 @@ void CheckBox::loadTextureBackGround(const std::string& backGround,TextureResTyp void CheckBox::loadTextureBackGroundSelected(const std::string& backGroundSelected,TextureResType texType) { - if (backGroundSelected.empty()) + if (backGroundSelected.empty() || (_backGroundSelectedFileName == backGroundSelected && _backGroundSelectedTexType == texType)) { return; } @@ -216,7 +216,7 @@ void CheckBox::loadTextureBackGroundSelected(const std::string& backGroundSelect void CheckBox::loadTextureFrontCross(const std::string& cross,TextureResType texType) { - if (cross.empty()) + if (cross.empty() || (_frontCrossFileName == cross && _frontCrossTexType == texType)) { return; } @@ -241,7 +241,7 @@ void CheckBox::loadTextureFrontCross(const std::string& cross,TextureResType tex void CheckBox::loadTextureBackGroundDisabled(const std::string& backGroundDisabled,TextureResType texType) { - if (backGroundDisabled.empty()) + if (backGroundDisabled.empty() || (_backGroundDisabledFileName == backGroundDisabled && _backGroundDisabledTexType == texType)) { return; } @@ -266,7 +266,7 @@ void CheckBox::loadTextureBackGroundDisabled(const std::string& backGroundDisabl void CheckBox::loadTextureFrontCrossDisabled(const std::string& frontCrossDisabled,TextureResType texType) { - if (frontCrossDisabled.empty()) + if (frontCrossDisabled.empty() || (_frontCrossDisabledFileName == frontCrossDisabled && _frontCrossDisabledTexType == texType)) { return; } diff --git a/cocos/ui/UILoadingBar.cpp b/cocos/ui/UILoadingBar.cpp index 972e5fd0ed..8d6197e5e4 100644 --- a/cocos/ui/UILoadingBar.cpp +++ b/cocos/ui/UILoadingBar.cpp @@ -212,7 +212,15 @@ const Rect& LoadingBar::getCapInsets()const void LoadingBar::setPercent(float percent) { - if ( percent < 0 || percent > 100 || _percent == percent) + if (percent > 100) + { + percent = 100; + } + if (percent < 0) + { + percent = 0; + } + if (_percent == percent) { return; } diff --git a/cocos/ui/UITextAtlas.cpp b/cocos/ui/UITextAtlas.cpp index a1ef656a99..64f06f4636 100644 --- a/cocos/ui/UITextAtlas.cpp +++ b/cocos/ui/UITextAtlas.cpp @@ -103,6 +103,10 @@ void TextAtlas::setProperty(const std::string& stringValue, const std::string& c void TextAtlas::setString(const std::string& value) { + if (value == _labelAtlasRenderer->getString()) + { + return; + } _stringValue = value; _labelAtlasRenderer->setString(value); updateContentSizeWithTextureSize(_labelAtlasRenderer->getContentSize()); diff --git a/cocos/ui/UITextBMFont.cpp b/cocos/ui/UITextBMFont.cpp index 7ee5babd20..d3fbb0cc57 100644 --- a/cocos/ui/UITextBMFont.cpp +++ b/cocos/ui/UITextBMFont.cpp @@ -94,6 +94,10 @@ void TextBMFont::setFntFile(const std::string& fileName) void TextBMFont::setString(const std::string& value) { + if (value == _labelBMFontRenderer->getString()) + { + return; + } _stringValue = value; if (!_fntFileHasInit) {