}
}
-bool NativeSurface::Init(NativeBufferHandler *buffer_handler,
+bool NativeSurface::Init(NativeBufferHandler *buffer_handler, uint32_t format,
bool cursor_layer) {
buffer_handler_ = buffer_handler;
uint32_t usage = hwcomposer::kLayerNormal;
usage = hwcomposer::kLayerCursor;
}
- buffer_handler_->CreateBuffer(width_, height_, 0, &native_handle_, usage);
+ buffer_handler_->CreateBuffer(width_, height_, format, &native_handle_,
+ usage);
if (!native_handle_) {
ETRACE("NativeSurface: Failed to create buffer.");
return false;
virtual ~NativeSurface();
- bool Init(NativeBufferHandler* buffer_handler, bool cursor_layer = false);
+ bool Init(NativeBufferHandler* buffer_handler, uint32_t format,
+ bool cursor_layer = false);
bool InitializeForOffScreenRendering(NativeBufferHandler* buffer_handler,
HWCNativeHandle native_handle);
void DisplayPlaneManager::SetOffScreenCursorPlaneTarget(
DisplayPlaneState &plane, uint32_t width, uint32_t height) {
NativeSurface *surface = NULL;
+ uint32_t preferred_format = plane.plane()->GetPreferredFormat();
for (auto &fb : cursor_surfaces_) {
if (!fb->InUse()) {
- surface = fb.get();
- break;
+ uint32_t surface_format = fb->GetLayer()->GetBuffer()->GetFormat();
+ if (preferred_format == surface_format) {
+ surface = fb.get();
+ break;
+ }
}
}
if (!surface) {
NativeSurface *new_surface = Create3DBuffer(width, height);
- new_surface->Init(buffer_handler_, true);
+ new_surface->Init(buffer_handler_, preferred_format, true);
cursor_surfaces_.emplace_back(std::move(new_surface));
surface = cursor_surfaces_.back().get();
}
void DisplayPlaneManager::EnsureOffScreenTarget(DisplayPlaneState &plane) {
NativeSurface *surface = NULL;
+ uint32_t preferred_format = plane.plane()->GetPreferredFormat();
for (auto &fb : surfaces_) {
if (!fb->InUse()) {
- surface = fb.get();
- break;
+ uint32_t surface_format = fb->GetLayer()->GetBuffer()->GetFormat();
+ if (preferred_format == surface_format) {
+ surface = fb.get();
+ break;
+ }
}
}
if (!surface) {
NativeSurface *new_surface = Create3DBuffer(width_, height_);
- new_surface->Init(buffer_handler_);
+ new_surface->Init(buffer_handler_, preferred_format);
surfaces_.emplace_back(std::move(new_surface));
surface = surfaces_.back().get();
}
*/
virtual uint32_t GetPreferredVideoFormat() const = 0;
+ /**
+ * API for querying preferred format supported by this
+ * plane for non-media content.
+ */
+ virtual uint32_t GetPreferredFormat() const = 0;
+
virtual void Dump() const = 0;
};
}
}
- if (prefered_video_format_ == 0) {
- for (uint32_t j = 0; j < total_size; j++) {
- uint32_t format = supported_formats_.at(j);
- switch (format) {
- case DRM_FORMAT_RGB888:
- case DRM_FORMAT_XRGB8888:
- case DRM_FORMAT_XBGR8888:
- case DRM_FORMAT_RGBX8888:
- case DRM_FORMAT_ABGR8888:
- case DRM_FORMAT_RGBA8888:
- prefered_video_format_ = format;
- break;
- }
+ for (uint32_t j = 0; j < total_size; j++) {
+ uint32_t format = supported_formats_.at(j);
+ switch (format) {
+ case DRM_FORMAT_RGB888:
+ case DRM_FORMAT_XRGB8888:
+ case DRM_FORMAT_XBGR8888:
+ case DRM_FORMAT_RGBX8888:
+ case DRM_FORMAT_ABGR8888:
+ case DRM_FORMAT_RGBA8888:
+ case DRM_FORMAT_BGRA8888:
+ prefered_format_ = format;
+ break;
}
}
+ if (prefered_video_format_ == 0) {
+ prefered_video_format_ = prefered_format_;
+ }
+
ScopedDrmObjectPropertyPtr plane_props(
drmModeObjectGetProperties(gpu_fd, id_, DRM_MODE_OBJECT_PLANE));
if (!plane_props) {
return prefered_video_format_;
}
+uint32_t DrmPlane::GetPreferredFormat() const {
+ return prefered_format_;
+}
+
void DrmPlane::Dump() const {
DUMPTRACE("Plane Information Starts. -------------");
DUMPTRACE("Plane ID: %d", id_);
if (in_fence_fd_prop_.id != 0)
DUMPTRACE("IN_FENCE_FD is supported.");
- DUMPTRACE("Preferred Video Formar: %4.4s", (char*)&(prefered_video_format_));
+ DUMPTRACE("Preferred Video Format: %4.4s", (char*)&(prefered_video_format_));
+ DUMPTRACE("Preferred Video Format: %4.4s", (char*)&(prefered_format_));
DUMPTRACE("Plane Information Ends. -------------");
}
uint32_t GetFormatForFrameBuffer(uint32_t format) override;
uint32_t GetPreferredVideoFormat() const override;
+ uint32_t GetPreferredFormat() const override;
void Dump() const override;
std::vector<uint32_t> supported_formats_;
int32_t kms_fence_ = 0;
uint32_t prefered_video_format_ = 0;
+ uint32_t prefered_format_ = 0;
};
} // namespace hwcomposer