diff options
author | Jesse Hall <jessehall@google.com> | 2013-08-18 04:31:24 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-08-18 04:31:24 +0000 |
commit | 7c6278de6e2aed171362012d578d8bd093c8f280 (patch) | |
tree | aaa91573911f93b9c52783d90d349919c2de2431 /services | |
parent | 0f05a926647389551aba6b8cfac37aaf73e8bad8 (diff) | |
parent | 9e663de4fe1dcc872373ee530c60a375624671c3 (diff) | |
download | frameworks_native-7c6278de6e2aed171362012d578d8bd093c8f280.zip frameworks_native-7c6278de6e2aed171362012d578d8bd093c8f280.tar.gz frameworks_native-7c6278de6e2aed171362012d578d8bd093c8f280.tar.bz2 |
Merge "Use new HWC display type/count constants." into klp-dev
Diffstat (limited to 'services')
-rw-r--r-- | services/surfaceflinger/DisplayDevice.h | 5 | ||||
-rw-r--r-- | services/surfaceflinger/DisplayHardware/HWComposer.cpp | 19 | ||||
-rw-r--r-- | services/surfaceflinger/DisplayHardware/HWComposer.h | 23 | ||||
-rw-r--r-- | services/surfaceflinger/EventThread.cpp | 22 | ||||
-rw-r--r-- | services/surfaceflinger/EventThread.h | 5 | ||||
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 22 | ||||
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.h | 2 |
7 files changed, 48 insertions, 50 deletions
diff --git a/services/surfaceflinger/DisplayDevice.h b/services/surfaceflinger/DisplayDevice.h index 6f0ce88..8e24df7 100644 --- a/services/surfaceflinger/DisplayDevice.h +++ b/services/surfaceflinger/DisplayDevice.h @@ -38,6 +38,7 @@ namespace android { class DisplayInfo; class DisplaySurface; +class IGraphicBufferProducer; class Layer; class SurfaceFlinger; class HWComposer; @@ -56,8 +57,8 @@ public: DISPLAY_ID_INVALID = -1, DISPLAY_PRIMARY = HWC_DISPLAY_PRIMARY, DISPLAY_EXTERNAL = HWC_DISPLAY_EXTERNAL, - NUM_DISPLAY_TYPES = HWC_NUM_DISPLAY_TYPES, - DISPLAY_VIRTUAL = HWC_NUM_DISPLAY_TYPES + DISPLAY_VIRTUAL = HWC_DISPLAY_VIRTUAL, + NUM_BUILTIN_DISPLAY_TYPES = HWC_NUM_PHYSICAL_DISPLAY_TYPES, }; enum { diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.cpp b/services/surfaceflinger/DisplayHardware/HWComposer.cpp index f6256f9..ef07f18 100644 --- a/services/surfaceflinger/DisplayHardware/HWComposer.cpp +++ b/services/surfaceflinger/DisplayHardware/HWComposer.cpp @@ -48,15 +48,8 @@ namespace android { -#ifndef HWC_DEVICE_API_VERSION_1_3 -#define HWC_DEVICE_API_VERSION_1_3 HARDWARE_DEVICE_API_VERSION_2(1, 3, HWC_HEADER_VERSION) -#endif - #define MIN_HWC_HEADER_VERSION HWC_HEADER_VERSION -#define NUM_PHYSICAL_DISPLAYS HWC_NUM_DISPLAY_TYPES -#define VIRTUAL_DISPLAY_ID_BASE HWC_NUM_DISPLAY_TYPES - static uint32_t hwcApiVersion(const hwc_composer_device_1_t* hwc) { uint32_t hwcVersion = hwc->common.version; return hwcVersion & HARDWARE_API_VERSION_2_MAJ_MIN_MASK; @@ -96,7 +89,7 @@ HWComposer::HWComposer( mEventHandler(handler), mVSyncCount(0), mDebugForceFakeVSync(false) { - for (size_t i =0 ; i<MAX_DISPLAYS ; i++) { + for (size_t i =0 ; i<MAX_HWC_DISPLAYS ; i++) { mLists[i] = 0; } @@ -127,7 +120,7 @@ HWComposer::HWComposer( } // these display IDs are always reserved - for (size_t i=0 ; i<NUM_PHYSICAL_DISPLAYS ; i++) { + for (size_t i=0 ; i<NUM_BUILTIN_DISPLAYS ; i++) { mAllocatedDisplayIDs.markBit(i); } @@ -156,10 +149,10 @@ HWComposer::HWComposer( // hw composer version if (hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_3)) { // 1.3 adds support for virtual displays - mNumDisplays = MAX_DISPLAYS; + mNumDisplays = MAX_HWC_DISPLAYS; } else if (hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_1)) { // 1.1 adds support for multiple displays - mNumDisplays = NUM_PHYSICAL_DISPLAYS; + mNumDisplays = NUM_BUILTIN_DISPLAYS; } else { mNumDisplays = 1; } @@ -187,7 +180,7 @@ HWComposer::HWComposer( } } else if (mHwc) { // here we're guaranteed to have at least HWC 1.1 - for (size_t i =0 ; i<NUM_PHYSICAL_DISPLAYS ; i++) { + for (size_t i =0 ; i<NUM_BUILTIN_DISPLAYS ; i++) { queryDisplayProperties(i); } } @@ -400,7 +393,7 @@ int32_t HWComposer::allocateDisplayId() { } status_t HWComposer::freeDisplayId(int32_t id) { - if (id < NUM_PHYSICAL_DISPLAYS) { + if (id < NUM_BUILTIN_DISPLAYS) { // cannot free the reserved IDs return BAD_VALUE; } diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.h b/services/surfaceflinger/DisplayHardware/HWComposer.h index 0462bcc..d901c62 100644 --- a/services/surfaceflinger/DisplayHardware/HWComposer.h +++ b/services/surfaceflinger/DisplayHardware/HWComposer.h @@ -64,7 +64,9 @@ public: }; enum { - MAX_DISPLAYS = HWC_NUM_DISPLAY_TYPES + 1 + NUM_BUILTIN_DISPLAYS = HWC_NUM_PHYSICAL_DISPLAY_TYPES, + MAX_HWC_DISPLAYS = HWC_NUM_DISPLAY_TYPES, + VIRTUAL_DISPLAY_ID_BASE = HWC_DISPLAY_VIRTUAL, }; HWComposer( @@ -75,15 +77,16 @@ public: status_t initCheck() const; - // returns a display ID starting at MAX_DISPLAYS, this ID - // is to be used with createWorkList (and all other - // methods requiring an ID below). - // IDs below MAX_DISPLAY are pre-defined and therefore are always valid. - // returns a negative error code if an ID cannot be allocated + // Returns a display ID starting at VIRTUAL_DISPLAY_ID_BASE, this ID is to + // be used with createWorkList (and all other methods requiring an ID + // below). + // IDs below NUM_BUILTIN_DISPLAYS are pre-defined and therefore are + // always valid. + // Returns -1 if an ID cannot be allocated int32_t allocateDisplayId(); - // recycles the given ID and frees the associated worklist. - // IDs below MAX_DISPLAYS are not recycled + // Recycles the given virtual display ID and frees the associated worklist. + // IDs below NUM_BUILTIN_DISPLAYS are not recycled. status_t freeDisplayId(int32_t id); @@ -333,8 +336,8 @@ private: struct hwc_composer_device_1* mHwc; // invariant: mLists[0] != NULL iff mHwc != NULL // mLists[i>0] can be NULL. that display is to be ignored - struct hwc_display_contents_1* mLists[MAX_DISPLAYS]; - DisplayData mDisplayData[MAX_DISPLAYS]; + struct hwc_display_contents_1* mLists[MAX_HWC_DISPLAYS]; + DisplayData mDisplayData[MAX_HWC_DISPLAYS]; size_t mNumDisplays; cb_context* mCBContext; diff --git a/services/surfaceflinger/EventThread.cpp b/services/surfaceflinger/EventThread.cpp index 4126c8a..a61ad72 100644 --- a/services/surfaceflinger/EventThread.cpp +++ b/services/surfaceflinger/EventThread.cpp @@ -41,7 +41,7 @@ EventThread::EventThread(const sp<SurfaceFlinger>& flinger) mUseSoftwareVSync(false), mDebugVsyncEnabled(false) { - for (int32_t i=0 ; i<HWC_NUM_DISPLAY_TYPES ; i++) { + for (int32_t i=0 ; i<DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES ; i++) { mVSyncEvent[i].header.type = DisplayEventReceiver::DISPLAY_EVENT_VSYNC; mVSyncEvent[i].header.id = 0; mVSyncEvent[i].header.timestamp = 0; @@ -112,11 +112,11 @@ void EventThread::onScreenAcquired() { void EventThread::onVSyncReceived(int type, nsecs_t timestamp) { - ALOGE_IF(type >= HWC_NUM_DISPLAY_TYPES, + ALOGE_IF(type >= DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES, "received vsync event for an invalid display (id=%d)", type); Mutex::Autolock _l(mLock); - if (type < HWC_NUM_DISPLAY_TYPES) { + if (type < DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES) { mVSyncEvent[type].header.type = DisplayEventReceiver::DISPLAY_EVENT_VSYNC; mVSyncEvent[type].header.id = type; mVSyncEvent[type].header.timestamp = timestamp; @@ -126,11 +126,11 @@ void EventThread::onVSyncReceived(int type, nsecs_t timestamp) { } void EventThread::onHotplugReceived(int type, bool connected) { - ALOGE_IF(type >= HWC_NUM_DISPLAY_TYPES, + ALOGE_IF(type >= DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES, "received hotplug event for an invalid display (id=%d)", type); Mutex::Autolock _l(mLock); - if (type < HWC_NUM_DISPLAY_TYPES) { + if (type < DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES) { DisplayEventReceiver::Event event; event.header.type = DisplayEventReceiver::DISPLAY_EVENT_HOTPLUG; event.header.id = type; @@ -184,7 +184,7 @@ Vector< sp<EventThread::Connection> > EventThread::waitForEvent( size_t vsyncCount = 0; nsecs_t timestamp = 0; - for (int32_t i=0 ; i<HWC_NUM_DISPLAY_TYPES ; i++) { + for (int32_t i=0 ; i<DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES ; i++) { timestamp = mVSyncEvent[i].header.timestamp; if (timestamp) { // we have a vsync event to dispatch @@ -285,7 +285,7 @@ Vector< sp<EventThread::Connection> > EventThread::waitForEvent( // FIXME: how do we decide which display id the fake // vsync came from ? mVSyncEvent[0].header.type = DisplayEventReceiver::DISPLAY_EVENT_VSYNC; - mVSyncEvent[0].header.id = HWC_DISPLAY_PRIMARY; + mVSyncEvent[0].header.id = DisplayDevice::DISPLAY_PRIMARY; mVSyncEvent[0].header.timestamp = systemTime(SYSTEM_TIME_MONOTONIC); mVSyncEvent[0].vsync.count++; } @@ -308,14 +308,16 @@ Vector< sp<EventThread::Connection> > EventThread::waitForEvent( void EventThread::enableVSyncLocked() { if (!mUseSoftwareVSync) { // never enable h/w VSYNC when screen is off - mFlinger->eventControl(HWC_DISPLAY_PRIMARY, SurfaceFlinger::EVENT_VSYNC, true); + mFlinger->eventControl(DisplayDevice::DISPLAY_PRIMARY, + SurfaceFlinger::EVENT_VSYNC, true); mPowerHAL.vsyncHint(true); } mDebugVsyncEnabled = true; } void EventThread::disableVSyncLocked() { - mFlinger->eventControl(HWC_DISPLAY_PRIMARY, SurfaceFlinger::EVENT_VSYNC, false); + mFlinger->eventControl(DisplayDevice::DISPLAY_PRIMARY, + SurfaceFlinger::EVENT_VSYNC, false); mPowerHAL.vsyncHint(false); mDebugVsyncEnabled = false; } @@ -328,7 +330,7 @@ void EventThread::dump(String8& result) const { mUseSoftwareVSync?"enabled":"disabled"); result.appendFormat(" numListeners=%u,\n events-delivered: %u\n", mDisplayEventConnections.size(), - mVSyncEvent[HWC_DISPLAY_PRIMARY].vsync.count); + mVSyncEvent[DisplayDevice::DISPLAY_PRIMARY].vsync.count); for (size_t i=0 ; i<mDisplayEventConnections.size() ; i++) { sp<Connection> connection = mDisplayEventConnections.itemAt(i).promote(); diff --git a/services/surfaceflinger/EventThread.h b/services/surfaceflinger/EventThread.h index 35ac0c8..5e88693 100644 --- a/services/surfaceflinger/EventThread.h +++ b/services/surfaceflinger/EventThread.h @@ -23,12 +23,11 @@ #include <gui/DisplayEventReceiver.h> #include <gui/IDisplayEventConnection.h> -#include <hardware/hwcomposer_defs.h> - #include <utils/Errors.h> #include <utils/threads.h> #include <utils/SortedVector.h> +#include "DisplayDevice.h" #include "DisplayHardware/PowerHAL.h" // --------------------------------------------------------------------------- @@ -104,7 +103,7 @@ private: // protected by mLock SortedVector< wp<Connection> > mDisplayEventConnections; Vector< DisplayEventReceiver::Event > mPendingEvents; - DisplayEventReceiver::Event mVSyncEvent[HWC_NUM_DISPLAY_TYPES]; + DisplayEventReceiver::Event mVSyncEvent[DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES]; bool mUseSoftwareVSync; // for debugging diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 68b9950..dcdd1d0 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -234,7 +234,7 @@ void SurfaceFlinger::createBuiltinDisplayLocked(DisplayDevice::DisplayType type) } sp<IBinder> SurfaceFlinger::getBuiltInDisplay(int32_t id) { - if (uint32_t(id) >= DisplayDevice::NUM_DISPLAY_TYPES) { + if (uint32_t(id) >= DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES) { ALOGE("getDefaultDisplay: id=%d is not a valid default display id", id); return NULL; } @@ -461,7 +461,7 @@ status_t SurfaceFlinger::readyToRun() "couldn't create EGLContext"); // initialize our non-virtual displays - for (size_t i=0 ; i<DisplayDevice::NUM_DISPLAY_TYPES ; i++) { + for (size_t i=0 ; i<DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES ; i++) { DisplayDevice::DisplayType type((DisplayDevice::DisplayType)i); // set-up the displays that are already connected if (mHwc->isConnected(i) || type==DisplayDevice::DISPLAY_PRIMARY) { @@ -511,7 +511,7 @@ status_t SurfaceFlinger::readyToRun() } int32_t SurfaceFlinger::allocateHwcDisplayId(DisplayDevice::DisplayType type) { - return (uint32_t(type) < DisplayDevice::NUM_DISPLAY_TYPES) ? + return (uint32_t(type) < DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES) ? type : mHwc->allocateDisplayId(); } @@ -540,7 +540,7 @@ bool SurfaceFlinger::authenticateSurfaceTexture( status_t SurfaceFlinger::getDisplayInfo(const sp<IBinder>& display, DisplayInfo* info) { int32_t type = NAME_NOT_FOUND; - for (int i=0 ; i<DisplayDevice::NUM_DISPLAY_TYPES ; i++) { + for (int i=0 ; i<DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES ; i++) { if (display == mBuiltinDisplays[i]) { type = i; break; @@ -661,7 +661,7 @@ void SurfaceFlinger::onVSyncReceived(int type, nsecs_t timestamp) { ALOGW("WARNING: EventThread not started, ignoring vsync"); return; } - if (uint32_t(type) < DisplayDevice::NUM_DISPLAY_TYPES) { + if (uint32_t(type) < DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES) { // we should only receive DisplayDevice::DisplayType from the vsync callback mEventThread->onVSyncReceived(type, timestamp); } @@ -676,7 +676,7 @@ void SurfaceFlinger::onHotplugReceived(int type, bool connected) { return; } - if (uint32_t(type) < DisplayDevice::NUM_DISPLAY_TYPES) { + if (uint32_t(type) < DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES) { Mutex::Autolock _l(mStateLock); if (connected) { createBuiltinDisplayLocked((DisplayDevice::DisplayType)type); @@ -1064,7 +1064,7 @@ void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags) sp<DisplayDevice> hw(getDisplayDevice(draw.keyAt(i))); if (hw != NULL) hw->disconnect(getHwComposer()); - if (draw[i].type < DisplayDevice::NUM_DISPLAY_TYPES) + if (draw[i].type < DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES) mEventThread->onHotplugReceived(draw[i].type, false); mDisplays.removeItem(draw.keyAt(i)); } else { @@ -2006,7 +2006,7 @@ void SurfaceFlinger::onScreenAcquired(const sp<const DisplayDevice>& hw) { hw->acquireScreen(); int32_t type = hw->getDisplayType(); - if (type < DisplayDevice::NUM_DISPLAY_TYPES) { + if (type < DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES) { // built-in display, tell the HWC getHwComposer().acquire(type); @@ -2028,7 +2028,7 @@ void SurfaceFlinger::onScreenReleased(const sp<const DisplayDevice>& hw) { hw->releaseScreen(); int32_t type = hw->getDisplayType(); - if (type < DisplayDevice::NUM_DISPLAY_TYPES) { + if (type < DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES) { if (type == DisplayDevice::DISPLAY_PRIMARY) { // FIXME: eventthread only knows about the main display right now mEventThread->onScreenReleased(); @@ -2052,7 +2052,7 @@ void SurfaceFlinger::unblank(const sp<IBinder>& display) { const sp<DisplayDevice> hw(mFlinger.getDisplayDevice(mDisplay)); if (hw == NULL) { ALOGE("Attempt to unblank null display %p", mDisplay.get()); - } else if (hw->getDisplayType() >= DisplayDevice::NUM_DISPLAY_TYPES) { + } else if (hw->getDisplayType() >= DisplayDevice::DISPLAY_VIRTUAL) { ALOGW("Attempt to unblank virtual display"); } else { mFlinger.onScreenAcquired(hw); @@ -2075,7 +2075,7 @@ void SurfaceFlinger::blank(const sp<IBinder>& display) { const sp<DisplayDevice> hw(mFlinger.getDisplayDevice(mDisplay)); if (hw == NULL) { ALOGE("Attempt to blank null display %p", mDisplay.get()); - } else if (hw->getDisplayType() >= DisplayDevice::NUM_DISPLAY_TYPES) { + } else if (hw->getDisplayType() >= DisplayDevice::DISPLAY_VIRTUAL) { ALOGW("Attempt to blank virtual display"); } else { mFlinger.onScreenReleased(hw); diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h index ce096d3..0906f80 100644 --- a/services/surfaceflinger/SurfaceFlinger.h +++ b/services/surfaceflinger/SurfaceFlinger.h @@ -421,7 +421,7 @@ private: EGLConfig mEGLConfig; EGLDisplay mEGLDisplay; EGLint mEGLNativeVisualId; - sp<IBinder> mBuiltinDisplays[DisplayDevice::NUM_DISPLAY_TYPES]; + sp<IBinder> mBuiltinDisplays[DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES]; // Can only accessed from the main thread, these members // don't need synchronization |