Loading services/surfaceflinger/DisplayHardware/HWComposer_hwc1.cpp +29 −14 Original line number Original line Diff line number Diff line Loading @@ -926,16 +926,19 @@ class Iterable : public HWComposer::HWCLayer { protected: protected: HWCTYPE* const mLayerList; HWCTYPE* const mLayerList; HWCTYPE* mCurrentLayer; HWCTYPE* mCurrentLayer; Iterable(HWCTYPE* layer) : mLayerList(layer), mCurrentLayer(layer) { } Iterable(HWCTYPE* layer) : mLayerList(layer), mCurrentLayer(layer), mIndex(0) { } inline HWCTYPE const * getLayer() const { return mCurrentLayer; } inline HWCTYPE const * getLayer() const { return mCurrentLayer; } inline HWCTYPE* getLayer() { return mCurrentLayer; } inline HWCTYPE* getLayer() { return mCurrentLayer; } virtual ~Iterable() { } virtual ~Iterable() { } size_t mIndex; private: private: // returns a copy of ourselves // returns a copy of ourselves virtual HWComposer::HWCLayer* dup() { virtual HWComposer::HWCLayer* dup() { return new CONCRETE( static_cast<const CONCRETE&>(*this) ); return new CONCRETE( static_cast<const CONCRETE&>(*this) ); } } virtual status_t setLayer(size_t index) { virtual status_t setLayer(size_t index) { mIndex = index; mCurrentLayer = &mLayerList[index]; mCurrentLayer = &mLayerList[index]; return NO_ERROR; return NO_ERROR; } } Loading @@ -948,8 +951,12 @@ private: class HWCLayerVersion1 : public Iterable<HWCLayerVersion1, hwc_layer_1_t> { class HWCLayerVersion1 : public Iterable<HWCLayerVersion1, hwc_layer_1_t> { struct hwc_composer_device_1* mHwc; struct hwc_composer_device_1* mHwc; public: public: HWCLayerVersion1(struct hwc_composer_device_1* hwc, hwc_layer_1_t* layer) HWCLayerVersion1(struct hwc_composer_device_1* hwc, hwc_layer_1_t* layer, : Iterable<HWCLayerVersion1, hwc_layer_1_t>(layer), mHwc(hwc) { } Vector<Region>* visibleRegions, Vector<Region>* surfaceDamageRegions) : Iterable<HWCLayerVersion1, hwc_layer_1_t>(layer), mHwc(hwc), mVisibleRegions(visibleRegions), mSurfaceDamageRegions(surfaceDamageRegions) {} virtual int32_t getCompositionType() const { virtual int32_t getCompositionType() const { return getLayer()->compositionType; return getLayer()->compositionType; Loading Loading @@ -1037,9 +1044,10 @@ public: } } virtual void setVisibleRegionScreen(const Region& reg) { virtual void setVisibleRegionScreen(const Region& reg) { hwc_region_t& visibleRegion = getLayer()->visibleRegionScreen; hwc_region_t& visibleRegion = getLayer()->visibleRegionScreen; mVisibleRegion = reg; mVisibleRegions->editItemAt(mIndex) = reg; visibleRegion.rects = reinterpret_cast<hwc_rect_t const *>( visibleRegion.rects = reinterpret_cast<hwc_rect_t const *>( mVisibleRegion.getArray(&visibleRegion.numRects)); mVisibleRegions->itemAt(mIndex).getArray( &visibleRegion.numRects)); } } virtual void setSurfaceDamage(const Region& reg) { virtual void setSurfaceDamage(const Region& reg) { if (!hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_5)) { if (!hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_5)) { Loading @@ -1053,9 +1061,10 @@ public: surfaceDamage.rects = NULL; surfaceDamage.rects = NULL; return; return; } } mSurfaceDamage = reg; mSurfaceDamageRegions->editItemAt(mIndex) = reg; surfaceDamage.rects = reinterpret_cast<hwc_rect_t const *>( surfaceDamage.rects = reinterpret_cast<hwc_rect_t const *>( mSurfaceDamage.getArray(&surfaceDamage.numRects)); mSurfaceDamageRegions->itemAt(mIndex).getArray( &surfaceDamage.numRects)); } } virtual void setSidebandStream(const sp<NativeHandle>& stream) { virtual void setSidebandStream(const sp<NativeHandle>& stream) { ALOG_ASSERT(stream->handle() != NULL); ALOG_ASSERT(stream->handle() != NULL); Loading @@ -1081,11 +1090,10 @@ public: } } protected: protected: // We need to hold "copies" of these for memory management purposes. The // Pointers to the vectors of Region backing-memory held in DisplayData. // actual hwc_layer_1_t holds pointers to the memory within. Vector<> // Only the Region at mIndex corresponds to this Layer. // internally doesn't copy the memory unless one of the copies is modified. Vector<Region>* mVisibleRegions; Region mVisibleRegion; Vector<Region>* mSurfaceDamageRegions; Region mSurfaceDamage; }; }; /* /* Loading @@ -1095,11 +1103,18 @@ HWComposer::LayerListIterator HWComposer::getLayerIterator(int32_t id, size_t in if (uint32_t(id)>31 || !mAllocatedDisplayIDs.hasBit(id)) { if (uint32_t(id)>31 || !mAllocatedDisplayIDs.hasBit(id)) { return LayerListIterator(); return LayerListIterator(); } } const DisplayData& disp(mDisplayData[id]); DisplayData& disp(mDisplayData[id]); if (!mHwc || !disp.list || index > disp.list->numHwLayers) { if (!mHwc || !disp.list || index > disp.list->numHwLayers) { return LayerListIterator(); return LayerListIterator(); } } return LayerListIterator(new HWCLayerVersion1(mHwc, disp.list->hwLayers), index); if (disp.visibleRegions.size() < disp.list->numHwLayers) { disp.visibleRegions.resize(disp.list->numHwLayers); } if (disp.surfaceDamageRegions.size() < disp.list->numHwLayers) { disp.surfaceDamageRegions.resize(disp.list->numHwLayers); } return LayerListIterator(new HWCLayerVersion1(mHwc, disp.list->hwLayers, &disp.visibleRegions, &disp.surfaceDamageRegions), index); } } /* /* Loading services/surfaceflinger/DisplayHardware/HWComposer_hwc1.h +7 −0 Original line number Original line Diff line number Diff line Loading @@ -346,6 +346,13 @@ private: // protected by mEventControlLock // protected by mEventControlLock int32_t events; int32_t events; // We need to hold "copies" of these for memory management purposes. The // actual hwc_layer_1_t holds pointers to the memory within. Vector<> // internally doesn't copy the memory unless one of the copies is // modified. Vector<Region> visibleRegions; Vector<Region> surfaceDamageRegions; }; }; sp<SurfaceFlinger> mFlinger; sp<SurfaceFlinger> mFlinger; Loading Loading
services/surfaceflinger/DisplayHardware/HWComposer_hwc1.cpp +29 −14 Original line number Original line Diff line number Diff line Loading @@ -926,16 +926,19 @@ class Iterable : public HWComposer::HWCLayer { protected: protected: HWCTYPE* const mLayerList; HWCTYPE* const mLayerList; HWCTYPE* mCurrentLayer; HWCTYPE* mCurrentLayer; Iterable(HWCTYPE* layer) : mLayerList(layer), mCurrentLayer(layer) { } Iterable(HWCTYPE* layer) : mLayerList(layer), mCurrentLayer(layer), mIndex(0) { } inline HWCTYPE const * getLayer() const { return mCurrentLayer; } inline HWCTYPE const * getLayer() const { return mCurrentLayer; } inline HWCTYPE* getLayer() { return mCurrentLayer; } inline HWCTYPE* getLayer() { return mCurrentLayer; } virtual ~Iterable() { } virtual ~Iterable() { } size_t mIndex; private: private: // returns a copy of ourselves // returns a copy of ourselves virtual HWComposer::HWCLayer* dup() { virtual HWComposer::HWCLayer* dup() { return new CONCRETE( static_cast<const CONCRETE&>(*this) ); return new CONCRETE( static_cast<const CONCRETE&>(*this) ); } } virtual status_t setLayer(size_t index) { virtual status_t setLayer(size_t index) { mIndex = index; mCurrentLayer = &mLayerList[index]; mCurrentLayer = &mLayerList[index]; return NO_ERROR; return NO_ERROR; } } Loading @@ -948,8 +951,12 @@ private: class HWCLayerVersion1 : public Iterable<HWCLayerVersion1, hwc_layer_1_t> { class HWCLayerVersion1 : public Iterable<HWCLayerVersion1, hwc_layer_1_t> { struct hwc_composer_device_1* mHwc; struct hwc_composer_device_1* mHwc; public: public: HWCLayerVersion1(struct hwc_composer_device_1* hwc, hwc_layer_1_t* layer) HWCLayerVersion1(struct hwc_composer_device_1* hwc, hwc_layer_1_t* layer, : Iterable<HWCLayerVersion1, hwc_layer_1_t>(layer), mHwc(hwc) { } Vector<Region>* visibleRegions, Vector<Region>* surfaceDamageRegions) : Iterable<HWCLayerVersion1, hwc_layer_1_t>(layer), mHwc(hwc), mVisibleRegions(visibleRegions), mSurfaceDamageRegions(surfaceDamageRegions) {} virtual int32_t getCompositionType() const { virtual int32_t getCompositionType() const { return getLayer()->compositionType; return getLayer()->compositionType; Loading Loading @@ -1037,9 +1044,10 @@ public: } } virtual void setVisibleRegionScreen(const Region& reg) { virtual void setVisibleRegionScreen(const Region& reg) { hwc_region_t& visibleRegion = getLayer()->visibleRegionScreen; hwc_region_t& visibleRegion = getLayer()->visibleRegionScreen; mVisibleRegion = reg; mVisibleRegions->editItemAt(mIndex) = reg; visibleRegion.rects = reinterpret_cast<hwc_rect_t const *>( visibleRegion.rects = reinterpret_cast<hwc_rect_t const *>( mVisibleRegion.getArray(&visibleRegion.numRects)); mVisibleRegions->itemAt(mIndex).getArray( &visibleRegion.numRects)); } } virtual void setSurfaceDamage(const Region& reg) { virtual void setSurfaceDamage(const Region& reg) { if (!hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_5)) { if (!hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_5)) { Loading @@ -1053,9 +1061,10 @@ public: surfaceDamage.rects = NULL; surfaceDamage.rects = NULL; return; return; } } mSurfaceDamage = reg; mSurfaceDamageRegions->editItemAt(mIndex) = reg; surfaceDamage.rects = reinterpret_cast<hwc_rect_t const *>( surfaceDamage.rects = reinterpret_cast<hwc_rect_t const *>( mSurfaceDamage.getArray(&surfaceDamage.numRects)); mSurfaceDamageRegions->itemAt(mIndex).getArray( &surfaceDamage.numRects)); } } virtual void setSidebandStream(const sp<NativeHandle>& stream) { virtual void setSidebandStream(const sp<NativeHandle>& stream) { ALOG_ASSERT(stream->handle() != NULL); ALOG_ASSERT(stream->handle() != NULL); Loading @@ -1081,11 +1090,10 @@ public: } } protected: protected: // We need to hold "copies" of these for memory management purposes. The // Pointers to the vectors of Region backing-memory held in DisplayData. // actual hwc_layer_1_t holds pointers to the memory within. Vector<> // Only the Region at mIndex corresponds to this Layer. // internally doesn't copy the memory unless one of the copies is modified. Vector<Region>* mVisibleRegions; Region mVisibleRegion; Vector<Region>* mSurfaceDamageRegions; Region mSurfaceDamage; }; }; /* /* Loading @@ -1095,11 +1103,18 @@ HWComposer::LayerListIterator HWComposer::getLayerIterator(int32_t id, size_t in if (uint32_t(id)>31 || !mAllocatedDisplayIDs.hasBit(id)) { if (uint32_t(id)>31 || !mAllocatedDisplayIDs.hasBit(id)) { return LayerListIterator(); return LayerListIterator(); } } const DisplayData& disp(mDisplayData[id]); DisplayData& disp(mDisplayData[id]); if (!mHwc || !disp.list || index > disp.list->numHwLayers) { if (!mHwc || !disp.list || index > disp.list->numHwLayers) { return LayerListIterator(); return LayerListIterator(); } } return LayerListIterator(new HWCLayerVersion1(mHwc, disp.list->hwLayers), index); if (disp.visibleRegions.size() < disp.list->numHwLayers) { disp.visibleRegions.resize(disp.list->numHwLayers); } if (disp.surfaceDamageRegions.size() < disp.list->numHwLayers) { disp.surfaceDamageRegions.resize(disp.list->numHwLayers); } return LayerListIterator(new HWCLayerVersion1(mHwc, disp.list->hwLayers, &disp.visibleRegions, &disp.surfaceDamageRegions), index); } } /* /* Loading
services/surfaceflinger/DisplayHardware/HWComposer_hwc1.h +7 −0 Original line number Original line Diff line number Diff line Loading @@ -346,6 +346,13 @@ private: // protected by mEventControlLock // protected by mEventControlLock int32_t events; int32_t events; // We need to hold "copies" of these for memory management purposes. The // actual hwc_layer_1_t holds pointers to the memory within. Vector<> // internally doesn't copy the memory unless one of the copies is // modified. Vector<Region> visibleRegions; Vector<Region> surfaceDamageRegions; }; }; sp<SurfaceFlinger> mFlinger; sp<SurfaceFlinger> mFlinger; Loading