@@ -2303,6 +2303,44 @@ status_t OpenGLRenderer::drawRect(float left, float top, float right, float bott
23032303 return DrawGlInfo::kStatusDrew ;
23042304}
23052305
2306+ void OpenGLRenderer::drawTextShadow (SkPaint* paint, const char * text, int bytesCount, int count,
2307+ const float * positions, FontRenderer& fontRenderer, int alpha, SkXfermode::Mode mode,
2308+ float x, float y) {
2309+ mCaches .activeTexture (0 );
2310+
2311+ // NOTE: The drop shadow will not perform gamma correction
2312+ // if shader-based correction is enabled
2313+ mCaches .dropShadowCache .setFontRenderer (fontRenderer);
2314+ const ShadowTexture* shadow = mCaches .dropShadowCache .get (
2315+ paint, text, bytesCount, count, mShadowRadius , positions);
2316+ const AutoTexture autoCleanup (shadow);
2317+
2318+ const float sx = x - shadow->left + mShadowDx ;
2319+ const float sy = y - shadow->top + mShadowDy ;
2320+
2321+ const int shadowAlpha = ((mShadowColor >> 24 ) & 0xFF ) * mSnapshot ->alpha ;
2322+ int shadowColor = mShadowColor ;
2323+ if (mShader ) {
2324+ shadowColor = 0xffffffff ;
2325+ }
2326+
2327+ setupDraw ();
2328+ setupDrawWithTexture (true );
2329+ setupDrawAlpha8Color (shadowColor, shadowAlpha < 255 ? shadowAlpha : alpha);
2330+ setupDrawColorFilter ();
2331+ setupDrawShader ();
2332+ setupDrawBlending (true , mode);
2333+ setupDrawProgram ();
2334+ setupDrawModelView (sx, sy, sx + shadow->width , sy + shadow->height );
2335+ setupDrawTexture (shadow->id );
2336+ setupDrawPureColorUniforms ();
2337+ setupDrawColorFilterUniforms ();
2338+ setupDrawShaderUniforms ();
2339+ setupDrawMesh (NULL , (GLvoid*) gMeshTextureOffset );
2340+
2341+ glDrawArrays (GL_TRIANGLE_STRIP, 0 , gMeshCount );
2342+ }
2343+
23062344status_t OpenGLRenderer::drawPosText (const char * text, int bytesCount, int count,
23072345 const float * positions, SkPaint* paint) {
23082346 if (text == NULL || count == 0 || mSnapshot ->isIgnored () ||
@@ -2331,6 +2369,11 @@ status_t OpenGLRenderer::drawPosText(const char* text, int bytesCount, int count
23312369 SkXfermode::Mode mode;
23322370 getAlphaAndMode (paint, &alpha, &mode);
23332371
2372+ if (CC_UNLIKELY (mHasShadow )) {
2373+ drawTextShadow (paint, text, bytesCount, count, positions, fontRenderer, alpha, mode,
2374+ 0 .0f , 0 .0f );
2375+ }
2376+
23342377 // Pick the appropriate texture filtering
23352378 bool linearFilter = mSnapshot ->transform ->changesBounds ();
23362379 if (pureTranslate && !linearFilter) {
@@ -2424,39 +2467,7 @@ status_t OpenGLRenderer::drawText(const char* text, int bytesCount, int count,
24242467 getAlphaAndMode (paint, &alpha, &mode);
24252468
24262469 if (CC_UNLIKELY (mHasShadow )) {
2427- mCaches .activeTexture (0 );
2428-
2429- // NOTE: The drop shadow will not perform gamma correction
2430- // if shader-based correction is enabled
2431- mCaches .dropShadowCache .setFontRenderer (fontRenderer);
2432- const ShadowTexture* shadow = mCaches .dropShadowCache .get (
2433- paint, text, bytesCount, count, mShadowRadius );
2434- const AutoTexture autoCleanup (shadow);
2435-
2436- const float sx = oldX - shadow->left + mShadowDx ;
2437- const float sy = oldY - shadow->top + mShadowDy ;
2438-
2439- const int shadowAlpha = ((mShadowColor >> 24 ) & 0xFF ) * mSnapshot ->alpha ;
2440- int shadowColor = mShadowColor ;
2441- if (mShader ) {
2442- shadowColor = 0xffffffff ;
2443- }
2444-
2445- setupDraw ();
2446- setupDrawWithTexture (true );
2447- setupDrawAlpha8Color (shadowColor, shadowAlpha < 255 ? shadowAlpha : alpha);
2448- setupDrawColorFilter ();
2449- setupDrawShader ();
2450- setupDrawBlending (true , mode);
2451- setupDrawProgram ();
2452- setupDrawModelView (sx, sy, sx + shadow->width , sy + shadow->height );
2453- setupDrawTexture (shadow->id );
2454- setupDrawPureColorUniforms ();
2455- setupDrawColorFilterUniforms ();
2456- setupDrawShaderUniforms ();
2457- setupDrawMesh (NULL , (GLvoid*) gMeshTextureOffset );
2458-
2459- glDrawArrays (GL_TRIANGLE_STRIP, 0 , gMeshCount );
2470+ drawTextShadow (paint, text, bytesCount, count, NULL , fontRenderer, alpha, mode, oldX, oldY);
24602471 }
24612472
24622473 // Pick the appropriate texture filtering
0 commit comments