OLD | NEW |
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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 | 72 |
73 surface_ = skia::AdoptRef(SkSurface::NewRasterDirect(info, pixels, stride_)); | 73 surface_ = skia::AdoptRef(SkSurface::NewRasterDirect(info, pixels, stride_)); |
74 if (!surface_) { | 74 if (!surface_) { |
75 VLOG(2) << "Cannot install Skia pixels for drm buffer"; | 75 VLOG(2) << "Cannot install Skia pixels for drm buffer"; |
76 return false; | 76 return false; |
77 } | 77 } |
78 | 78 |
79 return true; | 79 return true; |
80 } | 80 } |
81 | 81 |
| 82 SkCanvas* DriBuffer::GetCanvas() const { |
| 83 return surface_->getCanvas(); |
| 84 } |
| 85 |
| 86 uint32_t DriBuffer::GetFramebufferId() const { |
| 87 return framebuffer_; |
| 88 } |
| 89 |
| 90 uint32_t DriBuffer::GetHandle() const { |
| 91 return handle_; |
| 92 } |
| 93 |
| 94 gfx::Size DriBuffer::GetSize() const { |
| 95 return gfx::Size(surface_->width(), surface_->height()); |
| 96 } |
| 97 |
| 98 DriBufferGenerator::DriBufferGenerator(DriWrapper* dri) : dri_(dri) {} |
| 99 |
| 100 DriBufferGenerator::~DriBufferGenerator() {} |
| 101 |
| 102 scoped_refptr<ScanoutBuffer> DriBufferGenerator::Create(const gfx::Size& size) { |
| 103 scoped_refptr<DriBuffer> buffer(new DriBuffer(dri_)); |
| 104 SkImageInfo info = SkImageInfo::MakeN32Premul(size.width(), size.height()); |
| 105 if (!buffer->Initialize(info)) |
| 106 return NULL; |
| 107 |
| 108 return buffer; |
| 109 } |
| 110 |
82 } // namespace ui | 111 } // namespace ui |
OLD | NEW |