| Index: ui/ozone/platform/drm/gpu/drm_device.cc
|
| diff --git a/ui/ozone/platform/drm/gpu/drm_device.cc b/ui/ozone/platform/drm/gpu/drm_device.cc
|
| index 0a9fbbe7d74009b5c88c223fc2a40fbd373e8939..1df20c6c5d9ec1702cce442285d059911cf356f4 100644
|
| --- a/ui/ozone/platform/drm/gpu/drm_device.cc
|
| +++ b/ui/ozone/platform/drm/gpu/drm_device.cc
|
| @@ -185,9 +185,6 @@
|
| ScopedDrmColorLutPtr CreateLutBlob(
|
| const std::vector<GammaRampRGBEntry>& source) {
|
| TRACE_EVENT0("drm", "CreateLutBlob");
|
| - if (source.empty())
|
| - return nullptr;
|
| -
|
| ScopedDrmColorLutPtr lut(
|
| static_cast<DrmColorLut*>(malloc(sizeof(DrmColorLut) * source.size())));
|
| DrmColorLut* p = lut.get();
|
| @@ -201,9 +198,6 @@
|
|
|
| ScopedDrmColorCtmPtr CreateCTMBlob(
|
| const std::vector<float>& correction_matrix) {
|
| - if (correction_matrix.empty())
|
| - return nullptr;
|
| -
|
| ScopedDrmColorCtmPtr ctm(
|
| static_cast<DrmColorCtm*>(malloc(sizeof(DrmColorCtm))));
|
| for (size_t i = 0; i < arraysize(ctm->ctm_coeff); ++i) {
|
| @@ -226,38 +220,29 @@
|
| const char* property_name,
|
| unsigned char* data,
|
| size_t length) {
|
| - uint32_t blob_id = 0;
|
| + uint32_t blob_id;
|
| int res;
|
| -
|
| - if (data) {
|
| - res = CreatePropertyBlob(fd, data, length, &blob_id);
|
| - if (res != 0) {
|
| - LOG(ERROR) << "Error creating property blob: " << base::safe_strerror(res)
|
| - << " for property " << property_name;
|
| - return false;
|
| - }
|
| - }
|
| -
|
| - bool success = false;
|
| + res = CreatePropertyBlob(fd, data, length, &blob_id);
|
| + if (res != 0) {
|
| + LOG(ERROR) << "Error creating property blob: " << base::safe_strerror(res)
|
| + << " for property " << property_name;
|
| + return false;
|
| + }
|
| res = drmModeObjectSetProperty(fd, object_id, object_type, prop_id, blob_id);
|
| if (res != 0) {
|
| LOG(ERROR) << "Error updating property: " << base::safe_strerror(res)
|
| << " for property " << property_name;
|
| - } else {
|
| - success = true;
|
| - }
|
| - if (blob_id != 0)
|
| DestroyPropertyBlob(fd, blob_id);
|
| - return success;
|
| + return false;
|
| + }
|
| + DestroyPropertyBlob(fd, blob_id);
|
| + return true;
|
| }
|
|
|
| std::vector<GammaRampRGBEntry> ResampleLut(
|
| const std::vector<GammaRampRGBEntry>& lut_in,
|
| size_t desired_size) {
|
| TRACE_EVENT1("drm", "ResampleLut", "desired_size", desired_size);
|
| - if (lut_in.empty())
|
| - return std::vector<GammaRampRGBEntry>();
|
| -
|
| if (lut_in.size() == desired_size)
|
| return lut_in;
|
|
|
| @@ -689,35 +674,23 @@
|
| bool DrmDevice::SetGammaRamp(uint32_t crtc_id,
|
| const std::vector<GammaRampRGBEntry>& lut) {
|
| ScopedDrmCrtcPtr crtc = GetCrtc(crtc_id);
|
| - size_t gamma_size = static_cast<size_t>(crtc->gamma_size);
|
|
|
| // TODO(robert.bradford) resample the incoming ramp to match what the kernel
|
| // expects.
|
| - if (!lut.empty() && gamma_size != lut.size()) {
|
| + if (static_cast<size_t>(crtc->gamma_size) != lut.size()) {
|
| LOG(ERROR) << "Gamma table size mismatch: supplied " << lut.size()
|
| - << " expected " << gamma_size;
|
| - return false;
|
| + << " expected " << crtc->gamma_size;
|
| }
|
|
|
| std::vector<uint16_t> r, g, b;
|
| - r.reserve(gamma_size);
|
| - g.reserve(gamma_size);
|
| - b.reserve(gamma_size);
|
| -
|
| - if (lut.empty()) {
|
| - // Create a linear gamma ramp table to deactivate the feature.
|
| - for (size_t i = 0; i < gamma_size; ++i) {
|
| - uint16_t value = (i * ((1 << 16) - 1)) / (gamma_size - 1);
|
| - r.push_back(value);
|
| - g.push_back(value);
|
| - b.push_back(value);
|
| - }
|
| - } else {
|
| - for (size_t i = 0; i < gamma_size; ++i) {
|
| - r.push_back(lut[i].r);
|
| - g.push_back(lut[i].g);
|
| - b.push_back(lut[i].b);
|
| - }
|
| + r.reserve(lut.size());
|
| + g.reserve(lut.size());
|
| + b.reserve(lut.size());
|
| +
|
| + for (size_t i = 0; i < lut.size(); ++i) {
|
| + r.push_back(lut[i].r);
|
| + g.push_back(lut[i].g);
|
| + b.push_back(lut[i].b);
|
| }
|
|
|
| DCHECK(file_.IsValid());
|
| @@ -750,10 +723,9 @@
|
| break;
|
| }
|
|
|
| - // If we can't find the degamma & gamma lut size, it means the properties
|
| - // aren't available. We should then use the legacy gamma ramp ioctl.
|
| if (degamma_lut_size == 0 || gamma_lut_size == 0) {
|
| - return SetGammaRamp(crtc_id, gamma_lut);
|
| + LOG(WARNING) << "No available (de)gamma tables.";
|
| + return false;
|
| }
|
|
|
| ScopedDrmColorLutPtr degamma_blob_data =
|
|
|