summaryrefslogtreecommitdiffstats
path: root/libs/surfaceflinger
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2010-02-04 17:13:06 -0800
committerMathias Agopian <mathias@google.com>2010-02-04 17:13:06 -0800
commita7e380396ea68b2247a61e6fc676724a976223f9 (patch)
treeb51aab06d63397e9688653e32ac4955e73140ab8 /libs/surfaceflinger
parent8dccb26901973722164f2a11551fd6d5c52081bf (diff)
downloadframeworks_native-a7e380396ea68b2247a61e6fc676724a976223f9.zip
frameworks_native-a7e380396ea68b2247a61e6fc676724a976223f9.tar.gz
frameworks_native-a7e380396ea68b2247a61e6fc676724a976223f9.tar.bz2
Add support for direct EGLImageKHR use with pushbuffer API
We now always first try to use the EGLImageKHR directly before making a copy with copybit. The copy may be needed when EGLImage doesn't support the requested format, which is currently the case with YUV.
Diffstat (limited to 'libs/surfaceflinger')
-rw-r--r--libs/surfaceflinger/LayerBuffer.cpp46
-rw-r--r--libs/surfaceflinger/LayerBuffer.h1
2 files changed, 31 insertions, 16 deletions
diff --git a/libs/surfaceflinger/LayerBuffer.cpp b/libs/surfaceflinger/LayerBuffer.cpp
index 2735aa2..bd3113b 100644
--- a/libs/surfaceflinger/LayerBuffer.cpp
+++ b/libs/surfaceflinger/LayerBuffer.cpp
@@ -328,7 +328,8 @@ bool LayerBuffer::Source::transformed() const {
LayerBuffer::BufferSource::BufferSource(LayerBuffer& layer,
const ISurface::BufferHeap& buffers)
- : Source(layer), mStatus(NO_ERROR), mBufferSize(0)
+ : Source(layer), mStatus(NO_ERROR), mBufferSize(0),
+ mUseEGLImageDirectly(true)
{
if (buffers.heap == NULL) {
// this is allowed, but in this case, it is illegal to receive
@@ -466,25 +467,38 @@ void LayerBuffer::BufferSource::onDraw(const Region& clip) const
#if defined(EGL_ANDROID_image_native_buffer)
if (mLayer.mFlags & DisplayHardware::DIRECT_TEXTURE) {
- copybit_device_t* copybit = mLayer.mBlitEngine;
- if (copybit && ourBuffer->supportsCopybit()) {
- // create our EGLImageKHR the first time
- err = initTempBuffer();
- if (err == NO_ERROR) {
+ err = INVALID_OPERATION;
+ if (ourBuffer->supportsCopybit()) {
+ // First, try to use the buffer as an EGLImage directly
+ if (mUseEGLImageDirectly) {
// NOTE: Assume the buffer is allocated with the proper USAGE flags
- const NativeBuffer& dst(mTempBuffer);
- region_iterator clip(Region(Rect(dst.crop.r, dst.crop.b)));
- copybit->set_parameter(copybit, COPYBIT_TRANSFORM, 0);
- copybit->set_parameter(copybit, COPYBIT_PLANE_ALPHA, 0xFF);
- copybit->set_parameter(copybit, COPYBIT_DITHER, COPYBIT_ENABLE);
- err = copybit->stretch(copybit, &dst.img, &src.img,
- &dst.crop, &src.crop, &clip);
+ sp<GraphicBuffer> buffer = new GraphicBuffer(
+ src.img.w, src.img.h, src.img.format,
+ GraphicBuffer::USAGE_HW_TEXTURE,
+ src.img.w, src.img.handle, false);
+ err = mLayer.initializeEglImage(buffer, &mTexture);
if (err != NO_ERROR) {
- clearTempBufferImage();
+ mUseEGLImageDirectly = false;
+ }
+ }
+ copybit_device_t* copybit = mLayer.mBlitEngine;
+ if (copybit && err != NO_ERROR) {
+ // create our EGLImageKHR the first time
+ err = initTempBuffer();
+ if (err == NO_ERROR) {
+ // NOTE: Assume the buffer is allocated with the proper USAGE flags
+ const NativeBuffer& dst(mTempBuffer);
+ region_iterator clip(Region(Rect(dst.crop.r, dst.crop.b)));
+ copybit->set_parameter(copybit, COPYBIT_TRANSFORM, 0);
+ copybit->set_parameter(copybit, COPYBIT_PLANE_ALPHA, 0xFF);
+ copybit->set_parameter(copybit, COPYBIT_DITHER, COPYBIT_ENABLE);
+ err = copybit->stretch(copybit, &dst.img, &src.img,
+ &dst.crop, &src.crop, &clip);
+ if (err != NO_ERROR) {
+ clearTempBufferImage();
+ }
}
}
- } else {
- err = INVALID_OPERATION;
}
}
#endif
diff --git a/libs/surfaceflinger/LayerBuffer.h b/libs/surfaceflinger/LayerBuffer.h
index e03f92c..3257b76 100644
--- a/libs/surfaceflinger/LayerBuffer.h
+++ b/libs/surfaceflinger/LayerBuffer.h
@@ -145,6 +145,7 @@ private:
mutable LayerBase::Texture mTexture;
mutable NativeBuffer mTempBuffer;
mutable sp<GraphicBuffer> mTempGraphicBuffer;
+ mutable bool mUseEGLImageDirectly;
};
class OverlaySource : public Source {