Chromium Code Reviews| 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 fb5bbc8d4d080a2fcd397d1b3dc54801c853d3be..1ad7cc1d98851e521956292a21513c24d4488de6 100644 |
| --- a/ui/ozone/platform/drm/gpu/drm_device.cc |
| +++ b/ui/ozone/platform/drm/gpu/drm_device.cc |
| @@ -18,6 +18,7 @@ |
| #include "base/thread_task_runner_handle.h" |
| #include "base/trace_event/trace_event.h" |
| #include "third_party/skia/include/core/SkImageInfo.h" |
| +#include "ui/display/types/gamma_ramp_rgb_entry.h" |
| #include "ui/ozone/platform/drm/gpu/drm_util.h" |
| #include "ui/ozone/platform/drm/gpu/hardware_display_plane_manager_legacy.h" |
| @@ -504,4 +505,32 @@ bool DrmDevice::DropMaster() { |
| return (drmDropMaster(file_.GetPlatformFile()) == 0); |
| } |
| +bool DrmDevice::SetGammaRamp(uint32_t crtc_id, |
| + const std::vector<GammaRampRGBEntry>& lut) { |
| + ScopedDrmCrtcPtr crtc = GetCrtc(crtc_id); |
| + |
| + // TODO(robert.bradford) resample the incoming ramp to match what the kernel |
| + // expects. |
| + if (static_cast<size_t>(crtc->gamma_size) != lut.size()) { |
| + LOG(ERROR) << "Gamma table size mismatch: supplied " << lut.size() |
| + << " expected " << crtc->gamma_size; |
| + } |
| + |
| + std::vector<uint16_t> r, g, b; |
| + r.resize(lut.size()); |
|
dcheng
2015/04/30 20:40:24
Nit: reserve instead of resize.
|
| + g.resize(lut.size()); |
| + b.resize(lut.size()); |
| + |
| + for (size_t i = 0; i < lut.size(); ++i) { |
| + r[i] = lut[i].r; |
| + g[i] = lut[i].g; |
| + b[i] = lut[i].b; |
| + } |
| + |
| + DCHECK(file_.IsValid()); |
| + TRACE_EVENT0("drm", "DrmDevice::SetGamma"); |
| + return (drmModeCrtcSetGamma(file_.GetPlatformFile(), crtc_id, r.size(), &r[0], |
| + &g[0], &b[0]) == 0); |
| +} |
| + |
| } // namespace ui |