@@ -754,7 +754,7 @@ void OpenGLRenderer::composeLayerRegion(Layer* layer, const Rect& rect) {
754754
755755 // TODO: See LayerRenderer.cpp::generateMesh() for important
756756 // information about this implementation
757- if (!layer->region .isEmpty ()) {
757+ if (CC_LIKELY ( !layer->region .isEmpty () )) {
758758 size_t count;
759759 const android::Rect* rects = layer->region .getArray (&count);
760760
@@ -1398,7 +1398,7 @@ void OpenGLRenderer::drawBitmap(SkBitmap* bitmap, float left, float top, SkPaint
13981398 if (!texture) return ;
13991399 const AutoTexture autoCleanup (texture);
14001400
1401- if (bitmap->getConfig () == SkBitmap::kA8_Config ) {
1401+ if (CC_UNLIKELY ( bitmap->getConfig () == SkBitmap::kA8_Config ) ) {
14021402 drawAlphaBitmap (texture, left, top, paint);
14031403 } else {
14041404 drawTextureRect (left, top, right, bottom, texture, paint);
@@ -1454,9 +1454,9 @@ void OpenGLRenderer::drawBitmapMesh(SkBitmap* bitmap, int meshWidth, int meshHei
14541454 float bottom = FLT_MIN;
14551455
14561456#if RENDER_LAYERS_AS_REGIONS
1457- bool hasActiveLayer = hasLayer ();
1457+ const bool hasActiveLayer = hasLayer ();
14581458#else
1459- bool hasActiveLayer = false ;
1459+ const bool hasActiveLayer = false ;
14601460#endif
14611461
14621462 // TODO: Support the colors array
@@ -1541,7 +1541,7 @@ void OpenGLRenderer::drawBitmap(SkBitmap* bitmap,
15411541
15421542 texture->setWrap (GL_CLAMP_TO_EDGE, true );
15431543
1544- if (mSnapshot ->transform ->isPureTranslate ()) {
1544+ if (CC_LIKELY ( mSnapshot ->transform ->isPureTranslate () )) {
15451545 const float x = (int ) floorf (dstLeft + mSnapshot ->transform ->getTranslateX () + 0 .5f );
15461546 const float y = (int ) floorf (dstTop + mSnapshot ->transform ->getTranslateY () + 0 .5f );
15471547
@@ -1587,7 +1587,7 @@ void OpenGLRenderer::drawPatch(SkBitmap* bitmap, const int32_t* xDivs, const int
15871587 const Patch* mesh = mCaches .patchCache .get (bitmap->width (), bitmap->height (),
15881588 right - left, bottom - top, xDivs, yDivs, colors, width, height, numColors);
15891589
1590- if (mesh && mesh->verticesCount > 0 ) {
1590+ if (CC_LIKELY ( mesh && mesh->verticesCount > 0 ) ) {
15911591 const bool pureTranslate = mSnapshot ->transform ->isPureTranslate ();
15921592#if RENDER_LAYERS_AS_REGIONS
15931593 // Mark the current layer dirty where we are going to draw the patch
@@ -1597,7 +1597,7 @@ void OpenGLRenderer::drawPatch(SkBitmap* bitmap, const int32_t* xDivs, const int
15971597 const size_t count = mesh->quads .size ();
15981598 for (size_t i = 0 ; i < count; i++) {
15991599 const Rect& bounds = mesh->quads .itemAt (i);
1600- if (pureTranslate) {
1600+ if (CC_LIKELY ( pureTranslate) ) {
16011601 const float x = (int ) floorf (bounds.left + offsetX + 0 .5f );
16021602 const float y = (int ) floorf (bounds.top + offsetY + 0 .5f );
16031603 dirtyLayer (x, y, x + bounds.getWidth (), y + bounds.getHeight ());
@@ -1609,7 +1609,7 @@ void OpenGLRenderer::drawPatch(SkBitmap* bitmap, const int32_t* xDivs, const int
16091609 }
16101610#endif
16111611
1612- if (pureTranslate) {
1612+ if (CC_LIKELY ( pureTranslate) ) {
16131613 const float x = (int ) floorf (left + mSnapshot ->transform ->getTranslateX () + 0 .5f );
16141614 const float y = (int ) floorf (top + mSnapshot ->transform ->getTranslateY () + 0 .5f );
16151615
@@ -1637,7 +1637,7 @@ void OpenGLRenderer::drawAARect(float left, float top, float right, float bottom
16371637 float inverseScaleX = 1 .0f ;
16381638 float inverseScaleY = 1 .0f ;
16391639 // The quad that we use needs to account for scaling.
1640- if (!mSnapshot ->transform ->isPureTranslate ()) {
1640+ if (CC_UNLIKELY ( !mSnapshot ->transform ->isPureTranslate () )) {
16411641 Matrix4 *mat = mSnapshot ->transform ;
16421642 float m00 = mat->data [Matrix4::kScaleX ];
16431643 float m01 = mat->data [Matrix4::kSkewY ];
@@ -1743,16 +1743,16 @@ void OpenGLRenderer::drawLines(float* points, int count, SkPaint* paint) {
17431743 // The quad that we use for AA and hairlines needs to account for scaling. For hairlines
17441744 // the line on the screen should always be one pixel wide regardless of scale. For
17451745 // AA lines, we only want one pixel of translucent boundary around the quad.
1746- if (!mSnapshot ->transform ->isPureTranslate ()) {
1746+ if (CC_UNLIKELY ( !mSnapshot ->transform ->isPureTranslate () )) {
17471747 Matrix4 *mat = mSnapshot ->transform ;
17481748 float m00 = mat->data [Matrix4::kScaleX ];
17491749 float m01 = mat->data [Matrix4::kSkewY ];
17501750 float m02 = mat->data [2 ];
17511751 float m10 = mat->data [Matrix4::kSkewX ];
17521752 float m11 = mat->data [Matrix4::kScaleX ];
17531753 float m12 = mat->data [6 ];
1754- float scaleX = sqrt (m00* m00 + m01* m01);
1755- float scaleY = sqrt (m10* m10 + m11* m11);
1754+ float scaleX = sqrtf (m00 * m00 + m01 * m01);
1755+ float scaleY = sqrtf (m10 * m10 + m11 * m11);
17561756 inverseScaleX = (scaleX != 0 ) ? (inverseScaleX / scaleX) : 0 ;
17571757 inverseScaleY = (scaleY != 0 ) ? (inverseScaleY / scaleY) : 0 ;
17581758 if (inverseScaleX != 1 .0f || inverseScaleY != 1 .0f ) {
@@ -1770,11 +1770,7 @@ void OpenGLRenderer::drawLines(float* points, int count, SkPaint* paint) {
17701770 setupDrawColor (paint->getColor (), alpha);
17711771 setupDrawColorFilter ();
17721772 setupDrawShader ();
1773- if (isAA) {
1774- setupDrawBlending (true , mode);
1775- } else {
1776- setupDrawBlending (mode);
1777- }
1773+ setupDrawBlending (isAA, mode);
17781774 setupDrawProgram ();
17791775 setupDrawModelViewIdentity (true );
17801776 setupDrawColorUniforms ();
@@ -1792,7 +1788,7 @@ void OpenGLRenderer::drawLines(float* points, int count, SkPaint* paint) {
17921788 Vertex* vertices = &lines[0 ];
17931789 AAVertex wLines[verticesCount];
17941790 AAVertex* aaVertices = &wLines[0 ];
1795- if (!isAA) {
1791+ if (CC_UNLIKELY ( !isAA) ) {
17961792 setupDrawVertices (vertices);
17971793 } else {
17981794 void * widthCoords = ((GLbyte*) aaVertices) + gVertexAAWidthOffset ;
@@ -2152,9 +2148,9 @@ void OpenGLRenderer::drawPosText(const char* text, int bytesCount, int count,
21522148 Rect bounds (FLT_MAX / 2 .0f , FLT_MAX / 2 .0f , FLT_MIN / 2 .0f , FLT_MIN / 2 .0f );
21532149
21542150#if RENDER_LAYERS_AS_REGIONS
2155- bool hasActiveLayer = hasLayer ();
2151+ const bool hasActiveLayer = hasLayer ();
21562152#else
2157- bool hasActiveLayer = false ;
2153+ const bool hasActiveLayer = false ;
21582154#endif
21592155
21602156 if (fontRenderer.renderPosText (paint, clip, text, 0 , bytesCount, count, x, y,
@@ -2201,7 +2197,7 @@ void OpenGLRenderer::drawText(const char* text, int bytesCount, int count,
22012197 const float oldX = x;
22022198 const float oldY = y;
22032199 const bool pureTranslate = mSnapshot ->transform ->isPureTranslate ();
2204- if (pureTranslate) {
2200+ if (CC_LIKELY ( pureTranslate) ) {
22052201 x = (int ) floorf (x + mSnapshot ->transform ->getTranslateX () + 0 .5f );
22062202 y = (int ) floorf (y + mSnapshot ->transform ->getTranslateY () + 0 .5f );
22072203 }
@@ -2218,7 +2214,7 @@ void OpenGLRenderer::drawText(const char* text, int bytesCount, int count,
22182214 SkXfermode::Mode mode;
22192215 getAlphaAndMode (paint, &alpha, &mode);
22202216
2221- if (mHasShadow ) {
2217+ if (CC_UNLIKELY ( mHasShadow ) ) {
22222218 mCaches .activeTexture (0 );
22232219
22242220 mCaches .dropShadowCache .setFontRenderer (fontRenderer);
@@ -2277,9 +2273,9 @@ void OpenGLRenderer::drawText(const char* text, int bytesCount, int count,
22772273 Rect bounds (FLT_MAX / 2 .0f , FLT_MAX / 2 .0f , FLT_MIN / 2 .0f , FLT_MIN / 2 .0f );
22782274
22792275#if RENDER_LAYERS_AS_REGIONS
2280- bool hasActiveLayer = hasLayer ();
2276+ const bool hasActiveLayer = hasLayer ();
22812277#else
2282- bool hasActiveLayer = false ;
2278+ const bool hasActiveLayer = false ;
22832279#endif
22842280
22852281 if (fontRenderer.renderText (paint, clip, text, 0 , bytesCount, count, x, y,
@@ -2326,7 +2322,7 @@ void OpenGLRenderer::drawLayer(Layer* layer, float x, float y, SkPaint* paint) {
23262322 layer->setAlpha (alpha, mode);
23272323
23282324#if RENDER_LAYERS_AS_REGIONS
2329- if (!layer->region .isEmpty ()) {
2325+ if (CC_LIKELY ( !layer->region .isEmpty () )) {
23302326 if (layer->region .isRect ()) {
23312327 composeLayerRect (layer, layer->regionRect );
23322328 } else if (layer->mesh ) {
@@ -2342,7 +2338,7 @@ void OpenGLRenderer::drawLayer(Layer* layer, float x, float y, SkPaint* paint) {
23422338 setupDrawPureColorUniforms ();
23432339 setupDrawColorFilterUniforms ();
23442340 setupDrawTexture (layer->getTexture ());
2345- if (mSnapshot ->transform ->isPureTranslate ()) {
2341+ if (CC_LIKELY ( mSnapshot ->transform ->isPureTranslate () )) {
23462342 x = (int ) floorf (x + mSnapshot ->transform ->getTranslateX () + 0 .5f );
23472343 y = (int ) floorf (y + mSnapshot ->transform ->getTranslateY () + 0 .5f );
23482344
@@ -2502,7 +2498,7 @@ void OpenGLRenderer::drawTextDecorations(const char* text, int bytesCount, float
25022498 break ;
25032499 }
25042500
2505- if (underlineWidth > 0 .0f ) {
2501+ if (CC_LIKELY ( underlineWidth > 0 .0f ) ) {
25062502 const float textSize = paintCopy.getTextSize ();
25072503 const float strokeWidth = fmax (textSize * kStdUnderline_Thickness , 1 .0f );
25082504
@@ -2571,7 +2567,7 @@ void OpenGLRenderer::drawTextureRect(float left, float top, float right, float b
25712567
25722568 texture->setWrap (GL_CLAMP_TO_EDGE, true );
25732569
2574- if (mSnapshot ->transform ->isPureTranslate ()) {
2570+ if (CC_LIKELY ( mSnapshot ->transform ->isPureTranslate () )) {
25752571 const float x = (int ) floorf (left + mSnapshot ->transform ->getTranslateX () + 0 .5f );
25762572 const float y = (int ) floorf (top + mSnapshot ->transform ->getTranslateY () + 0 .5f );
25772573
@@ -2631,8 +2627,8 @@ void OpenGLRenderer::chooseBlending(bool blend, SkXfermode::Mode mode,
26312627 // the blending, turn blending off here
26322628 // If the blend mode cannot be implemented using shaders, fall
26332629 // back to the default SrcOver blend mode instead
2634- if ( mode > SkXfermode::kScreen_Mode ) {
2635- if (mCaches .extensions .hasFramebufferFetch ()) {
2630+ if CC_UNLIKELY (( mode > SkXfermode::kScreen_Mode ) ) {
2631+ if (CC_UNLIKELY ( mCaches .extensions .hasFramebufferFetch () )) {
26362632 description.framebufferMode = mode;
26372633 description.swapSrcDst = swapSrcDst;
26382634
0 commit comments