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 | 26c28b16f3464eeb98b091b915ccf494ac31c35f (patch) | |
tree | a13c8d030ad3f9988c4958d7cbac328d20df7dcb | |
parent | c1e3ec555b79b1e45fccbdf0bbc8ac2d51902860 (diff) | |
download | frameworks_base-26c28b16f3464eeb98b091b915ccf494ac31c35f.zip frameworks_base-26c28b16f3464eeb98b091b915ccf494ac31c35f.tar.gz frameworks_base-26c28b16f3464eeb98b091b915ccf494ac31c35f.tar.bz2 |
make use of new eglGetRenderBufferANDROID extension to clean-up a bit a few hacks added recently
-rw-r--r-- | include/ui/FramebufferNativeWindow.h | 6 | ||||
-rw-r--r-- | libs/surfaceflinger/DisplayHardware/DisplayHardware.cpp | 5 | ||||
-rw-r--r-- | libs/surfaceflinger/DisplayHardware/DisplayHardware.h | 3 | ||||
-rw-r--r-- | libs/surfaceflinger/LayerBuffer.cpp | 79 | ||||
-rw-r--r-- | libs/ui/FramebufferNativeWindow.cpp | 6 |
5 files changed, 42 insertions, 57 deletions
diff --git a/include/ui/FramebufferNativeWindow.h b/include/ui/FramebufferNativeWindow.h index 03d064c..e72357a 100644 --- a/include/ui/FramebufferNativeWindow.h +++ b/include/ui/FramebufferNativeWindow.h @@ -55,9 +55,6 @@ public: bool isUpdateOnDemand() const { return mUpdateOnDemand; } status_t setUpdateRectangle(const Rect& updateRect); - // FIXME: needed for copybit hack in LayerBuffer - android_native_buffer_t const* getBackbuffer() const; - private: friend class LightRefBase<FramebufferNativeWindow>; ~FramebufferNativeWindow(); // this class cannot be overloaded @@ -78,9 +75,6 @@ private: int32_t mNumFreeBuffers; int32_t mBufferHead; bool mUpdateOnDemand; - - // FIXME: for getBackbuffer - int32_t mLastDequeued; }; // --------------------------------------------------------------------------- diff --git a/libs/surfaceflinger/DisplayHardware/DisplayHardware.cpp b/libs/surfaceflinger/DisplayHardware/DisplayHardware.cpp index 925f5cc..1719b74 100644 --- a/libs/surfaceflinger/DisplayHardware/DisplayHardware.cpp +++ b/libs/surfaceflinger/DisplayHardware/DisplayHardware.cpp @@ -348,8 +348,3 @@ void DisplayHardware::makeCurrent() const { eglMakeCurrent(mDisplay, mSurface, mSurface, mContext); } - -sp<FramebufferNativeWindow> DisplayHardware::getFb() const { - return mNativeWindow; -} - diff --git a/libs/surfaceflinger/DisplayHardware/DisplayHardware.h b/libs/surfaceflinger/DisplayHardware/DisplayHardware.h index 240c5d1..8972d51 100644 --- a/libs/surfaceflinger/DisplayHardware/DisplayHardware.h +++ b/libs/surfaceflinger/DisplayHardware/DisplayHardware.h @@ -84,9 +84,6 @@ public: return Rect(mWidth, mHeight); } - // FIXME: needed in LayerBuffer for msm7k/copybit hack - sp<FramebufferNativeWindow> getFb() const; - private: void init(uint32_t displayIndex) __attribute__((noinline)); void fini() __attribute__((noinline)); 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 diff --git a/libs/ui/FramebufferNativeWindow.cpp b/libs/ui/FramebufferNativeWindow.cpp index 406c072..8c8fd6b 100644 --- a/libs/ui/FramebufferNativeWindow.cpp +++ b/libs/ui/FramebufferNativeWindow.cpp @@ -63,11 +63,6 @@ private: }; -android_native_buffer_t const* FramebufferNativeWindow::getBackbuffer() const { - return static_cast<android_native_buffer_t const*>(buffers[mLastDequeued].get()); -} - - /* * This implements the (main) framebuffer management. This class is used * mostly by SurfaceFlinger, but also by command line GL application. @@ -170,7 +165,6 @@ int FramebufferNativeWindow::dequeueBuffer(android_native_window_t* window, if (self->mBufferHead >= self->mNumBuffers) self->mBufferHead = 0; - self->mLastDequeued = index; *buffer = self->buffers[index].get(); return 0; |