return bclient;
}
+int32_t SurfaceFlinger::chooseNewDisplayIdLocked() const
+{
+ int32_t id = DisplayDevice::DISPLAY_ID_COUNT - 1;
+ bool available;
+ do {
+ id++;
+ available = true;
+ for (size_t i = 0; i < mCurrentState.displays.size(); i++) {
+ const DisplayDeviceState& dds(mCurrentState.displays.valueAt(i));
+ if (dds.id == id) {
+ available = false;
+ break;
+ }
+ }
+ } while (!available);
+ return id;
+}
+
sp<IBinder> SurfaceFlinger::createDisplay()
{
class DisplayToken : public BBinder {
sp<BBinder> token = new DisplayToken(this);
Mutex::Autolock _l(mStateLock);
- DisplayDeviceState info(intptr_t(token.get())); // FIXME: we shouldn't use the address for the id
+ int32_t id = chooseNewDisplayIdLocked();
+ DisplayDeviceState info(id);
mCurrentState.displays.add(token, info);
return token;
}
/* ------------------------------------------------------------------------
+ * Display management
+ */
+ int32_t chooseNewDisplayIdLocked() const;
+
+ /* ------------------------------------------------------------------------
* Debugging & dumpsys
*/
void listLayersLocked(const Vector<String16>& args, size_t& index,