manager_visible_(false),
manager_z_order_(0),
manager_blur_(0.0f),
- layer_order_(0) {}
+ layer_order_(0),
+ allocated_buffer_index_(0) {}
DisplaySurface::~DisplaySurface() {
ALOGD_IF(LOCAL_TRACE,
return;
}
+ // Save buffer index, associated with the buffer id so that it can be looked
+ // up later.
+ int buffer_id = buffer_consumer->id();
+ if (buffer_id_to_index_.find(buffer_id) == buffer_id_to_index_.end()) {
+ buffer_id_to_index_[buffer_id] = allocated_buffer_index_;
+ ++allocated_buffer_index_;
+ }
+
if (!IsVisible()) {
ATRACE_NAME("DropFrameOnInvisibleSurface");
ALOGD_IF(TRACE,
return buffer;
}
+uint32_t DisplaySurface::GetRenderBufferIndex(int buffer_id) {
+ std::lock_guard<std::mutex> autolock(lock_);
+
+ if (buffer_id_to_index_.find(buffer_id) == buffer_id_to_index_.end()) {
+ ALOGW("DisplaySurface::GetRenderBufferIndex: unknown buffer_id %d.",
+ buffer_id);
+ return 0;
+ }
+ return buffer_id_to_index_[buffer_id];
+}
+
bool DisplaySurface::IsBufferAvailable() {
std::lock_guard<std::mutex> autolock(lock_);
DequeueBuffersLocked();
}
}
- uint32_t GetRenderBufferIndex(int buffer_id) {
- return buffer_id_to_index_[buffer_id];
- }
-
+ uint32_t GetRenderBufferIndex(int buffer_id);
bool IsBufferAvailable();
bool IsBufferPosted();
AcquiredBuffer AcquireCurrentBuffer();
float manager_blur_;
int layer_order_;
+ // The monotonically increasing index for allocated buffers in this surface.
+ uint32_t allocated_buffer_index_;
// Maps from the buffer id to the corresponding allocated buffer index.
std::unordered_map<int, uint32_t> buffer_id_to_index_;
};