OSDN Git Service

Remove ANativeWindow call to avoid blocking call
authorChris Craik <ccraik@google.com>
Tue, 9 Aug 2011 22:40:21 +0000 (15:40 -0700)
committerChris Craik <ccraik@google.com>
Tue, 9 Aug 2011 22:40:21 +0000 (15:40 -0700)
bug:5114637

Determine alpha blending through surface texture instead of ANativeWindow call.

Change-Id: I5a56178047b7f7782bbd3b736e98f0d5965c1c2b

Source/WebCore/platform/graphics/android/MediaTexture.cpp

index 3fecfb5..b9c640d 100644 (file)
@@ -104,10 +104,19 @@ void MediaTexture::drawContent(const TransformationMatrix& matrix)
 
     m_surfaceTexture->updateTexImage();
 
-    bool forceBlending = ANativeWindow_getFormat(m_surfaceTextureClient.get()) == WINDOW_FORMAT_RGB_565;
+    sp<GraphicBuffer> buf = m_surfaceTexture->getCurrentBuffer();
+    PixelFormat f = buf->getPixelFormat();
+
+    // only attempt to use alpha blending if alpha channel exists
+    bool forceAlphaBlending = !(
+        PIXEL_FORMAT_RGBX_8888 == f ||
+        PIXEL_FORMAT_RGB_888 == f ||
+        PIXEL_FORMAT_RGB_565 == f ||
+        PIXEL_FORMAT_RGB_332 == f);
+
     TilesManager::instance()->shader()->drawLayerQuad(matrix, m_dimensions,
                                                       m_textureId, 1.0f,
-                                                      forceBlending, GL_TEXTURE_EXTERNAL_OES);
+                                                      forceAlphaBlending, GL_TEXTURE_EXTERNAL_OES);
 }
 
 void MediaTexture::drawVideo(const TransformationMatrix& matrix, const SkRect& parentBounds)