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

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

Issue 1422563002: [Ozone] Enables overlay render format setting path and by default use UYVY (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
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_buffer.h" 5 #include "ui/ozone/platform/drm/gpu/drm_buffer.h"
6 6
7 #include <drm_fourcc.h> 7 #include <drm_fourcc.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "ui/ozone/platform/drm/gpu/drm_device.h" 10 #include "ui/ozone/platform/drm/gpu/drm_device.h"
11 11
12 namespace ui { 12 namespace ui {
13 13
14 namespace { 14 namespace {
15 15
16 uint8_t GetColorDepth(SkColorType type) {
17 switch (type) {
18 case kUnknown_SkColorType:
19 case kAlpha_8_SkColorType:
20 return 0;
21 case kIndex_8_SkColorType:
22 return 8;
23 case kRGB_565_SkColorType:
24 return 16;
25 case kARGB_4444_SkColorType:
26 return 16;
27 case kN32_SkColorType:
28 return 32;
29 default:
30 NOTREACHED();
31 return 0;
32 }
33 }
34
35 uint32_t GetFourCCCodeForSkColorType(SkColorType type) { 16 uint32_t GetFourCCCodeForSkColorType(SkColorType type) {
36 switch (type) { 17 switch (type) {
37 case kUnknown_SkColorType: 18 case kUnknown_SkColorType:
38 case kAlpha_8_SkColorType: 19 case kAlpha_8_SkColorType:
39 return 0; 20 return 0;
40 case kIndex_8_SkColorType: 21 case kIndex_8_SkColorType:
41 return DRM_FORMAT_C8; 22 return DRM_FORMAT_C8;
42 case kRGB_565_SkColorType: 23 case kRGB_565_SkColorType:
43 return DRM_FORMAT_RGB565; 24 return DRM_FORMAT_RGB565;
44 case kARGB_4444_SkColorType: 25 case kARGB_4444_SkColorType:
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 return false; 58 return false;
78 } 59 }
79 60
80 mmap_size_ = info.getSafeSize(stride_); 61 mmap_size_ = info.getSafeSize(stride_);
81 if (!drm_->MapDumbBuffer(handle_, mmap_size_, &mmap_base_)) { 62 if (!drm_->MapDumbBuffer(handle_, mmap_size_, &mmap_base_)) {
82 PLOG(ERROR) << "DrmBuffer: MapDumbBuffer: handle " << handle_; 63 PLOG(ERROR) << "DrmBuffer: MapDumbBuffer: handle " << handle_;
83 return false; 64 return false;
84 } 65 }
85 66
86 if (should_register_framebuffer) { 67 if (should_register_framebuffer) {
87 if (!drm_->AddFramebuffer( 68 uint32_t handles[4] = {0};
88 info.width(), info.height(), GetColorDepth(info.colorType()), 69 handles[0] = handle_;
89 info.bytesPerPixel() << 3, stride_, handle_, &framebuffer_)) { 70 uint32_t strides[4] = {0};
90 PLOG(ERROR) << "DrmBuffer: AddFramebuffer: handle " << handle_; 71 strides[0] = stride_;
72 uint32_t offsets[4] = {0};
73 fb_pixel_format_ = GetFourCCCodeForSkColorType(info.colorType());
74 if (!drm_->AddFramebuffer2(info.width(), info.height(), fb_pixel_format_,
75 handles, strides, offsets, &framebuffer_, 0)) {
76 PLOG(ERROR) << "DrmBuffer: AddFramebuffer2: handle " << handle_;
91 return false; 77 return false;
92 } 78 }
93
94 fb_pixel_format_ = GetFourCCCodeForSkColorType(info.colorType());
95 } 79 }
96 80
97 surface_ = 81 surface_ =
98 skia::AdoptRef(SkSurface::NewRasterDirect(info, mmap_base_, stride_)); 82 skia::AdoptRef(SkSurface::NewRasterDirect(info, mmap_base_, stride_));
99 if (!surface_) { 83 if (!surface_) {
100 LOG(ERROR) << "DrmBuffer: Failed to create SkSurface: handle " << handle_; 84 LOG(ERROR) << "DrmBuffer: Failed to create SkSurface: handle " << handle_;
101 return false; 85 return false;
102 } 86 }
103 87
104 return true; 88 return true;
(...skipping 17 matching lines...) Expand all
122 106
123 gfx::Size DrmBuffer::GetSize() const { 107 gfx::Size DrmBuffer::GetSize() const {
124 return gfx::Size(surface_->width(), surface_->height()); 108 return gfx::Size(surface_->width(), surface_->height());
125 } 109 }
126 110
127 bool DrmBuffer::RequiresGlFinish() const { 111 bool DrmBuffer::RequiresGlFinish() const {
128 return false; 112 return false;
129 } 113 }
130 114
131 } // namespace ui 115 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698