Loading services/surfaceflinger/Android.mk +1 −1 Original line number Diff line number Diff line Loading @@ -3,12 +3,12 @@ include $(CLEAR_VARS) LOCAL_SRC_FILES:= \ Client.cpp \ DisplayHardware.cpp \ EventThread.cpp \ Layer.cpp \ LayerBase.cpp \ LayerDim.cpp \ LayerScreenshot.cpp \ DisplayHardware/DisplayHardware.cpp \ DisplayHardware/DisplayHardwareBase.cpp \ DisplayHardware/FramebufferSurface.cpp \ DisplayHardware/HWComposer.cpp \ Loading services/surfaceflinger/DisplayHardware/DisplayHardware.cpp→services/surfaceflinger/DisplayHardware.cpp +88 −9 Original line number Diff line number Diff line Loading @@ -30,14 +30,14 @@ #include <EGL/egl.h> #include <EGL/eglext.h> #include "DisplayHardware/DisplayHardware.h" #include "DisplayHardware/FramebufferSurface.h" #include <hardware/gralloc.h> #include "DisplayHardwareBase.h" #include "DisplayHardware/FramebufferSurface.h" #include "DisplayHardware/DisplayHardwareBase.h" #include "DisplayHardware/HWComposer.h" #include "DisplayHardware.h" #include "GLExtensions.h" #include "HWComposer.h" #include "SurfaceFlinger.h" using namespace android; Loading Loading @@ -111,8 +111,8 @@ float DisplayHardware::getDpiX() const { return mDpiX; } float DisplayHardware::getDpiY() const { return mDpiY; } float DisplayHardware::getDensity() const { return mDensity; } float DisplayHardware::getRefreshRate() const { return mRefreshRate; } int DisplayHardware::getWidth() const { return mWidth; } int DisplayHardware::getHeight() const { return mHeight; } int DisplayHardware::getWidth() const { return mDisplayWidth; } int DisplayHardware::getHeight() const { return mDisplayHeight; } PixelFormat DisplayHardware::getFormat() const { return mFormat; } uint32_t DisplayHardware::getMaxTextureSize() const { return mMaxTextureSize; } Loading Loading @@ -267,8 +267,8 @@ void DisplayHardware::init(uint32_t dpy) */ surface = eglCreateWindowSurface(display, config, mNativeWindow.get(), NULL); eglQuerySurface(display, surface, EGL_WIDTH, &mWidth); eglQuerySurface(display, surface, EGL_HEIGHT, &mHeight); eglQuerySurface(display, surface, EGL_WIDTH, &mDisplayWidth); eglQuerySurface(display, surface, EGL_HEIGHT, &mDisplayHeight); if (mFlags & PARTIAL_UPDATES) { // if we have partial updates, we definitely don't need to Loading Loading @@ -348,6 +348,36 @@ void DisplayHardware::init(uint32_t dpy) if (mHwc->initCheck() == NO_ERROR) { mHwc->setFrameBuffer(mDisplay, mSurface); } // initialize the display orientation transform. // it's a constant that should come from the display driver. int displayOrientation = ISurfaceComposer::eOrientationDefault; char property[PROPERTY_VALUE_MAX]; if (property_get("ro.sf.hwrotation", property, NULL) > 0) { //displayOrientation switch (atoi(property)) { case 90: displayOrientation = ISurfaceComposer::eOrientation90; break; case 270: displayOrientation = ISurfaceComposer::eOrientation270; break; } } w = mDisplayWidth; h = mDisplayHeight; DisplayHardware::orientationToTransfrom(displayOrientation, w, h, &mDisplayTransform); if (displayOrientation & ISurfaceComposer::eOrientationSwapMask) { mLogicalDisplayWidth = h; mLogicalDisplayHeight = w; } else { mLogicalDisplayWidth = w; mLogicalDisplayHeight = h; } DisplayHardware::setOrientation(ISurfaceComposer::eOrientationDefault); } void DisplayHardware::setVSyncHandler(const sp<VSyncHandler>& handler) { Loading Loading @@ -476,3 +506,52 @@ void DisplayHardware::dump(String8& res) const { mNativeWindow->dump(res); } // ---------------------------------------------------------------------------- status_t DisplayHardware::orientationToTransfrom( int orientation, int w, int h, Transform* tr) { uint32_t flags = 0; switch (orientation) { case ISurfaceComposer::eOrientationDefault: flags = Transform::ROT_0; break; case ISurfaceComposer::eOrientation90: flags = Transform::ROT_90; break; case ISurfaceComposer::eOrientation180: flags = Transform::ROT_180; break; case ISurfaceComposer::eOrientation270: flags = Transform::ROT_270; break; default: return BAD_VALUE; } tr->set(flags, w, h); return NO_ERROR; } status_t DisplayHardware::setOrientation(int orientation) { // If the rotation can be handled in hardware, this is where // the magic should happen. const int w = mLogicalDisplayWidth; const int h = mLogicalDisplayHeight; mUserDisplayWidth = w; mUserDisplayHeight = h; Transform orientationTransform; DisplayHardware::orientationToTransfrom(orientation, w, h, &orientationTransform); if (orientation & ISurfaceComposer::eOrientationSwapMask) { mUserDisplayWidth = h; mUserDisplayHeight = w; } mOrientation = orientation; mGlobalTransform = mDisplayTransform * orientationTransform; return NO_ERROR; } services/surfaceflinger/DisplayHardware/DisplayHardware.h→services/surfaceflinger/DisplayHardware.h +25 −7 Original line number Diff line number Diff line Loading @@ -28,10 +28,11 @@ #include <EGL/eglext.h> #include "GLExtensions.h" #include "Transform.h" #include "DisplayHardware/DisplayHardwareBase.h" #include "HWComposer.h" #include "PowerHAL.h" #include "DisplayHardware/HWComposer.h" #include "DisplayHardware/PowerHAL.h" namespace android { Loading Loading @@ -84,6 +85,11 @@ public: nsecs_t getRefreshTimestamp() const; void makeCurrent() const; status_t setOrientation(int orientation); int getOrientation() const { return mOrientation; } const Transform& getTransform() const { return mGlobalTransform; } int getUserWidth() const { return mUserDisplayWidth; } int getUserHeight() const { return mUserDisplayHeight; } void setVSyncHandler(const sp<VSyncHandler>& handler); Loading @@ -106,14 +112,14 @@ public: status_t compositionComplete() const; Rect getBounds() const { return Rect(mWidth, mHeight); return Rect(mDisplayWidth, mDisplayHeight); } inline Rect bounds() const { return getBounds(); } private: virtual void onVSyncReceived(int dpy, nsecs_t timestamp); void init(uint32_t displayIndex) __attribute__((noinline)); void fini() __attribute__((noinline)); void init(uint32_t displayIndex); void fini(); sp<SurfaceFlinger> mFlinger; EGLDisplay mDisplay; Loading @@ -124,8 +130,8 @@ private: float mDpiY; float mRefreshRate; float mDensity; int mWidth; int mHeight; int mDisplayWidth; int mDisplayHeight; PixelFormat mFormat; uint32_t mFlags; mutable uint32_t mPageFlipCount; Loading @@ -140,6 +146,18 @@ private: PowerHAL mPowerHAL; // this used to be in GraphicPlane static status_t orientationToTransfrom(int orientation, int w, int h, Transform* tr); Transform mGlobalTransform; Transform mDisplayTransform; int mOrientation; int mLogicalDisplayWidth; int mLogicalDisplayHeight; int mUserDisplayWidth; int mUserDisplayHeight; mutable Mutex mLock; // protected by mLock Loading services/surfaceflinger/EventThread.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -26,7 +26,7 @@ #include <utils/Errors.h> #include <utils/Trace.h> #include "DisplayHardware/DisplayHardware.h" #include "DisplayHardware.h" #include "EventThread.h" #include "SurfaceFlinger.h" Loading @@ -38,7 +38,7 @@ namespace android { EventThread::EventThread(const sp<SurfaceFlinger>& flinger) : mFlinger(flinger), mHw(flinger->graphicPlane(0).editDisplayHardware()), mHw(const_cast<DisplayHardware&>(flinger->getDefaultDisplayHardware())), // XXX: eventthread will need rework mLastVSyncTimestamp(0), mVSyncTimestamp(0), mUseSoftwareVSync(false), Loading services/surfaceflinger/EventThread.h +1 −1 Original line number Diff line number Diff line Loading @@ -27,7 +27,7 @@ #include <utils/threads.h> #include <utils/SortedVector.h> #include "DisplayHardware/DisplayHardware.h" #include "DisplayHardware.h" // --------------------------------------------------------------------------- Loading Loading
services/surfaceflinger/Android.mk +1 −1 Original line number Diff line number Diff line Loading @@ -3,12 +3,12 @@ include $(CLEAR_VARS) LOCAL_SRC_FILES:= \ Client.cpp \ DisplayHardware.cpp \ EventThread.cpp \ Layer.cpp \ LayerBase.cpp \ LayerDim.cpp \ LayerScreenshot.cpp \ DisplayHardware/DisplayHardware.cpp \ DisplayHardware/DisplayHardwareBase.cpp \ DisplayHardware/FramebufferSurface.cpp \ DisplayHardware/HWComposer.cpp \ Loading
services/surfaceflinger/DisplayHardware/DisplayHardware.cpp→services/surfaceflinger/DisplayHardware.cpp +88 −9 Original line number Diff line number Diff line Loading @@ -30,14 +30,14 @@ #include <EGL/egl.h> #include <EGL/eglext.h> #include "DisplayHardware/DisplayHardware.h" #include "DisplayHardware/FramebufferSurface.h" #include <hardware/gralloc.h> #include "DisplayHardwareBase.h" #include "DisplayHardware/FramebufferSurface.h" #include "DisplayHardware/DisplayHardwareBase.h" #include "DisplayHardware/HWComposer.h" #include "DisplayHardware.h" #include "GLExtensions.h" #include "HWComposer.h" #include "SurfaceFlinger.h" using namespace android; Loading Loading @@ -111,8 +111,8 @@ float DisplayHardware::getDpiX() const { return mDpiX; } float DisplayHardware::getDpiY() const { return mDpiY; } float DisplayHardware::getDensity() const { return mDensity; } float DisplayHardware::getRefreshRate() const { return mRefreshRate; } int DisplayHardware::getWidth() const { return mWidth; } int DisplayHardware::getHeight() const { return mHeight; } int DisplayHardware::getWidth() const { return mDisplayWidth; } int DisplayHardware::getHeight() const { return mDisplayHeight; } PixelFormat DisplayHardware::getFormat() const { return mFormat; } uint32_t DisplayHardware::getMaxTextureSize() const { return mMaxTextureSize; } Loading Loading @@ -267,8 +267,8 @@ void DisplayHardware::init(uint32_t dpy) */ surface = eglCreateWindowSurface(display, config, mNativeWindow.get(), NULL); eglQuerySurface(display, surface, EGL_WIDTH, &mWidth); eglQuerySurface(display, surface, EGL_HEIGHT, &mHeight); eglQuerySurface(display, surface, EGL_WIDTH, &mDisplayWidth); eglQuerySurface(display, surface, EGL_HEIGHT, &mDisplayHeight); if (mFlags & PARTIAL_UPDATES) { // if we have partial updates, we definitely don't need to Loading Loading @@ -348,6 +348,36 @@ void DisplayHardware::init(uint32_t dpy) if (mHwc->initCheck() == NO_ERROR) { mHwc->setFrameBuffer(mDisplay, mSurface); } // initialize the display orientation transform. // it's a constant that should come from the display driver. int displayOrientation = ISurfaceComposer::eOrientationDefault; char property[PROPERTY_VALUE_MAX]; if (property_get("ro.sf.hwrotation", property, NULL) > 0) { //displayOrientation switch (atoi(property)) { case 90: displayOrientation = ISurfaceComposer::eOrientation90; break; case 270: displayOrientation = ISurfaceComposer::eOrientation270; break; } } w = mDisplayWidth; h = mDisplayHeight; DisplayHardware::orientationToTransfrom(displayOrientation, w, h, &mDisplayTransform); if (displayOrientation & ISurfaceComposer::eOrientationSwapMask) { mLogicalDisplayWidth = h; mLogicalDisplayHeight = w; } else { mLogicalDisplayWidth = w; mLogicalDisplayHeight = h; } DisplayHardware::setOrientation(ISurfaceComposer::eOrientationDefault); } void DisplayHardware::setVSyncHandler(const sp<VSyncHandler>& handler) { Loading Loading @@ -476,3 +506,52 @@ void DisplayHardware::dump(String8& res) const { mNativeWindow->dump(res); } // ---------------------------------------------------------------------------- status_t DisplayHardware::orientationToTransfrom( int orientation, int w, int h, Transform* tr) { uint32_t flags = 0; switch (orientation) { case ISurfaceComposer::eOrientationDefault: flags = Transform::ROT_0; break; case ISurfaceComposer::eOrientation90: flags = Transform::ROT_90; break; case ISurfaceComposer::eOrientation180: flags = Transform::ROT_180; break; case ISurfaceComposer::eOrientation270: flags = Transform::ROT_270; break; default: return BAD_VALUE; } tr->set(flags, w, h); return NO_ERROR; } status_t DisplayHardware::setOrientation(int orientation) { // If the rotation can be handled in hardware, this is where // the magic should happen. const int w = mLogicalDisplayWidth; const int h = mLogicalDisplayHeight; mUserDisplayWidth = w; mUserDisplayHeight = h; Transform orientationTransform; DisplayHardware::orientationToTransfrom(orientation, w, h, &orientationTransform); if (orientation & ISurfaceComposer::eOrientationSwapMask) { mUserDisplayWidth = h; mUserDisplayHeight = w; } mOrientation = orientation; mGlobalTransform = mDisplayTransform * orientationTransform; return NO_ERROR; }
services/surfaceflinger/DisplayHardware/DisplayHardware.h→services/surfaceflinger/DisplayHardware.h +25 −7 Original line number Diff line number Diff line Loading @@ -28,10 +28,11 @@ #include <EGL/eglext.h> #include "GLExtensions.h" #include "Transform.h" #include "DisplayHardware/DisplayHardwareBase.h" #include "HWComposer.h" #include "PowerHAL.h" #include "DisplayHardware/HWComposer.h" #include "DisplayHardware/PowerHAL.h" namespace android { Loading Loading @@ -84,6 +85,11 @@ public: nsecs_t getRefreshTimestamp() const; void makeCurrent() const; status_t setOrientation(int orientation); int getOrientation() const { return mOrientation; } const Transform& getTransform() const { return mGlobalTransform; } int getUserWidth() const { return mUserDisplayWidth; } int getUserHeight() const { return mUserDisplayHeight; } void setVSyncHandler(const sp<VSyncHandler>& handler); Loading @@ -106,14 +112,14 @@ public: status_t compositionComplete() const; Rect getBounds() const { return Rect(mWidth, mHeight); return Rect(mDisplayWidth, mDisplayHeight); } inline Rect bounds() const { return getBounds(); } private: virtual void onVSyncReceived(int dpy, nsecs_t timestamp); void init(uint32_t displayIndex) __attribute__((noinline)); void fini() __attribute__((noinline)); void init(uint32_t displayIndex); void fini(); sp<SurfaceFlinger> mFlinger; EGLDisplay mDisplay; Loading @@ -124,8 +130,8 @@ private: float mDpiY; float mRefreshRate; float mDensity; int mWidth; int mHeight; int mDisplayWidth; int mDisplayHeight; PixelFormat mFormat; uint32_t mFlags; mutable uint32_t mPageFlipCount; Loading @@ -140,6 +146,18 @@ private: PowerHAL mPowerHAL; // this used to be in GraphicPlane static status_t orientationToTransfrom(int orientation, int w, int h, Transform* tr); Transform mGlobalTransform; Transform mDisplayTransform; int mOrientation; int mLogicalDisplayWidth; int mLogicalDisplayHeight; int mUserDisplayWidth; int mUserDisplayHeight; mutable Mutex mLock; // protected by mLock Loading
services/surfaceflinger/EventThread.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -26,7 +26,7 @@ #include <utils/Errors.h> #include <utils/Trace.h> #include "DisplayHardware/DisplayHardware.h" #include "DisplayHardware.h" #include "EventThread.h" #include "SurfaceFlinger.h" Loading @@ -38,7 +38,7 @@ namespace android { EventThread::EventThread(const sp<SurfaceFlinger>& flinger) : mFlinger(flinger), mHw(flinger->graphicPlane(0).editDisplayHardware()), mHw(const_cast<DisplayHardware&>(flinger->getDefaultDisplayHardware())), // XXX: eventthread will need rework mLastVSyncTimestamp(0), mVSyncTimestamp(0), mUseSoftwareVSync(false), Loading
services/surfaceflinger/EventThread.h +1 −1 Original line number Diff line number Diff line Loading @@ -27,7 +27,7 @@ #include <utils/threads.h> #include <utils/SortedVector.h> #include "DisplayHardware/DisplayHardware.h" #include "DisplayHardware.h" // --------------------------------------------------------------------------- Loading