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

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

Issue 1285183008: Ozone integration. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: add missing license header Created 5 years, 4 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_console_buffer.h ('k') | 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ui/ozone/platform/drm/gpu/drm_console_buffer.h"
6
7 #include <sys/mman.h>
8 #include <xf86drmMode.h>
9
10 #include "third_party/skia/include/core/SkCanvas.h"
11 #include "ui/ozone/platform/drm/common/scoped_drm_types.h"
12 #include "ui/ozone/platform/drm/gpu/drm_device.h"
13
14 namespace ui {
15
16 DrmConsoleBuffer::DrmConsoleBuffer(const scoped_refptr<DrmDevice>& drm,
17 uint32_t framebuffer)
18 : drm_(drm), framebuffer_(framebuffer) {
19 }
20
21 DrmConsoleBuffer::~DrmConsoleBuffer() {
22 if (mmap_base_)
23 if (munmap(mmap_base_, mmap_size_))
24 PLOG(ERROR) << "munmap";
25
26 if (handle_ && !drm_->CloseBufferHandle(handle_))
27 PLOG(ERROR) << "DrmConsoleBuffer: CloseBufferHandle: handle " << handle_;
28 }
29
30 bool DrmConsoleBuffer::Initialize() {
31 ScopedDrmFramebufferPtr fb(drm_->GetFramebuffer(framebuffer_));
32
33 if (!fb)
34 return false;
35
36 handle_ = fb->handle;
37 stride_ = fb->pitch;
38 SkImageInfo info = SkImageInfo::MakeN32Premul(fb->width, fb->height);
39
40 mmap_size_ = info.getSafeSize(stride_);
41
42 if (!drm_->MapDumbBuffer(fb->handle, mmap_size_, &mmap_base_)) {
43 mmap_base_ = NULL;
44 return false;
45 }
46
47 surface_ =
48 skia::AdoptRef(SkSurface::NewRasterDirect(info, mmap_base_, stride_));
49 if (!surface_)
50 return false;
51
52 return true;
53 }
54
55 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/drm/gpu/drm_console_buffer.h ('k') | ui/ozone/platform/drm/gpu/drm_device.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698