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

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

Issue 959953002: [Ozone-Dri] Do not call AddFramebuffer with cursor buffers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: renamed param Created 5 years, 9 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
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/dri/dri_buffer.h" 5 #include "ui/ozone/platform/dri/dri_buffer.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "ui/ozone/platform/dri/dri_wrapper.h" 8 #include "ui/ozone/platform/dri/dri_wrapper.h"
9 9
10 namespace ui { 10 namespace ui {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 dri_->RemoveFramebuffer(framebuffer_); 46 dri_->RemoveFramebuffer(framebuffer_);
47 47
48 SkImageInfo info; 48 SkImageInfo info;
49 void* pixels = const_cast<void*>(surface_->peekPixels(&info, NULL)); 49 void* pixels = const_cast<void*>(surface_->peekPixels(&info, NULL));
50 if (!pixels) 50 if (!pixels)
51 return; 51 return;
52 52
53 dri_->DestroyDumbBuffer(info, handle_, stride_, pixels); 53 dri_->DestroyDumbBuffer(info, handle_, stride_, pixels);
54 } 54 }
55 55
56 bool DriBuffer::Initialize(const SkImageInfo& info) { 56 bool DriBuffer::Initialize(const SkImageInfo& info,
57 bool should_register_framebuffer) {
57 void* pixels = NULL; 58 void* pixels = NULL;
58 if (!dri_->CreateDumbBuffer(info, &handle_, &stride_, &pixels)) { 59 if (!dri_->CreateDumbBuffer(info, &handle_, &stride_, &pixels)) {
59 VLOG(2) << "Cannot create drm dumb buffer"; 60 VLOG(2) << "Cannot create drm dumb buffer";
60 return false; 61 return false;
61 } 62 }
62 63
63 if (!dri_->AddFramebuffer(info.width(), 64 if (should_register_framebuffer &&
64 info.height(), 65 !dri_->AddFramebuffer(
65 GetColorDepth(info.colorType()), 66 info.width(), info.height(), GetColorDepth(info.colorType()),
66 info.bytesPerPixel() << 3, 67 info.bytesPerPixel() << 3, stride_, handle_, &framebuffer_)) {
67 stride_,
68 handle_,
69 &framebuffer_)) {
70 VLOG(2) << "Failed to register framebuffer: " << strerror(errno); 68 VLOG(2) << "Failed to register framebuffer: " << strerror(errno);
71 return false; 69 return false;
72 } 70 }
73 71
74 surface_ = skia::AdoptRef(SkSurface::NewRasterDirect(info, pixels, stride_)); 72 surface_ = skia::AdoptRef(SkSurface::NewRasterDirect(info, pixels, stride_));
75 if (!surface_) { 73 if (!surface_) {
76 VLOG(2) << "Cannot install Skia pixels for drm buffer"; 74 VLOG(2) << "Cannot install Skia pixels for drm buffer";
77 return false; 75 return false;
78 } 76 }
79 77
(...skipping 19 matching lines...) Expand all
99 DriBufferGenerator::DriBufferGenerator() { 97 DriBufferGenerator::DriBufferGenerator() {
100 } 98 }
101 99
102 DriBufferGenerator::~DriBufferGenerator() {} 100 DriBufferGenerator::~DriBufferGenerator() {}
103 101
104 scoped_refptr<ScanoutBuffer> DriBufferGenerator::Create( 102 scoped_refptr<ScanoutBuffer> DriBufferGenerator::Create(
105 const scoped_refptr<DriWrapper>& drm, 103 const scoped_refptr<DriWrapper>& drm,
106 const gfx::Size& size) { 104 const gfx::Size& size) {
107 scoped_refptr<DriBuffer> buffer(new DriBuffer(drm)); 105 scoped_refptr<DriBuffer> buffer(new DriBuffer(drm));
108 SkImageInfo info = SkImageInfo::MakeN32Premul(size.width(), size.height()); 106 SkImageInfo info = SkImageInfo::MakeN32Premul(size.width(), size.height());
109 if (!buffer->Initialize(info)) 107 if (!buffer->Initialize(info, true))
110 return NULL; 108 return NULL;
111 109
112 return buffer; 110 return buffer;
113 } 111 }
114 112
115 } // namespace ui 113 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698