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

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

Issue 1080923006: ozone: drm: Fix graphics buffer handle leak in DrmConsoleBuffer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: switch to DRM_IOCTL_GEM_CLOSE per marcheu@ Created 5 years, 8 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/test/mock_drm_device.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 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 void DrmDevice::DestroyDumbBuffer(const SkImageInfo& info, 471 void DrmDevice::DestroyDumbBuffer(const SkImageInfo& info,
472 uint32_t handle, 472 uint32_t handle,
473 uint32_t stride, 473 uint32_t stride,
474 void* pixels) { 474 void* pixels) {
475 DCHECK(file_.IsValid()); 475 DCHECK(file_.IsValid());
476 TRACE_EVENT1("drm", "DrmDevice::DestroyDumbBuffer", "handle", handle); 476 TRACE_EVENT1("drm", "DrmDevice::DestroyDumbBuffer", "handle", handle);
477 munmap(pixels, info.getSafeSize(stride)); 477 munmap(pixels, info.getSafeSize(stride));
478 DrmDestroyDumbBuffer(file_.GetPlatformFile(), handle); 478 DrmDestroyDumbBuffer(file_.GetPlatformFile(), handle);
479 } 479 }
480 480
481 bool DrmDevice::CloseBufferHandle(uint32_t handle) {
482 struct drm_gem_close close_request;
483 memset(&close_request, 0, sizeof(close_request));
484 close_request.handle = handle;
485 return !drmIoctl(file_.GetPlatformFile(), DRM_IOCTL_GEM_CLOSE,
486 &close_request);
487 }
488
481 bool DrmDevice::CommitProperties(drmModePropertySet* properties, 489 bool DrmDevice::CommitProperties(drmModePropertySet* properties,
482 uint32_t flags, 490 uint32_t flags,
483 const PageFlipCallback& callback) { 491 const PageFlipCallback& callback) {
484 #if defined(USE_DRM_ATOMIC) 492 #if defined(USE_DRM_ATOMIC)
485 scoped_ptr<PageFlipPayload> payload( 493 scoped_ptr<PageFlipPayload> payload(
486 new PageFlipPayload(base::ThreadTaskRunnerHandle::Get(), callback)); 494 new PageFlipPayload(base::ThreadTaskRunnerHandle::Get(), callback));
487 if (!drmModePropertySetCommit(file_.GetPlatformFile(), flags, payload.get(), 495 if (!drmModePropertySetCommit(file_.GetPlatformFile(), flags, payload.get(),
488 properties)) { 496 properties)) {
489 // If successful the payload will be removed by the event 497 // If successful the payload will be removed by the event
490 ignore_result(payload.release()); 498 ignore_result(payload.release());
491 return true; 499 return true;
492 } 500 }
493 return false; 501 return false;
494 #else 502 #else
495 return false; 503 return false;
496 #endif // defined(USE_DRM_ATOMIC) 504 #endif // defined(USE_DRM_ATOMIC)
497 } 505 }
498 506
499 bool DrmDevice::SetMaster() { 507 bool DrmDevice::SetMaster() {
500 DCHECK(file_.IsValid()); 508 DCHECK(file_.IsValid());
501 return (drmSetMaster(file_.GetPlatformFile()) == 0); 509 return (drmSetMaster(file_.GetPlatformFile()) == 0);
502 } 510 }
503 511
504 bool DrmDevice::DropMaster() { 512 bool DrmDevice::DropMaster() {
505 DCHECK(file_.IsValid()); 513 DCHECK(file_.IsValid());
506 return (drmDropMaster(file_.GetPlatformFile()) == 0); 514 return (drmDropMaster(file_.GetPlatformFile()) == 0);
507 } 515 }
508 516
509 } // namespace ui 517 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/drm/gpu/drm_device.h ('k') | ui/ozone/platform/drm/test/mock_drm_device.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698