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

Side by Side Diff: ui/ozone/platform/drm/gpu/drm_console_buffer.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 | « no previous file | ui/ozone/platform/drm/gpu/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_console_buffer.h" 5 #include "ui/ozone/platform/drm/gpu/drm_console_buffer.h"
6 6
7 #include <sys/mman.h> 7 #include <sys/mman.h>
8 #include <xf86drmMode.h> 8 #include <xf86drmMode.h>
9 9
10 #include "third_party/skia/include/core/SkCanvas.h" 10 #include "third_party/skia/include/core/SkCanvas.h"
11 #include "ui/ozone/platform/drm/gpu/drm_device.h" 11 #include "ui/ozone/platform/drm/gpu/drm_device.h"
12 #include "ui/ozone/platform/drm/gpu/drm_util.h" 12 #include "ui/ozone/platform/drm/gpu/drm_util.h"
13 #include "ui/ozone/platform/drm/gpu/scoped_drm_types.h" 13 #include "ui/ozone/platform/drm/gpu/scoped_drm_types.h"
14 14
15 namespace ui { 15 namespace ui {
16 16
17 DrmConsoleBuffer::DrmConsoleBuffer(const scoped_refptr<DrmDevice>& drm, 17 DrmConsoleBuffer::DrmConsoleBuffer(const scoped_refptr<DrmDevice>& drm,
18 uint32_t framebuffer) 18 uint32_t framebuffer)
19 : drm_(drm), 19 : drm_(drm),
20 handle_(0), 20 handle_(0),
21 framebuffer_(framebuffer), 21 framebuffer_(framebuffer),
22 mmap_base_(NULL), 22 mmap_base_(NULL),
23 mmap_size_(0) { 23 mmap_size_(0) {
24 } 24 }
25 25
26 DrmConsoleBuffer::~DrmConsoleBuffer() { 26 DrmConsoleBuffer::~DrmConsoleBuffer() {
27 if (mmap_base_) 27 if (mmap_base_)
28 if (munmap(mmap_base_, mmap_size_)) 28 if (munmap(mmap_base_, mmap_size_))
29 PLOG(ERROR) << "munmap"; 29 PLOG(ERROR) << "munmap";
30
31 if (handle_ && !drm_->CloseBufferHandle(handle_))
32 PLOG(ERROR) << "DrmConsoleBuffer: CloseBufferHandle: handle " << handle_;
30 } 33 }
31 34
32 bool DrmConsoleBuffer::Initialize() { 35 bool DrmConsoleBuffer::Initialize() {
33 ScopedDrmFramebufferPtr fb(drm_->GetFramebuffer(framebuffer_)); 36 ScopedDrmFramebufferPtr fb(drm_->GetFramebuffer(framebuffer_));
34 37
35 if (!fb) 38 if (!fb)
36 return false; 39 return false;
37 40
38 handle_ = fb->handle; 41 handle_ = fb->handle;
39 stride_ = fb->pitch; 42 stride_ = fb->pitch;
40 SkImageInfo info = SkImageInfo::MakeN32Premul(fb->width, fb->height); 43 SkImageInfo info = SkImageInfo::MakeN32Premul(fb->width, fb->height);
41 44
42 mmap_size_ = info.getSafeSize(stride_); 45 mmap_size_ = info.getSafeSize(stride_);
43 46
44 if (!MapDumbBuffer(drm_->get_fd(), fb->handle, mmap_size_, &mmap_base_)) { 47 if (!MapDumbBuffer(drm_->get_fd(), fb->handle, mmap_size_, &mmap_base_)) {
45 mmap_base_ = NULL; 48 mmap_base_ = NULL;
46 return false; 49 return false;
47 } 50 }
48 51
49 surface_ = 52 surface_ =
50 skia::AdoptRef(SkSurface::NewRasterDirect(info, mmap_base_, stride_)); 53 skia::AdoptRef(SkSurface::NewRasterDirect(info, mmap_base_, stride_));
51 if (!surface_) 54 if (!surface_)
52 return false; 55 return false;
53 56
54 return true; 57 return true;
55 } 58 }
56 59
57 } // namespace ui 60 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | ui/ozone/platform/drm/gpu/drm_device.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698