* layer ids. The argument to the method is the
* initial size of the pool
*/
- virtual int InitializeLayerHashGenerator(int) {
+ virtual int InitializeLayerHashGenerator(int size) {
+ LayerIds_.clear();
+ for (int i = 0; i < size; i++) {
+ LayerIds_.push_back(i);
+ }
+
+ current_max_layer_ids_ = size;
return 0;
}
* unused id for the layer.
*/
virtual uint64_t AcquireId() {
- return 0;
+ if (LayerIds_.empty())
+ return ++current_max_layer_ids_;
+
+ uint64_t id = LayerIds_.back();
+ LayerIds_.pop_back();
+
+ return id;
}
/**
* Method to return a destroyed layer's id back into the pool
*/
- virtual void ReleaseId(uint64_t) {
+ virtual void ReleaseId(uint64_t id) {
+ LayerIds_.push_back(id);
}
/**
* Call this to reset the id pool back to its initial state.
*/
virtual void ResetLayerHashGenerator() {
+ InitializeLayerHashGenerator(current_max_layer_ids_);
}
/**
// to individual layers shown by this display.
virtual void RotateDisplay(HWCRotation /*rotation*/) {
}
+
+private:
+ std::vector<uint64_t> LayerIds_;
+ uint64_t current_max_layer_ids_;
+
};
/**
strncpy(name, string.c_str(), *size);
return true;
}
-
-int PhysicalDisplay::InitializeLayerHashGenerator(int size) {
- LayerIds_.clear();
- for (int i = 0; i < size; i++) {
- LayerIds_.push_back(i);
- }
-
- current_max_layer_ids_ = size;
- return 0;
-}
-
-uint64_t PhysicalDisplay::AcquireId() {
- if (LayerIds_.empty())
- return ++current_max_layer_ids_;
-
- uint64_t id = LayerIds_.back();
- LayerIds_.pop_back();
-
- return id;
-}
-
-void PhysicalDisplay::ReleaseId(uint64_t id) {
- LayerIds_.push_back(id);
-}
-
-void PhysicalDisplay::ResetLayerHashGenerator() {
- InitializeLayerHashGenerator(current_max_layer_ids_);
-}
} // namespace hwcomposer
virtual void HandleLazyInitialization() {
}
- int InitializeLayerHashGenerator(int) override;
-
- uint64_t AcquireId() override;
-
- void ReleaseId(uint64_t) override;
-
- void ResetLayerHashGenerator() override;
-
private:
bool UpdatePowerMode();
void RefreshClones();
void HandleClonedDisplays(std::vector<HwcLayer *> &source_layers);
- std::vector<uint64_t> LayerIds_;
- uint64_t current_max_layer_ids_;
protected:
enum DisplayConnectionStatus {