| OLD | NEW |
| 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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 + |
| 275 (lut_in[base_index + 1].g - lut_in[base_index].g) * | 275 (lut_in[base_index + 1].g - lut_in[base_index].g) * |
| 276 remaining / desired_size; | 276 remaining / desired_size; |
| 277 result[i].b = lut_in[base_index].b + | 277 result[i].b = lut_in[base_index].b + |
| 278 (lut_in[base_index + 1].b - lut_in[base_index].b) * | 278 (lut_in[base_index + 1].b - lut_in[base_index].b) * |
| 279 remaining / desired_size; | 279 remaining / desired_size; |
| 280 } else { | 280 } else { |
| 281 result[i] = lut_in[lut_in.size() - 1]; | 281 result[i] = lut_in.back(); |
| 282 } | 282 } |
| 283 } | 283 } |
| 284 | 284 |
| 285 return result; | 285 return result; |
| 286 } | 286 } |
| 287 | 287 |
| 288 } // namespace | 288 } // namespace |
| 289 | 289 |
| 290 class DrmDevice::PageFlipManager { | 290 class DrmDevice::PageFlipManager { |
| 291 public: | 291 public: |
| 292 PageFlipManager() : next_id_(0) {} | 292 PageFlipManager() : next_id_(0) {} |
| 293 ~PageFlipManager() {} | 293 ~PageFlipManager() {} |
| 294 | 294 |
| 295 void OnPageFlip(uint32_t frame, | 295 void OnPageFlip(uint32_t frame, |
| 296 uint32_t seconds, | 296 uint32_t seconds, |
| 297 uint32_t useconds, | 297 uint32_t useconds, |
| 298 uint64_t id) { | 298 uint64_t id) { |
| 299 auto it = | 299 auto it = |
| 300 std::find_if(callbacks_.begin(), callbacks_.end(), FindCallback(id)); | 300 std::find_if(callbacks_.begin(), callbacks_.end(), FindCallback(id)); |
| 301 if (it == callbacks_.end()) { | 301 if (it == callbacks_.end()) { |
| 302 LOG(WARNING) << "Could not find callback for page flip id=" << id; | 302 LOG(WARNING) << "Could not find callback for page flip id=" << id; |
| 303 return; | 303 return; |
| 304 } | 304 } |
| 305 | 305 |
| 306 DrmDevice::PageFlipCallback callback = it->callback; | 306 DrmDevice::PageFlipCallback callback = it->callback; |
| 307 it->pending_calls -= 1; | 307 it->pending_calls--; |
| 308 | |
| 309 if (it->pending_calls) | 308 if (it->pending_calls) |
| 310 return; | 309 return; |
| 311 | 310 |
| 312 callbacks_.erase(it); | 311 callbacks_.erase(it); |
| 313 callback.Run(frame, seconds, useconds); | 312 callback.Run(frame, seconds, useconds); |
| 314 } | 313 } |
| 315 | 314 |
| 316 uint64_t GetNextId() { return next_id_++; } | 315 uint64_t GetNextId() { return next_id_++; } |
| 317 | 316 |
| 318 void RegisterCallback(uint64_t id, | 317 void RegisterCallback(uint64_t id, |
| 319 uint64_t pending_calls, | 318 uint64_t pending_calls, |
| 320 const DrmDevice::PageFlipCallback& callback) { | 319 const DrmDevice::PageFlipCallback& callback) { |
| 321 callbacks_.push_back({id, pending_calls, callback}); | 320 callbacks_.push_back({id, pending_calls, callback}); |
| 322 } | 321 } |
| 323 | 322 |
| 324 private: | 323 private: |
| 325 struct PageFlip { | 324 struct PageFlip { |
| 326 uint64_t id; | 325 uint64_t id; |
| 327 uint32_t pending_calls; | 326 uint32_t pending_calls; |
| 328 DrmDevice::PageFlipCallback callback; | 327 DrmDevice::PageFlipCallback callback; |
| 329 }; | 328 }; |
| 330 | 329 |
| 331 struct FindCallback { | 330 struct FindCallback { |
| 332 FindCallback(uint64_t id) : id(id) {} | 331 explicit FindCallback(uint64_t id) : id(id) {} |
| 333 | 332 |
| 334 bool operator()(const PageFlip& flip) const { return flip.id == id; } | 333 bool operator()(const PageFlip& flip) const { return flip.id == id; } |
| 335 | 334 |
| 336 uint64_t id; | 335 const uint64_t id; |
| 337 }; | 336 }; |
| 338 | 337 |
| 339 uint64_t next_id_; | 338 uint64_t next_id_; |
| 340 | 339 |
| 341 std::vector<PageFlip> callbacks_; | 340 std::vector<PageFlip> callbacks_; |
| 342 | 341 |
| 343 DISALLOW_COPY_AND_ASSIGN(PageFlipManager); | 342 DISALLOW_COPY_AND_ASSIGN(PageFlipManager); |
| 344 }; | 343 }; |
| 345 | 344 |
| 346 class DrmDevice::IOWatcher : public base::MessagePumpLibevent::Watcher { | 345 class DrmDevice::IOWatcher : public base::MessagePumpLibevent::Watcher { |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 799 reinterpret_cast<unsigned char*>(ctm_blob_data.get()), | 798 reinterpret_cast<unsigned char*>(ctm_blob_data.get()), |
| 800 sizeof(DrmColorCtm))) | 799 sizeof(DrmColorCtm))) |
| 801 return false; | 800 return false; |
| 802 } | 801 } |
| 803 } | 802 } |
| 804 | 803 |
| 805 return true; | 804 return true; |
| 806 } | 805 } |
| 807 | 806 |
| 808 } // namespace ui | 807 } // namespace ui |
| OLD | NEW |