Commit Graph

53 Commits

Author SHA1 Message Date
xiaoyur347 617009f1cf fix CCTextureCache addImageAsync race condition (#18366) 2017-10-16 00:58:29 -05:00
CocosRobot d07794052f Update license to 2017 (#17362)
* Typo: CopyRight -> Copyright

* Copyright update: chukong-inc.com -> Chukong Technologies Inc.

* [js files] Copyright update: 2014 -> 2014-2017

* [cpp files] Copyright update: 2014 -> 2014-2017

* Copyright update: 2015 -> 2015-2017

* [js files] Copyright update: 2014 -> 2014-2017

* Copyright update: 2016 -> 2016-2017

* Copyright update: 2013 -> 2013-2017

* Copyright update: 201?-201? -> 201?-2017

* License year fixes.

* Liscene year fix in CCRay.cpp

* Updates license years in CCGLProgramState.h & CCGLProgramStateCache.h
2017-02-14 14:36:57 +08:00
minggo c4712936f3 fix the bug that ect1 texture lost on android (#17278)
the commit do the following things:
- reload ect1 related shaders when comes from background
- reload alpha texture when comes from background
2017-02-04 18:00:21 +08:00
j-jorge c616d6d9ff Compilation fix (#17209)
* Fix various compilation issues.

Mostly errors on field initialization order but also missing files
in CMakeLists and missing include directives.

* Fix compilations issues with GCC 6.2

* Fix gitignore libs/ entry to not ignore the Android external libraries.
2017-02-04 09:46:32 +08:00
j-jorge 6bbf01537d Allow to unbind asynchronous texture loading callback with a custom key. (#17206)
* Allow to unbind asynchronous texture loading callback with a custom key.

In order to unbind the callback passed to
`cocos2d::TextureCache::addImageAsync(path, callback)`, one has to
call `cocos2d::TextureCache::unbindImageAsync(path)`. In the cases
where the loading of the same texture is requested from several sources
simultaneously, then none of the source can unbind its own callback
unambiguously.

This commit adds an overload of the `addImageAsync` function taking an extra
argument identifying the callback, thus allowing to unbind it unambiguously
in cases where the loading of path is requested by several sources
simultaneously.

* Add a test case for TextureCache::addImageAsync with a custom key.
2017-02-04 09:38:54 +08:00
Wilson E. Alvarez 3056269531 Various small performance tweaks (#16881)
* These variables can be accessed by reference

* Assign values in initialization list

* _range can also be in initialization list

* Prefixed ++ and added 'auto' to loops

Also removed extra whitespace

* Prefixed ++/--, and changed for-loop implementation to use 'auto' on some loops
2016-11-22 09:54:04 +08:00
pyrosphere 663bb4d7ed No CC_UNUSED_PARAM (#16812)
* Added -Wno-unused-parameter and removed all uses of the CC_UNUSED_PARAM macro

* Commented unused parameter names in .cpp files which previously used CC_UNUSED_PARAM

* Reverted -Wno-unused-param flag.
Moved deprecated touch methods definitions to .cpp file.
Commented more unused parameter names.

* Fixed some errors and warnings caused by the previous commit.

* Commented remaining unused parameter names in .cpp files.

* Fixed unused parameter warnings in headers.

* Fixed some more unused parameter warnings.

* Fixed some more unused parameters warnings.

* Fixed mistake in previous commit, missing ComAudioReader:: in method. Other warnings.

* Fixed build errors.

* Added missing file to CMakeLists
2016-11-16 09:48:37 +08:00
Ce Zheng 4b3525f7a8 use STL emplace when possible (#16815)
* replaced some unordered_map::insert(std::make_pair(foo, bar)) with unordered_map::emplace(foo, bar)
* replaced some vector::push_back(std::make_pair(foo, bar)) with vector::emplace_back(foo, bar)

The old way will construct a std::pair first then call move constructor
when putting it into the container, while using emplace will construct
the pair in-place in the container. Also, the emplace way is shorter &
more concise.
2016-11-08 11:50:00 +08:00
Wilson E. Alvarez c0e1e91373 Performance tweak: Use range-based for-loops and allocate std::vector size() and *end() on the stack where favorable. (#16716)
* Use range-based for-loops and allocate std::vector size(), end(), cend(), rend(), crend() on the stack where favorable.

Other minor trivial changes were applied.

* Fixed Android compilation error

* Fixed windows-universal compilation error
2016-10-27 15:10:24 +08:00
James Chen 189ffc4e27 Minor fix for TextureCache::addImage(image, key). (#16613)
* Removes insignificant log: `prevents overloading the autorelease pool`
* Removes unused retain -> autorelease stuff
* Checks the return value of `texture->initWithImage`, if it returns false, texture should be released and set to nullptr.
* More specifc log output in TextureCache::addImage(image, key)
* Checks arguments validation for VolatileTextureMgr::addImage
2016-09-27 15:10:16 +08:00
James Chen b135d512d2 Update copyright to 2016. (#16311) 2016-08-05 09:42:15 +08:00
halx99 bf996c5bac Add ETC1 builtin alpha support. (#16118)
* Add ETC1 builtin alpha support.

* Rename setETC1AlphaFileEndix to setETC1AlphaFileSuffix

* Check whether etc1 alpha suffix is empty

* fix Code ident & Add etc1 alpha test case to SpriteTest.

* Remove unused ETC1AA shader programs

* Fix all review issues and endl issues

* Add a new TriangleCommand::init() with Texture2D* instead of GLuint textureID

* #fix issues
2016-07-25 17:31:54 +08:00
Ricardo Quesada c387f953fa fix: TextureCache ASSERTS if image is invalid
Github issue #15776
2016-06-17 16:07:33 -07:00
mogemimi a348cbda8b Move StringUtils functions from deprecated header file to ccUTF8.h (#15835)
* Move StringUtils functions outside of deprecated header

* Replace deprecated headers with 'base/ccUTF8.h'
2016-06-15 15:01:26 +08:00
MagicXrEv 29cca63822 Texture2D::addImageAsync : Set pixel format correctly. (#15774) 2016-06-03 09:38:01 +08:00
mogemimi 1e04cb5950 Use nullptr instead of 0 or NULL 2016-05-25 03:09:11 +09:00
mogemimi a1a8feed71 Add missing references to avoid unnecessary copies 2016-05-17 01:15:07 +09:00
Steve Tranby 24fd25e143 Iterator erase pattern 2016-04-01 18:29:21 -06:00
mogemimi 2a8d84e7f9 Remove unnecessary const from return types 2016-02-29 16:48:07 +09:00
pandamicro 022bcc24f1 Merge branch 'v3.10' of github.com:cocos2d/cocos2d-x into v3
Conflicts:
	cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_manual.cpp
	cocos/scripting/js-bindings/manual/component/CCComponentJS.cpp
	cocos/scripting/js-bindings/manual/js_bindings_opengl.cpp
2015-12-20 22:56:33 +08:00
Liam fb312a761c update for 3D object render, revert old changes 2015-12-18 11:23:33 +08:00
Wenhai Lin 4fa58602a8 Adds `std::nothrow` to the `new` statements 2015-12-16 14:02:55 +08:00
pandamicro 70dd2af5d5 Merge pull request #14518 from mogemimi/fix-memory-leak-texture-cache
Fix memory leak when initWithImage() failed
2015-12-02 10:20:04 +08:00
mogemimi d539e6c797 Fix memory leak when initWithImage() failed 2015-12-01 12:48:54 +09:00
XiaoFeng 150d907636 Add missing changes to Particle 3d 2015-11-27 19:01:30 +08:00
XiaoFeng d0cd640ac8 Update 2015-11-25 11:15:17 +08:00
XiaoFeng 722f20c4b6 Update implement remove condition macro check. 2015-11-24 18:29:58 +08:00
XiaoFeng eb644ee79f Combine Studio change for 3d components 2015-11-16 15:05:43 +08:00
Martin Taylor 62e36e8006 fix typos and syntax error. A thorough check by tool VSSpellChecker. 2015-09-22 16:08:23 +08:00
andyque 7c665e6447 remove EMSCRIPTEN related code 2015-07-16 14:15:41 +08:00
Vincent Yang d9bc8b7c1b fix bug: don't decrease _asyncRefCount correct in addImageAsyncCallback. 2015-07-09 17:06:55 +08:00
Vincent Yang 1f8b46e911 Fixbug: Need to replace thread unsafe code from TextureCache::addImageAsync. 2015-07-08 15:13:48 +08:00
Justin Hawkwood 90db6fe5d6 Added check that callback is set 2015-06-15 23:36:04 -07:00
Justin Hawkwood 9378b6704c Moved file check to alternate location 2015-06-15 23:31:52 -07:00
Justin Hawkwood 852639cfe7 Added empty string check 2015-06-09 09:19:04 -07:00
Justin Hawkwood eca488b85a Fails if file does not exist
This adds a callback with nullptr if the file does not exists.  Checking this before checking cache means that if a file is cached then deleted, the async call will fail.  To allow a cached but deleted file to return the texture, move the isFileExist check to ALTERNATIVE.

If leaving check where it is, on failure should it also check if the file was cached and remove it?
2015-06-08 17:14:15 -07:00
minggo 273ac5d00a Merge pull request #12002 from WenhaiLin/v3-texturecache-unbindfix
Fixed TextureCache::unbindImageAsync fails to unbind all asynchronous callback for a specified bound image.
2015-05-25 16:29:43 +08:00
WenhaiLin 234ad668ec Fixed TextureCache::unbindImageAsync fails to unbind all asynchronous callback for a specified bound image. 2015-05-25 11:47:37 +08:00
andyque 0352a7a3ea add Android 9-patch image format support
commit c214c4a7a457275785d6377031b5a267d543ffbb
Author: andyque <guanghui8827@126.com>
Date:   Mon May 18 17:16:09 2015 +0800

    Add Android 9-patch format support.

    Squashed commit of the following:

    commit a5a5a7a8f25b5bddae0ba21c56676a3f8d84102a
    Author: andyque <guanghui8827@126.com>
    Date:   Mon May 18 17:08:05 2015 +0800

        finish refactoring

    commit 730bf817f833de56999c616779fc0279890e14bf
    Author: andyque <guanghui8827@126.com>
    Date:   Mon May 18 11:47:08 2015 +0800

        refactoring 9-patch

    commit b45be6d54ac6e70a3fb9aa3eb700b252e4e72a54
    Author: andyque <guanghui8827@126.com>
    Date:   Mon May 18 09:42:06 2015 +0800

        refactor

    commit 384110193f1d581c4a0fb7a2c771c55f1db63cbf
    Author: andyque <guanghui8827@126.com>
    Date:   Fri May 15 17:59:21 2015 +0800

        fix lua and Android compile error

    commit 2877538fb3a436f95400b2ad637ea147b9df81d7
    Author: andyque <guanghui8827@126.com>
    Date:   Fri May 15 11:32:43 2015 +0800

         Add Android 9-patch image format support.

        The 9-patch format is used for creating Scale9Sprite.
2015-05-21 16:04:37 +08:00
Eric Zhong fdd20b4d73 fix memory leak when reload texture 2014-10-20 10:43:18 +08:00
Ricardo Quesada 342d934a0e scheduler and macro fixes
* kRepeatForever -> CC_REPEAT_FOREVER
* schedule_selector -> CC_SCHEDULE_SELECTOR
* [new] Node::schedule(const std::function<>& callback, const std::string &key)

Updates all smaples
2014-10-03 09:38:36 -07:00
Ricardo Quesada 3dda35b4ef Adds `std::nothrow` to `new`
Since cocos2d-x doesn't support exceptions, it is important to add
`std::nothrow` to all the `new` statements
2014-08-27 16:31:57 -07:00
Dale Stammen 70f3f0f913 release glTextures before reloading cached textures 2014-06-12 16:31:46 -07:00
Dhilan007 d755b7ffcb issue #3341:fix TextureCache::addImageAsync repeatedly generate Image for the same image file. 2014-06-12 11:21:42 +08:00
vision e2ce876260 remove new lines 2014-05-23 18:01:17 +08:00
vision ffdf3d7b67 assure threading safety 2014-05-23 17:59:34 +08:00
vision fb6ea21ca8 assure threading safety 2014-05-23 17:49:25 +08:00
vision e3a365ad60 assure threading safety 2014-05-23 17:48:07 +08:00
vision 8128bfce68 check the condition guard 2014-05-23 17:27:59 +08:00
vision 66a33e7d93 no need to pass all the references 2014-05-23 17:21:46 +08:00