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

Side by Side Diff: ui/ozone/platform/dri/dri_console_buffer.cc

Issue 851853002: It is time. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Trying to reup because the last upload failed. Created 5 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/dri/dri_console_buffer.h ('k') | ui/ozone/platform/dri/dri_cursor.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/dri/dri_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/dri/dri_util.h"
12 #include "ui/ozone/platform/dri/dri_wrapper.h"
13 #include "ui/ozone/platform/dri/scoped_drm_types.h"
14
15 namespace ui {
16
17 DriConsoleBuffer::DriConsoleBuffer(DriWrapper* dri, uint32_t framebuffer)
18 : dri_(dri),
19 handle_(0),
20 framebuffer_(framebuffer),
21 mmap_base_(NULL),
22 mmap_size_(0) {
23 }
24
25 DriConsoleBuffer::~DriConsoleBuffer() {
26 if (mmap_base_)
27 if (munmap(mmap_base_, mmap_size_))
28 PLOG(ERROR) << "munmap";
29 }
30
31 bool DriConsoleBuffer::Initialize() {
32 ScopedDrmFramebufferPtr fb(dri_->GetFramebuffer(framebuffer_));
33
34 if (!fb)
35 return false;
36
37 handle_ = fb->handle;
38 stride_ = fb->pitch;
39 SkImageInfo info = SkImageInfo::MakeN32Premul(fb->width, fb->height);
40
41 mmap_size_ = info.getSafeSize(stride_);
42
43 if (!MapDumbBuffer(dri_->get_fd(), fb->handle, mmap_size_, &mmap_base_)) {
44 mmap_base_ = NULL;
45 return false;
46 }
47
48 surface_ =
49 skia::AdoptRef(SkSurface::NewRasterDirect(info, mmap_base_, stride_));
50 if (!surface_)
51 return false;
52
53 return true;
54 }
55
56 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/dri/dri_console_buffer.h ('k') | ui/ozone/platform/dri/dri_cursor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698