Skip to content

Commit 991db46

Browse files
committed
Merge commit '4a23e754b250a9a411136c9c5114d2c2e4c5eba6' into scgamex-v3
* commit '4a23e754b250a9a411136c9c5114d2c2e4c5eba6': [ci skip][AUTO]: updating luabinding & jsbinding & cocos_file.json automatically (cocos2d#18647) V3 multisampling support (cocos2d#18632) Fix a crash bug when the UserDefault.xml file is empty. (cocos2d#18626) android emulator stensil fix (cocos2d#18637) Add blend function to Text (cocos2d#18631) remove unuseful content (cocos2d#18644) [ci skip][AUTO]: updating luabinding & jsbinding & cocos_file.json automatically (cocos2d#18642) fix nbsp (cocos2d#18147) fix issue that render texture will have wrong effect if using with global z order (cocos2d#18629)
2 parents 1879068 + 4a23e75 commit 991db46

File tree

42 files changed

+330
-59
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+330
-59
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,4 +296,3 @@ Contact us
296296
[9]: http://discuss.cocos2d-x.org "http://discuss.cocos2d-x.org"
297297
[10]: http://www.twitter.com/cocos2dx "http://www.twitter.com/cocos2dx"
298298
[11]: http://t.sina.com.cn/cocos2dx "http://t.sina.com.cn/cocos2dx"
299-
[12]: https://webchat.freenode.net/ "https://webchat.freenode.net/"

cocos/2d/CCRenderTexture.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,12 @@ void RenderTexture::draw(Renderer *renderer, const Mat4 &transform, uint32_t fla
771771
}
772772
}
773773

774+
void RenderTexture::setGlobalZOrder(float globalZOrder)
775+
{
776+
Node::setGlobalZOrder(globalZOrder);
777+
_sprite->setGlobalZOrder(globalZOrder);
778+
}
779+
774780
void RenderTexture::begin()
775781
{
776782
Director* director = Director::getInstance();
@@ -805,15 +811,17 @@ void RenderTexture::begin()
805811
renderer->addCommand(&_groupCommand);
806812
renderer->pushGroup(_groupCommand.getRenderQueueID());
807813

808-
_beginCommand.init(_globalZOrder);
814+
// Begine command should be the first command of the command group.
815+
_beginCommand.init(INT_MIN);
809816
_beginCommand.func = CC_CALLBACK_0(RenderTexture::onBegin, this);
810817

811818
Director::getInstance()->getRenderer()->addCommand(&_beginCommand);
812819
}
813820

814821
void RenderTexture::end()
815822
{
816-
_endCommand.init(_globalZOrder);
823+
// End command should be the last command of the command group.
824+
_endCommand.init(INT_MAX);
817825
_endCommand.func = CC_CALLBACK_0(RenderTexture::onEnd, this);
818826

819827
Director* director = Director::getInstance();

cocos/2d/CCRenderTexture.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ class CC_DLL RenderTexture : public Node
264264
// Overrides
265265
virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override;
266266
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
267+
virtual void setGlobalZOrder(float globalZOrder) override;
267268

268269
/** Flag: Use stack matrix computed from scene hierarchy or generate new modelView and projection matrix.
269270
*

cocos/base/CCUserDefault.cpp

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,25 +57,41 @@ static tinyxml2::XMLElement* getXMLNodeForKey(const char* pKey, tinyxml2::XMLEle
5757

5858
do
5959
{
60-
tinyxml2::XMLDocument* xmlDoc = new (std::nothrow) tinyxml2::XMLDocument();
60+
tinyxml2::XMLDocument* xmlDoc = new (std::nothrow) tinyxml2::XMLDocument();
6161
*doc = xmlDoc;
62+
*rootNode = nullptr;
6263

6364
std::string xmlBuffer = FileUtils::getInstance()->getStringFromFile(UserDefault::getInstance()->getXMLFilePath());
6465

65-
if (xmlBuffer.empty())
66+
if (!xmlBuffer.empty())
6667
{
67-
CCLOG("can not read xml file");
68-
break;
68+
xmlDoc->Parse(xmlBuffer.c_str(), xmlBuffer.size());
69+
70+
// get root node
71+
*rootNode = xmlDoc->RootElement();
6972
}
70-
xmlDoc->Parse(xmlBuffer.c_str(), xmlBuffer.size());
7173

72-
// get root node
73-
*rootNode = xmlDoc->RootElement();
7474
if (nullptr == *rootNode)
7575
{
76-
CCLOG("read root node error");
77-
break;
76+
// try to insert xml declaration
77+
if (!xmlDoc->FirstChild())
78+
{
79+
tinyxml2::XMLDeclaration *xmlDeclaration = xmlDoc->NewDeclaration(nullptr);
80+
if (nullptr != xmlDeclaration)
81+
{
82+
xmlDoc->LinkEndChild(xmlDeclaration);
83+
}
84+
}
85+
86+
// create root element
87+
tinyxml2::XMLElement *rootEle = xmlDoc->NewElement(USERDEFAULT_ROOT_NAME);
88+
if (nullptr == rootEle)
89+
break;
90+
91+
xmlDoc->LinkEndChild(rootEle);
92+
*rootNode = rootEle;
7893
}
94+
7995
// find the node
8096
curNode = (*rootNode)->FirstChildElement();
8197
while (nullptr != curNode)
@@ -95,7 +111,7 @@ static tinyxml2::XMLElement* getXMLNodeForKey(const char* pKey, tinyxml2::XMLEle
95111

96112
static void setValueForKey(const char* pKey, const char* pValue)
97113
{
98-
tinyxml2::XMLElement* rootNode;
114+
tinyxml2::XMLElement* rootNode;
99115
tinyxml2::XMLDocument* doc;
100116
tinyxml2::XMLElement* node;
101117
// check the params

cocos/editor-support/cocostudio/ActionTimeline/CCFrame.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ TextureFrame* TextureFrame::create()
152152
}
153153

154154
TextureFrame::TextureFrame()
155-
: _textureName("")
155+
: _sprite(nullptr)
156+
, _textureName("")
156157
{
157158
}
158159

cocos/platform/CCFileUtils.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ class DictMaker : public SAXDelegator
8686
public:
8787
DictMaker()
8888
: _resultType(SAX_RESULT_NONE)
89+
, _state(SAX_NONE)
8990
{
9091
}
9192

cocos/platform/CCGLView.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ namespace {
9191
}
9292

9393
//default context attributions are set as follows
94-
GLContextAttrs GLView::_glContextAttrs = {8, 8, 8, 8, 24, 8};
94+
GLContextAttrs GLView::_glContextAttrs = {8, 8, 8, 8, 24, 8, 0};
9595

9696
const char* GLView::EVENT_WINDOW_RESIZED = "glview_window_resized";
9797
const char* GLView::EVENT_WINDOW_FOCUSED = "glview_window_focused";

cocos/platform/CCGLView.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ struct GLContextAttrs
8282
int alphaBits;
8383
int depthBits;
8484
int stencilBits;
85+
int multisamplingCount;
8586
};
8687

8788
NS_CC_BEGIN

cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,9 @@ public void init() {
270270
mFrameLayout.addView(this.mGLSurfaceView);
271271

272272
// Switch to supported OpenGL (ARGB888) mode on emulator
273-
if (isAndroidEmulator())
274-
this.mGLSurfaceView.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
273+
// this line dows not needed on new emulators and also it breaks stencil buffer
274+
//if (isAndroidEmulator())
275+
// this.mGLSurfaceView.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
275276

276277
this.mGLSurfaceView.setCocos2dxRenderer(new Cocos2dxRenderer());
277278
this.mGLSurfaceView.setCocos2dxEditText(edittext);
@@ -355,9 +356,9 @@ private class Cocos2dxEGLConfigChooser implements GLSurfaceView.EGLConfigChooser
355356
private int[] mConfigAttributes;
356357
private final int EGL_OPENGL_ES2_BIT = 0x04;
357358
private final int EGL_OPENGL_ES3_BIT = 0x40;
358-
public Cocos2dxEGLConfigChooser(int redSize, int greenSize, int blueSize, int alphaSize, int depthSize, int stencilSize)
359+
public Cocos2dxEGLConfigChooser(int redSize, int greenSize, int blueSize, int alphaSize, int depthSize, int stencilSize, int multisamplingCount)
359360
{
360-
mConfigAttributes = new int[] {redSize, greenSize, blueSize, alphaSize, depthSize, stencilSize};
361+
mConfigAttributes = new int[] {redSize, greenSize, blueSize, alphaSize, depthSize, stencilSize, multisamplingCount};
361362
}
362363
public Cocos2dxEGLConfigChooser(int[] attributes)
363364
{
@@ -376,17 +377,34 @@ public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display)
376377
EGL10.EGL_ALPHA_SIZE, mConfigAttributes[3],
377378
EGL10.EGL_DEPTH_SIZE, mConfigAttributes[4],
378379
EGL10.EGL_STENCIL_SIZE, mConfigAttributes[5],
380+
EGL10.EGL_SAMPLE_BUFFERS, (mConfigAttributes[6] > 0) ? 1 : 0,
381+
EGL10.EGL_SAMPLES, mConfigAttributes[6],
379382
EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
380383
EGL10.EGL_NONE
381384
},
382385
{
383-
// GL ES 2 with user set
386+
// GL ES 2 with user set 16 bit depth buffer
384387
EGL10.EGL_RED_SIZE, mConfigAttributes[0],
385388
EGL10.EGL_GREEN_SIZE, mConfigAttributes[1],
386389
EGL10.EGL_BLUE_SIZE, mConfigAttributes[2],
387390
EGL10.EGL_ALPHA_SIZE, mConfigAttributes[3],
388391
EGL10.EGL_DEPTH_SIZE, mConfigAttributes[4] >= 24 ? 16 : mConfigAttributes[4],
389392
EGL10.EGL_STENCIL_SIZE, mConfigAttributes[5],
393+
EGL10.EGL_SAMPLE_BUFFERS, (mConfigAttributes[6] > 0) ? 1 : 0,
394+
EGL10.EGL_SAMPLES, mConfigAttributes[6],
395+
EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
396+
EGL10.EGL_NONE
397+
},
398+
{
399+
// GL ES 2 with user set 16 bit depth buffer without multisampling
400+
EGL10.EGL_RED_SIZE, mConfigAttributes[0],
401+
EGL10.EGL_GREEN_SIZE, mConfigAttributes[1],
402+
EGL10.EGL_BLUE_SIZE, mConfigAttributes[2],
403+
EGL10.EGL_ALPHA_SIZE, mConfigAttributes[3],
404+
EGL10.EGL_DEPTH_SIZE, mConfigAttributes[4] >= 24 ? 16 : mConfigAttributes[4],
405+
EGL10.EGL_STENCIL_SIZE, mConfigAttributes[5],
406+
EGL10.EGL_SAMPLE_BUFFERS, 0,
407+
EGL10.EGL_SAMPLES, 0,
390408
EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
391409
EGL10.EGL_NONE
392410
},

cocos/platform/android/javaactivity-android.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,12 @@ JNIEXPORT jintArray Java_org_cocos2dx_lib_Cocos2dxActivity_getGLContextAttrs(JNI
116116
cocos2d::Application::getInstance()->initGLContextAttrs();
117117
GLContextAttrs _glContextAttrs = GLView::getGLContextAttrs();
118118

119-
int tmp[6] = {_glContextAttrs.redBits, _glContextAttrs.greenBits, _glContextAttrs.blueBits,
120-
_glContextAttrs.alphaBits, _glContextAttrs.depthBits, _glContextAttrs.stencilBits};
119+
int tmp[7] = {_glContextAttrs.redBits, _glContextAttrs.greenBits, _glContextAttrs.blueBits,
120+
_glContextAttrs.alphaBits, _glContextAttrs.depthBits, _glContextAttrs.stencilBits, _glContextAttrs.multisamplingCount};
121121

122122

123-
jintArray glContextAttrsJava = env->NewIntArray(6);
124-
env->SetIntArrayRegion(glContextAttrsJava, 0, 6, tmp);
123+
jintArray glContextAttrsJava = env->NewIntArray(7);
124+
env->SetIntArrayRegion(glContextAttrsJava, 0, 7, tmp);
125125

126126
return glContextAttrsJava;
127127
}

0 commit comments

Comments
 (0)