HWC2::Error DrmHwcTwo::HwcLayer::SetLayerBlendMode(int32_t mode) {
supported(__func__);
- blending_ = static_cast<HWC2::BlendMode>(mode);
+ switch (static_cast<HWC2::BlendMode>(mode)) {
+ case HWC2::BlendMode::None:
+ blending_ = DrmHwcBlending::kNone;
+ break;
+ case HWC2::BlendMode::Premultiplied:
+ blending_ = DrmHwcBlending::kPreMult;
+ break;
+ case HWC2::BlendMode::Coverage:
+ blending_ = DrmHwcBlending::kCoverage;
+ break;
+ default:
+ ALOGE("Unknown blending mode b=%d", blending_);
+ blending_ = DrmHwcBlending::kNone;
+ break;
+ }
return HWC2::Error::None;
}
void DrmHwcTwo::HwcLayer::PopulateDrmLayer(DrmHwcLayer *layer) {
supported(__func__);
- switch (blending_) {
- case HWC2::BlendMode::None:
- layer->blending = DrmHwcBlending::kNone;
- break;
- case HWC2::BlendMode::Premultiplied:
- layer->blending = DrmHwcBlending::kPreMult;
- break;
- case HWC2::BlendMode::Coverage:
- layer->blending = DrmHwcBlending::kCoverage;
- break;
- default:
- ALOGE("Unknown blending mode b=%d", blending_);
- layer->blending = DrmHwcBlending::kNone;
- break;
- }
-
layer->sf_handle = buffer_;
// TODO(rsglobal): Avoid extra fd duplication
layer->acquire_fence = UniqueFd(fcntl(acquire_fence_.Get(), F_DUPFD_CLOEXEC));
layer->display_frame = display_frame_;
layer->alpha = lround(65535.0F * alpha_);
+ layer->blending = blending_;
layer->source_crop = source_crop_;
layer->SetTransform(static_cast<int32_t>(transform_));
layer->color_space = color_space_;
HWC2::Composition sf_type_ = HWC2::Composition::Invalid;
HWC2::Composition validated_type_ = HWC2::Composition::Invalid;
- HWC2::BlendMode blending_ = HWC2::BlendMode::None;
buffer_handle_t buffer_ = NULL;
hwc_rect_t display_frame_;
float alpha_ = 1.0f;
hwc_color_t layer_color_;
HWC2::Transform transform_ = HWC2::Transform::None;
uint32_t z_order_ = 0;
+ DrmHwcBlending blending_ = DrmHwcBlending::kNone;
DrmHwcColorSpace color_space_ = DrmHwcColorSpace::kUndefined;
DrmHwcSampleRange sample_range_ = DrmHwcSampleRange::kUndefined;
};
ALOGI("Could not get alpha property");
ret = drm_->GetPlaneProperty(*this, "pixel blend mode", &blend_property_);
- if (ret)
+ if (ret == 0) {
+ std::tie(enum_value,
+ ret) = blend_property_.GetEnumValueWithName("Pre-multiplied");
+ if (ret == 0) {
+ blending_enum_map_[DrmHwcBlending::kPreMult] = enum_value;
+ }
+ std::tie(enum_value,
+ ret) = blend_property_.GetEnumValueWithName("Coverage");
+ if (ret == 0) {
+ blending_enum_map_[DrmHwcBlending::kCoverage] = enum_value;
+ }
+ std::tie(enum_value, ret) = blend_property_.GetEnumValueWithName("None");
+ if (ret == 0) {
+ blending_enum_map_[DrmHwcBlending::kNone] = enum_value;
+ }
+ } else {
ALOGI("Could not get pixel blend mode property");
+ }
ret = drm_->GetPlaneProperty(*this, "IN_FENCE_FD", &in_fence_fd_property_);
if (ret)
return false;
}
- if (blend_property_.id() == 0) {
- if ((layer->blending != DrmHwcBlending::kNone) &&
- (layer->blending != DrmHwcBlending::kPreMult)) {
- ALOGV("Blending is not supported on plane %d", id_);
- return false;
- }
- } else {
- int ret = 0;
-
- switch (layer->blending) {
- case DrmHwcBlending::kPreMult:
- std::tie(std::ignore,
- ret) = blend_property_.GetEnumValueWithName("Pre-multiplied");
- break;
- case DrmHwcBlending::kCoverage:
- std::tie(std::ignore,
- ret) = blend_property_.GetEnumValueWithName("Coverage");
- break;
- case DrmHwcBlending::kNone:
- default:
- std::tie(std::ignore,
- ret) = blend_property_.GetEnumValueWithName("None");
- break;
- }
- if (ret) {
- ALOGV("Expected a valid blend mode on plane %d", id_);
- return false;
- }
+ if (blending_enum_map_.count(layer->blending) == 0 &&
+ layer->blending != DrmHwcBlending::kNone) {
+ ALOGV("Blending is not supported on plane %d", id_);
+ return false;
}
uint32_t format = layer->buffer_info.format;
auto DrmPlane::AtomicSetState(drmModeAtomicReq &pset, DrmHwcLayer &layer,
uint32_t zpos, uint32_t crtc_id) -> int {
- int ret = 0;
uint32_t fb_id = UINT32_MAX;
int fence_fd = -1;
hwc_rect_t display_frame;
hwc_frect_t source_crop;
uint64_t rotation = 0;
uint64_t alpha = 0xFFFF;
- uint64_t blend = UINT64_MAX;
if (!layer.FbIdHandle) {
ALOGE("Expected a valid framebuffer for pset");
return 0;
}
- if (blend_property_) {
- switch (layer.blending) {
- case DrmHwcBlending::kPreMult:
- std::tie(blend,
- ret) = blend_property_.GetEnumValueWithName("Pre-multiplied");
- break;
- case DrmHwcBlending::kCoverage:
- std::tie(blend, ret) = blend_property_.GetEnumValueWithName("Coverage");
- break;
- case DrmHwcBlending::kNone:
- default:
- std::tie(blend, ret) = blend_property_.GetEnumValueWithName("None");
- break;
- }
- }
-
if (zpos_property_ && !zpos_property_.is_immutable()) {
uint64_t min_zpos = 0;
}
}
- if (blend_property_ && blend != UINT64_MAX) {
- if (!blend_property_.AtomicSet(pset, blend)) {
- return -EINVAL;
- }
+ if (blending_enum_map_.count(layer.blending) != 0 &&
+ !blend_property_.AtomicSet(pset, blending_enum_map_[layer.blending])) {
+ return -EINVAL;
}
if (color_encoding_enum_map_.count(layer.color_space) != 0 &&