Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1143)

Side by Side Diff: ui/ozone/platform/drm/gpu/drm_device.cc

Issue 2613493002: Fix namespace for src/ui/display/. (Closed)
Patch Set: Rebase. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/ozone/platform/drm/gpu/drm_device.h ('k') | ui/ozone/platform/drm/gpu/drm_display.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/ozone/platform/drm/gpu/drm_device.h" 5 #include "ui/ozone/platform/drm/gpu/drm_device.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <sys/mman.h> 8 #include <sys/mman.h>
9 #include <unistd.h> 9 #include <unistd.h>
10 #include <xf86drm.h> 10 #include <xf86drm.h>
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 memset(&destroy, 0, sizeof(destroy)); 176 memset(&destroy, 0, sizeof(destroy));
177 destroy.blob_id = id; 177 destroy.blob_id = id;
178 ret = drmIoctl(fd, DRM_IOCTL_MODE_DESTROYPROPBLOB, &destroy); 178 ret = drmIoctl(fd, DRM_IOCTL_MODE_DESTROYPROPBLOB, &destroy);
179 return ret < 0 ? -errno : ret; 179 return ret < 0 ? -errno : ret;
180 } 180 }
181 181
182 using ScopedDrmColorLutPtr = std::unique_ptr<DrmColorLut, base::FreeDeleter>; 182 using ScopedDrmColorLutPtr = std::unique_ptr<DrmColorLut, base::FreeDeleter>;
183 using ScopedDrmColorCtmPtr = std::unique_ptr<DrmColorCtm, base::FreeDeleter>; 183 using ScopedDrmColorCtmPtr = std::unique_ptr<DrmColorCtm, base::FreeDeleter>;
184 184
185 ScopedDrmColorLutPtr CreateLutBlob( 185 ScopedDrmColorLutPtr CreateLutBlob(
186 const std::vector<GammaRampRGBEntry>& source) { 186 const std::vector<display::GammaRampRGBEntry>& source) {
187 TRACE_EVENT0("drm", "CreateLutBlob"); 187 TRACE_EVENT0("drm", "CreateLutBlob");
188 if (source.empty()) 188 if (source.empty())
189 return nullptr; 189 return nullptr;
190 190
191 ScopedDrmColorLutPtr lut( 191 ScopedDrmColorLutPtr lut(
192 static_cast<DrmColorLut*>(malloc(sizeof(DrmColorLut) * source.size()))); 192 static_cast<DrmColorLut*>(malloc(sizeof(DrmColorLut) * source.size())));
193 DrmColorLut* p = lut.get(); 193 DrmColorLut* p = lut.get();
194 for (size_t i = 0; i < source.size(); ++i) { 194 for (size_t i = 0; i < source.size(); ++i) {
195 p[i].red = source[i].r; 195 p[i].red = source[i].r;
196 p[i].green = source[i].g; 196 p[i].green = source[i].g;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 LOG(ERROR) << "Error updating property: " << base::safe_strerror(res) 244 LOG(ERROR) << "Error updating property: " << base::safe_strerror(res)
245 << " for property " << property_name; 245 << " for property " << property_name;
246 } else { 246 } else {
247 success = true; 247 success = true;
248 } 248 }
249 if (blob_id != 0) 249 if (blob_id != 0)
250 DestroyPropertyBlob(fd, blob_id); 250 DestroyPropertyBlob(fd, blob_id);
251 return success; 251 return success;
252 } 252 }
253 253
254 std::vector<GammaRampRGBEntry> ResampleLut( 254 std::vector<display::GammaRampRGBEntry> ResampleLut(
255 const std::vector<GammaRampRGBEntry>& lut_in, 255 const std::vector<display::GammaRampRGBEntry>& lut_in,
256 size_t desired_size) { 256 size_t desired_size) {
257 TRACE_EVENT1("drm", "ResampleLut", "desired_size", desired_size); 257 TRACE_EVENT1("drm", "ResampleLut", "desired_size", desired_size);
258 if (lut_in.empty()) 258 if (lut_in.empty())
259 return std::vector<GammaRampRGBEntry>(); 259 return std::vector<display::GammaRampRGBEntry>();
260 260
261 if (lut_in.size() == desired_size) 261 if (lut_in.size() == desired_size)
262 return lut_in; 262 return lut_in;
263 263
264 std::vector<GammaRampRGBEntry> result; 264 std::vector<display::GammaRampRGBEntry> result;
265 result.resize(desired_size); 265 result.resize(desired_size);
266 266
267 for (size_t i = 0; i < desired_size; ++i) { 267 for (size_t i = 0; i < desired_size; ++i) {
268 size_t base_index = lut_in.size() * i / desired_size; 268 size_t base_index = lut_in.size() * i / desired_size;
269 size_t remaining = lut_in.size() * i % desired_size; 269 size_t remaining = lut_in.size() * i % desired_size;
270 if (base_index < lut_in.size() - 1) { 270 if (base_index < lut_in.size() - 1) {
271 result[i].r = lut_in[base_index].r + 271 result[i].r = lut_in[base_index].r +
272 (lut_in[base_index + 1].r - lut_in[base_index].r) * 272 (lut_in[base_index + 1].r - lut_in[base_index].r) *
273 remaining / desired_size; 273 remaining / desired_size;
274 result[i].g = lut_in[base_index].g + 274 result[i].g = lut_in[base_index].g +
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 DCHECK(file_.IsValid()); 692 DCHECK(file_.IsValid());
693 return (drmSetMaster(file_.GetPlatformFile()) == 0); 693 return (drmSetMaster(file_.GetPlatformFile()) == 0);
694 } 694 }
695 695
696 bool DrmDevice::DropMaster() { 696 bool DrmDevice::DropMaster() {
697 TRACE_EVENT1("drm", "DrmDevice::DropMaster", "path", device_path_.value()); 697 TRACE_EVENT1("drm", "DrmDevice::DropMaster", "path", device_path_.value());
698 DCHECK(file_.IsValid()); 698 DCHECK(file_.IsValid());
699 return (drmDropMaster(file_.GetPlatformFile()) == 0); 699 return (drmDropMaster(file_.GetPlatformFile()) == 0);
700 } 700 }
701 701
702 bool DrmDevice::SetGammaRamp(uint32_t crtc_id, 702 bool DrmDevice::SetGammaRamp(
703 const std::vector<GammaRampRGBEntry>& lut) { 703 uint32_t crtc_id,
704 const std::vector<display::GammaRampRGBEntry>& lut) {
704 ScopedDrmCrtcPtr crtc = GetCrtc(crtc_id); 705 ScopedDrmCrtcPtr crtc = GetCrtc(crtc_id);
705 size_t gamma_size = static_cast<size_t>(crtc->gamma_size); 706 size_t gamma_size = static_cast<size_t>(crtc->gamma_size);
706 707
707 if (gamma_size == 0 && lut.empty()) 708 if (gamma_size == 0 && lut.empty())
708 return true; 709 return true;
709 710
710 if (gamma_size == 0) { 711 if (gamma_size == 0) {
711 LOG(ERROR) << "Gamma table not supported"; 712 LOG(ERROR) << "Gamma table not supported";
712 return false; 713 return false;
713 } 714 }
(...skipping 28 matching lines...) Expand all
742 } 743 }
743 744
744 DCHECK(file_.IsValid()); 745 DCHECK(file_.IsValid());
745 TRACE_EVENT0("drm", "DrmDevice::SetGamma"); 746 TRACE_EVENT0("drm", "DrmDevice::SetGamma");
746 return (drmModeCrtcSetGamma(file_.GetPlatformFile(), crtc_id, r.size(), &r[0], 747 return (drmModeCrtcSetGamma(file_.GetPlatformFile(), crtc_id, r.size(), &r[0],
747 &g[0], &b[0]) == 0); 748 &g[0], &b[0]) == 0);
748 } 749 }
749 750
750 bool DrmDevice::SetColorCorrection( 751 bool DrmDevice::SetColorCorrection(
751 uint32_t crtc_id, 752 uint32_t crtc_id,
752 const std::vector<GammaRampRGBEntry>& degamma_lut, 753 const std::vector<display::GammaRampRGBEntry>& degamma_lut,
753 const std::vector<GammaRampRGBEntry>& gamma_lut, 754 const std::vector<display::GammaRampRGBEntry>& gamma_lut,
754 const std::vector<float>& correction_matrix) { 755 const std::vector<float>& correction_matrix) {
755 ScopedDrmObjectPropertyPtr crtc_props(drmModeObjectGetProperties( 756 ScopedDrmObjectPropertyPtr crtc_props(drmModeObjectGetProperties(
756 file_.GetPlatformFile(), crtc_id, DRM_MODE_OBJECT_CRTC)); 757 file_.GetPlatformFile(), crtc_id, DRM_MODE_OBJECT_CRTC));
757 uint64_t degamma_lut_size = 0; 758 uint64_t degamma_lut_size = 0;
758 uint64_t gamma_lut_size = 0; 759 uint64_t gamma_lut_size = 0;
759 760
760 for (uint32_t i = 0; i < crtc_props->count_props; ++i) { 761 for (uint32_t i = 0; i < crtc_props->count_props; ++i) {
761 ScopedDrmPropertyPtr property( 762 ScopedDrmPropertyPtr property(
762 drmModeGetProperty(file_.GetPlatformFile(), crtc_props->props[i])); 763 drmModeGetProperty(file_.GetPlatformFile(), crtc_props->props[i]));
763 if (property && !strcmp(property->name, "DEGAMMA_LUT_SIZE")) { 764 if (property && !strcmp(property->name, "DEGAMMA_LUT_SIZE")) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 reinterpret_cast<unsigned char*>(ctm_blob_data.get()), 813 reinterpret_cast<unsigned char*>(ctm_blob_data.get()),
813 sizeof(DrmColorCtm))) 814 sizeof(DrmColorCtm)))
814 return false; 815 return false;
815 } 816 }
816 } 817 }
817 818
818 return true; 819 return true;
819 } 820 }
820 821
821 } // namespace ui 822 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/drm/gpu/drm_device.h ('k') | ui/ozone/platform/drm/gpu/drm_display.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698