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

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

Issue 1418603002: Revert of Re-land: ui: Move GLImage::BindTexImage fallback from GLImage implementations to GLES2CmdDecoder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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_glx.h ('k') | ui/gl/gl_image_io_surface.h » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 extern "C" { 5 extern "C" {
6 #include <X11/Xlib.h> 6 #include <X11/Xlib.h>
7 } 7 }
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "ui/gl/gl_bindings.h" 11 #include "ui/gl/gl_bindings.h"
12 #include "ui/gl/gl_image_glx.h" 12 #include "ui/gl/gl_image_glx.h"
13 #include "ui/gl/gl_surface_glx.h" 13 #include "ui/gl/gl_surface_glx.h"
14 14
15 namespace gfx { 15 namespace gfx {
16
16 namespace { 17 namespace {
17 18
18 bool ValidFormat(unsigned internalformat) { 19 bool ValidFormat(unsigned internalformat) {
19 switch (internalformat) { 20 switch (internalformat) {
20 case GL_RGB: 21 case GL_RGB:
21 case GL_RGBA: 22 case GL_RGBA:
22 return true; 23 return true;
23 default: 24 default:
24 return false; 25 return false;
25 } 26 }
(...skipping 28 matching lines...) Expand all
54 case GL_RGBA: 55 case GL_RGBA:
55 return 32u; 56 return 32u;
56 case GL_RGB: 57 case GL_RGB:
57 return 24u; 58 return 24u;
58 default: 59 default:
59 NOTREACHED(); 60 NOTREACHED();
60 return 0u; 61 return 0u;
61 } 62 }
62 } 63 }
63 64
64 bool ActualPixmapGeometry(XID pixmap, Size* size, unsigned* depth) { 65 bool ActualPixmapGeometry(XID pixmap, gfx::Size* size, unsigned* depth) {
65 XID root_return; 66 XID root_return;
66 int x_return; 67 int x_return;
67 int y_return; 68 int y_return;
68 unsigned width_return; 69 unsigned width_return;
69 unsigned height_return; 70 unsigned height_return;
70 unsigned border_width_return; 71 unsigned border_width_return;
71 unsigned depth_return; 72 unsigned depth_return;
72 if (!XGetGeometry(GetXDisplay(), pixmap, &root_return, &x_return, &y_return, 73 if (!XGetGeometry(gfx::GetXDisplay(),
73 &width_return, &height_return, &border_width_return, 74 pixmap,
75 &root_return,
76 &x_return,
77 &y_return,
78 &width_return,
79 &height_return,
80 &border_width_return,
74 &depth_return)) 81 &depth_return))
75 return false; 82 return false;
76 83
77 if (size) 84 if (size)
78 *size = Size(width_return, height_return); 85 *size = gfx::Size(width_return, height_return);
79 if (depth) 86 if (depth)
80 *depth = depth_return; 87 *depth = depth_return;
81 return true; 88 return true;
82 } 89 }
83 90
84 unsigned ActualPixmapDepth(XID pixmap) { 91 unsigned ActualPixmapDepth(XID pixmap) {
85 unsigned depth; 92 unsigned depth;
86 if (!ActualPixmapGeometry(pixmap, NULL, &depth)) 93 if (!ActualPixmapGeometry(pixmap, NULL, &depth))
87 return -1; 94 return -1;
88 95
89 return depth; 96 return depth;
90 } 97 }
91 98
92 Size ActualPixmapSize(XID pixmap) { 99 gfx::Size ActualPixmapSize(XID pixmap) {
93 Size size; 100 gfx::Size size;
94 if (!ActualPixmapGeometry(pixmap, &size, NULL)) 101 if (!ActualPixmapGeometry(pixmap, &size, NULL))
95 return Size(); 102 return gfx::Size();
96 103
97 return size; 104 return size;
98 } 105 }
99 106
100 } // namespace 107 } // namespace anonymous
101 108
102 GLImageGLX::GLImageGLX(const Size& size, unsigned internalformat) 109 GLImageGLX::GLImageGLX(const gfx::Size& size, unsigned internalformat)
103 : glx_pixmap_(0), size_(size), internalformat_(internalformat) {} 110 : glx_pixmap_(0), size_(size), internalformat_(internalformat) {
111 }
104 112
105 GLImageGLX::~GLImageGLX() { 113 GLImageGLX::~GLImageGLX() {
106 DCHECK_EQ(0u, glx_pixmap_); 114 DCHECK_EQ(0u, glx_pixmap_);
107 } 115 }
108 116
109 bool GLImageGLX::Initialize(XID pixmap) { 117 bool GLImageGLX::Initialize(XID pixmap) {
110 if (!GLSurfaceGLX::IsTextureFromPixmapSupported()) { 118 if (!GLSurfaceGLX::IsTextureFromPixmapSupported()) {
111 DVLOG(0) << "GLX_EXT_texture_from_pixmap not supported."; 119 DVLOG(0) << "GLX_EXT_texture_from_pixmap not supported.";
112 return false; 120 return false;
113 } 121 }
114 122
115 if (!ValidFormat(internalformat_)) { 123 if (!ValidFormat(internalformat_)) {
116 DVLOG(0) << "Invalid format: " << internalformat_; 124 DVLOG(0) << "Invalid format: " << internalformat_;
117 return false; 125 return false;
118 } 126 }
119 127
120 DCHECK_EQ(PixmapDepth(internalformat_), ActualPixmapDepth(pixmap)); 128 DCHECK_EQ(PixmapDepth(internalformat_), ActualPixmapDepth(pixmap));
121 DCHECK_EQ(size_.ToString(), ActualPixmapSize(pixmap).ToString()); 129 DCHECK_EQ(size_.ToString(), ActualPixmapSize(pixmap).ToString());
122 130
123 int config_attribs[] = { 131 int config_attribs[] = {
124 GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT, 132 GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT,
125 GLX_BIND_TO_TEXTURE_TARGETS_EXT, GLX_TEXTURE_2D_EXT, 133 GLX_BIND_TO_TEXTURE_TARGETS_EXT, GLX_TEXTURE_2D_EXT,
126 BindToTextureFormat(internalformat_), GL_TRUE, 134 BindToTextureFormat(internalformat_), GL_TRUE,
127 0}; 135 0};
128 int num_elements = 0; 136 int num_elements = 0;
129 XScopedPtr<GLXFBConfig> config( 137 gfx::XScopedPtr<GLXFBConfig> config(
130 glXChooseFBConfig(GetXDisplay(), DefaultScreen(GetXDisplay()), 138 glXChooseFBConfig(gfx::GetXDisplay(), DefaultScreen(gfx::GetXDisplay()),
131 config_attribs, &num_elements)); 139 config_attribs, &num_elements));
132 if (!config.get()) { 140 if (!config.get()) {
133 DVLOG(0) << "glXChooseFBConfig failed."; 141 DVLOG(0) << "glXChooseFBConfig failed.";
134 return false; 142 return false;
135 } 143 }
136 if (!num_elements) { 144 if (!num_elements) {
137 DVLOG(0) << "glXChooseFBConfig returned 0 elements."; 145 DVLOG(0) << "glXChooseFBConfig returned 0 elements.";
138 return false; 146 return false;
139 } 147 }
140 148
141 int pixmap_attribs[] = {GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT, 149 int pixmap_attribs[] = {GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT,
142 GLX_TEXTURE_FORMAT_EXT, 150 GLX_TEXTURE_FORMAT_EXT,
143 TextureFormat(internalformat_), 0}; 151 TextureFormat(internalformat_), 0};
144 glx_pixmap_ = 152 glx_pixmap_ = glXCreatePixmap(
145 glXCreatePixmap(GetXDisplay(), *config.get(), pixmap, pixmap_attribs); 153 gfx::GetXDisplay(), *config.get(), pixmap, pixmap_attribs);
146 if (!glx_pixmap_) { 154 if (!glx_pixmap_) {
147 DVLOG(0) << "glXCreatePixmap failed."; 155 DVLOG(0) << "glXCreatePixmap failed.";
148 return false; 156 return false;
149 } 157 }
150 158
151 return true; 159 return true;
152 } 160 }
153 161
154 void GLImageGLX::Destroy(bool have_context) { 162 void GLImageGLX::Destroy(bool have_context) {
155 if (glx_pixmap_) { 163 if (glx_pixmap_) {
156 glXDestroyGLXPixmap(GetXDisplay(), glx_pixmap_); 164 glXDestroyGLXPixmap(gfx::GetXDisplay(), glx_pixmap_);
157 glx_pixmap_ = 0; 165 glx_pixmap_ = 0;
158 } 166 }
159 } 167 }
160 168
161 Size GLImageGLX::GetSize() { 169 gfx::Size GLImageGLX::GetSize() { return size_; }
162 return size_;
163 }
164 170
165 unsigned GLImageGLX::GetInternalFormat() { return internalformat_; } 171 unsigned GLImageGLX::GetInternalFormat() { return internalformat_; }
166 172
167 bool GLImageGLX::BindTexImage(unsigned target) { 173 bool GLImageGLX::BindTexImage(unsigned target) {
168 if (!glx_pixmap_) 174 if (!glx_pixmap_)
169 return false; 175 return false;
170 176
171 // Requires TEXTURE_2D target. 177 // Requires TEXTURE_2D target.
172 if (target != GL_TEXTURE_2D) 178 if (target != GL_TEXTURE_2D)
173 return false; 179 return false;
174 180
175 glXBindTexImageEXT(GetXDisplay(), glx_pixmap_, GLX_FRONT_LEFT_EXT, 0); 181 glXBindTexImageEXT(gfx::GetXDisplay(), glx_pixmap_, GLX_FRONT_LEFT_EXT, 0);
176 return true; 182 return true;
177 } 183 }
178 184
179 void GLImageGLX::ReleaseTexImage(unsigned target) { 185 void GLImageGLX::ReleaseTexImage(unsigned target) {
180 DCHECK_NE(0u, glx_pixmap_); 186 DCHECK_NE(0u, glx_pixmap_);
181 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), target); 187 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), target);
182 188
183 glXReleaseTexImageEXT(GetXDisplay(), glx_pixmap_, GLX_FRONT_LEFT_EXT); 189 glXReleaseTexImageEXT(gfx::GetXDisplay(), glx_pixmap_, GLX_FRONT_LEFT_EXT);
184 }
185
186 bool GLImageGLX::CopyTexImage(unsigned target) {
187 return false;
188 } 190 }
189 191
190 bool GLImageGLX::CopyTexSubImage(unsigned target, 192 bool GLImageGLX::CopyTexSubImage(unsigned target,
191 const Point& offset, 193 const Point& offset,
192 const Rect& rect) { 194 const Rect& rect) {
193 return false; 195 return false;
194 } 196 }
195 197
196 bool GLImageGLX::ScheduleOverlayPlane(AcceleratedWidget widget, 198 bool GLImageGLX::ScheduleOverlayPlane(gfx::AcceleratedWidget widget,
197 int z_order, 199 int z_order,
198 OverlayTransform transform, 200 OverlayTransform transform,
199 const Rect& bounds_rect, 201 const Rect& bounds_rect,
200 const RectF& crop_rect) { 202 const RectF& crop_rect) {
201 return false; 203 return false;
202 } 204 }
203 205
204 void GLImageGLX::OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd, 206 void GLImageGLX::OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd,
205 uint64_t process_tracing_id, 207 uint64_t process_tracing_id,
206 const std::string& dump_name) { 208 const std::string& dump_name) {
207 // TODO(ericrk): Implement GLImage OnMemoryDump. crbug.com/514914 209 // TODO(ericrk): Implement GLImage OnMemoryDump. crbug.com/514914
208 } 210 }
209 211
210 } // namespace gfx 212 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gl/gl_image_glx.h ('k') | ui/gl/gl_image_io_surface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698