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

Side by Side Diff: ui/gl/gl_image_ozone_native_pixmap.cc

Issue 2014223002: Follow-up fixes to changing namespace gfx to gl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 6 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/gl/gl_image_ozone_native_pixmap.h ('k') | ui/gl/gl_image_ozone_native_pixmap_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/gfx/buffer_format_util.h" 5 #include "ui/gfx/buffer_format_util.h"
6 #include "ui/gl/gl_image_ozone_native_pixmap.h" 6 #include "ui/gl/gl_image_ozone_native_pixmap.h"
7 7
8 #define FOURCC(a, b, c, d) \ 8 #define FOURCC(a, b, c, d) \
9 ((static_cast<uint32_t>(a)) | (static_cast<uint32_t>(b) << 8) | \ 9 ((static_cast<uint32_t>(a)) | (static_cast<uint32_t>(b) << 8) | \
10 (static_cast<uint32_t>(c) << 16) | (static_cast<uint32_t>(d) << 24)) 10 (static_cast<uint32_t>(c) << 16) | (static_cast<uint32_t>(d) << 24))
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 } 84 }
85 85
86 NOTREACHED(); 86 NOTREACHED();
87 return 0; 87 return 0;
88 } 88 }
89 89
90 } // namespace 90 } // namespace
91 91
92 GLImageOzoneNativePixmap::GLImageOzoneNativePixmap(const gfx::Size& size, 92 GLImageOzoneNativePixmap::GLImageOzoneNativePixmap(const gfx::Size& size,
93 unsigned internalformat) 93 unsigned internalformat)
94 : gl::GLImageEGL(size), internalformat_(internalformat) {} 94 : GLImageEGL(size), internalformat_(internalformat) {}
95 95
96 GLImageOzoneNativePixmap::~GLImageOzoneNativePixmap() { 96 GLImageOzoneNativePixmap::~GLImageOzoneNativePixmap() {
97 } 97 }
98 98
99 bool GLImageOzoneNativePixmap::Initialize(ui::NativePixmap* pixmap, 99 bool GLImageOzoneNativePixmap::Initialize(ui::NativePixmap* pixmap,
100 gfx::BufferFormat format) { 100 gfx::BufferFormat format) {
101 DCHECK(!pixmap_); 101 DCHECK(!pixmap_);
102 if (pixmap->GetEGLClientBuffer()) { 102 if (pixmap->GetEGLClientBuffer()) {
103 EGLint attrs[] = {EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE}; 103 EGLint attrs[] = {EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE};
104 if (!gl::GLImageEGL::Initialize(EGL_NATIVE_PIXMAP_KHR, 104 if (!GLImageEGL::Initialize(EGL_NATIVE_PIXMAP_KHR,
105 pixmap->GetEGLClientBuffer(), attrs)) { 105 pixmap->GetEGLClientBuffer(), attrs)) {
106 return false; 106 return false;
107 } 107 }
108 } else if (pixmap->AreDmaBufFdsValid()) { 108 } else if (pixmap->AreDmaBufFdsValid()) {
109 if (!ValidInternalFormat(internalformat_)) { 109 if (!ValidInternalFormat(internalformat_)) {
110 LOG(ERROR) << "Invalid internalformat: " << internalformat_; 110 LOG(ERROR) << "Invalid internalformat: " << internalformat_;
111 return false; 111 return false;
112 } 112 }
113 113
114 if (!ValidFormat(format)) { 114 if (!ValidFormat(format)) {
115 LOG(ERROR) << "Invalid format: " << static_cast<int>(format); 115 LOG(ERROR) << "Invalid format: " << static_cast<int>(format);
(...skipping 15 matching lines...) Expand all
131 ++plane) { 131 ++plane) {
132 attrs.push_back(EGL_DMA_BUF_PLANE0_FD_EXT + plane * 3); 132 attrs.push_back(EGL_DMA_BUF_PLANE0_FD_EXT + plane * 3);
133 attrs.push_back(pixmap->GetDmaBufFd(plane)); 133 attrs.push_back(pixmap->GetDmaBufFd(plane));
134 attrs.push_back(EGL_DMA_BUF_PLANE0_OFFSET_EXT + plane * 3); 134 attrs.push_back(EGL_DMA_BUF_PLANE0_OFFSET_EXT + plane * 3);
135 attrs.push_back(0); 135 attrs.push_back(0);
136 attrs.push_back(EGL_DMA_BUF_PLANE0_PITCH_EXT + plane * 3); 136 attrs.push_back(EGL_DMA_BUF_PLANE0_PITCH_EXT + plane * 3);
137 attrs.push_back(pixmap->GetDmaBufPitch(plane)); 137 attrs.push_back(pixmap->GetDmaBufPitch(plane));
138 } 138 }
139 attrs.push_back(EGL_NONE); 139 attrs.push_back(EGL_NONE);
140 140
141 if (!gl::GLImageEGL::Initialize(EGL_LINUX_DMA_BUF_EXT, 141 if (!GLImageEGL::Initialize(EGL_LINUX_DMA_BUF_EXT,
142 static_cast<EGLClientBuffer>(nullptr), 142 static_cast<EGLClientBuffer>(nullptr),
143 &attrs[0])) { 143 &attrs[0])) {
144 return false; 144 return false;
145 } 145 }
146 } 146 }
147 147
148 pixmap_ = pixmap; 148 pixmap_ = pixmap;
149 return true; 149 return true;
150 } 150 }
151 151
152 unsigned GLImageOzoneNativePixmap::GetInternalFormat() { 152 unsigned GLImageOzoneNativePixmap::GetInternalFormat() {
153 return internalformat_; 153 return internalformat_;
154 } 154 }
155 155
156 void GLImageOzoneNativePixmap::Destroy(bool have_context) { 156 void GLImageOzoneNativePixmap::Destroy(bool have_context) {
157 gl::GLImageEGL::Destroy(have_context); 157 GLImageEGL::Destroy(have_context);
158 } 158 }
159 159
160 bool GLImageOzoneNativePixmap::CopyTexImage(unsigned target) { 160 bool GLImageOzoneNativePixmap::CopyTexImage(unsigned target) {
161 if (egl_image_ == EGL_NO_IMAGE_KHR) { 161 if (egl_image_ == EGL_NO_IMAGE_KHR) {
162 // Pass-through image type fails to bind and copy; make sure we 162 // Pass-through image type fails to bind and copy; make sure we
163 // don't draw with uninitialized texture. 163 // don't draw with uninitialized texture.
164 std::vector<unsigned char> data(size_.width() * size_.height() * 4); 164 std::vector<unsigned char> data(size_.width() * size_.height() * 4);
165 glTexImage2D(target, 0, GL_RGBA, size_.width(), 165 glTexImage2D(target, 0, GL_RGBA, size_.width(),
166 size_.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, 166 size_.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE,
167 data.data()); 167 data.data());
(...skipping 14 matching lines...) Expand all
182 } 182 }
183 183
184 void GLImageOzoneNativePixmap::OnMemoryDump( 184 void GLImageOzoneNativePixmap::OnMemoryDump(
185 base::trace_event::ProcessMemoryDump* pmd, 185 base::trace_event::ProcessMemoryDump* pmd,
186 uint64_t process_tracing_id, 186 uint64_t process_tracing_id,
187 const std::string& dump_name) { 187 const std::string& dump_name) {
188 // TODO(ericrk): Implement GLImage OnMemoryDump. crbug.com/514914 188 // TODO(ericrk): Implement GLImage OnMemoryDump. crbug.com/514914
189 } 189 }
190 190
191 } // namespace gl 191 } // namespace gl
OLDNEW
« no previous file with comments | « ui/gl/gl_image_ozone_native_pixmap.h ('k') | ui/gl/gl_image_ozone_native_pixmap_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698