diff options
author | Mathias Agopian <mathias@google.com> | 2009-06-24 22:39:26 -0700 |
---|---|---|
committer | Mathias Agopian <mathias@google.com> | 2009-06-25 00:09:27 -0700 |
commit | 2ab55a4e31c37d74abdd85486e1f4045c7f708e2 (patch) | |
tree | d4ff7f4fe7ac7a6078eb819077e1325d7938e28e /libs/surfaceflinger/LayerBuffer.cpp | |
parent | 8d2e83b9f44c7f2207a312fcfda8eb3a4c26745f (diff) | |
download | frameworks_native-2ab55a4e31c37d74abdd85486e1f4045c7f708e2.zip frameworks_native-2ab55a4e31c37d74abdd85486e1f4045c7f708e2.tar.gz frameworks_native-2ab55a4e31c37d74abdd85486e1f4045c7f708e2.tar.bz2 |
make use of new eglGetRenderBufferANDROID extension to clean-up a bit a few hacks added recently
Diffstat (limited to 'libs/surfaceflinger/LayerBuffer.cpp')
-rw-r--r-- | libs/surfaceflinger/LayerBuffer.cpp | 79 |
1 files changed, 42 insertions, 37 deletions
diff --git a/libs/surfaceflinger/LayerBuffer.cpp b/libs/surfaceflinger/LayerBuffer.cpp index 58bba44..d70a71f 100644 --- a/libs/surfaceflinger/LayerBuffer.cpp +++ b/libs/surfaceflinger/LayerBuffer.cpp @@ -468,47 +468,52 @@ void LayerBuffer::BufferSource::onDraw(const Region& clip) const } #endif - copybit_image_t dst; - const DisplayHardware& hw(mLayer.graphicPlane(0).displayHardware()); - sp<FramebufferNativeWindow> fbw = hw.getFb(); - android_native_buffer_t const* nb = fbw->getBackbuffer(); - native_handle_t const* hnd = nb->handle; - - dst.w = 320; - dst.h = 480; - dst.format = 4; - dst.base = 0; - dst.handle = (native_handle_t *)nb->handle; - - const Rect& transformedBounds = mLayer.getTransformedBounds(); - const copybit_rect_t& drect - = reinterpret_cast<const copybit_rect_t&>(transformedBounds); - const State& s(mLayer.drawingState()); - region_iterator it(clip); - - // pick the right orientation for this buffer - int orientation = mLayer.getOrientation(); - if (UNLIKELY(mBufferHeap.transform)) { - Transform rot90; - GraphicPlane::orientationToTransfrom( - ISurfaceComposer::eOrientation90, 0, 0, &rot90); - const Transform& planeTransform(mLayer.graphicPlane(0).transform()); - const Layer::State& s(mLayer.drawingState()); - Transform tr(planeTransform * s.transform * rot90); - orientation = tr.getOrientation(); - } +#ifdef EGL_ANDROID_get_render_buffer + EGLDisplay dpy = eglGetCurrentDisplay(); + EGLSurface draw = eglGetCurrentSurface(EGL_DRAW); + EGLClientBuffer clientBuf = eglGetRenderBufferANDROID(dpy, draw); + android_native_buffer_t* nb = (android_native_buffer_t*)clientBuf; + if (nb == 0) { + err = BAD_VALUE; + } else { + copybit_image_t dst; + dst.w = nb->width; + dst.h = nb->height; + dst.format = nb->format; + dst.base = NULL; // unused by copybit on msm7k + dst.handle = (native_handle_t *)nb->handle; + + const Rect& transformedBounds = mLayer.getTransformedBounds(); + const copybit_rect_t& drect + = reinterpret_cast<const copybit_rect_t&>(transformedBounds); + const State& s(mLayer.drawingState()); + region_iterator it(clip); + + // pick the right orientation for this buffer + int orientation = mLayer.getOrientation(); + if (UNLIKELY(mBufferHeap.transform)) { + Transform rot90; + GraphicPlane::orientationToTransfrom( + ISurfaceComposer::eOrientation90, 0, 0, &rot90); + const Transform& planeTransform(mLayer.graphicPlane(0).transform()); + const Layer::State& s(mLayer.drawingState()); + Transform tr(planeTransform * s.transform * rot90); + orientation = tr.getOrientation(); + } - copybit->set_parameter(copybit, COPYBIT_TRANSFORM, orientation); - copybit->set_parameter(copybit, COPYBIT_PLANE_ALPHA, s.alpha); - copybit->set_parameter(copybit, COPYBIT_DITHER, COPYBIT_ENABLE); + copybit->set_parameter(copybit, COPYBIT_TRANSFORM, orientation); + copybit->set_parameter(copybit, COPYBIT_PLANE_ALPHA, s.alpha); + copybit->set_parameter(copybit, COPYBIT_DITHER, COPYBIT_ENABLE); - err = copybit->stretch(copybit, - &dst, &src.img, &drect, &src.crop, &it); - if (err != NO_ERROR) { - LOGE("copybit failed (%s)", strerror(err)); + err = copybit->stretch(copybit, + &dst, &src.img, &drect, &src.crop, &it); + if (err != NO_ERROR) { + LOGE("copybit failed (%s)", strerror(err)); + } } } - +#endif + if (!copybit || err) { // OpenGL fall-back |