| OLD | NEW |
| 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 #include "ui/gl/gl_surface.h" | 5 #include "ui/gl/gl_surface.h" |
| 6 | 6 |
| 7 #include <stdint.h> |
| 8 |
| 7 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/macros.h" |
| 8 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 10 #include "base/trace_event/trace_event.h" | 13 #include "base/trace_event/trace_event.h" |
| 11 #include "ui/gfx/native_widget_types.h" | 14 #include "ui/gfx/native_widget_types.h" |
| 12 #include "ui/gfx/x/x11_types.h" | 15 #include "ui/gfx/x/x11_types.h" |
| 13 #include "ui/gl/gl_bindings.h" | 16 #include "ui/gl/gl_bindings.h" |
| 14 #include "ui/gl/gl_implementation.h" | 17 #include "ui/gl/gl_implementation.h" |
| 15 #include "ui/gl/gl_surface_egl.h" | 18 #include "ui/gl/gl_surface_egl.h" |
| 16 #include "ui/gl/gl_surface_egl_x11.h" | 19 #include "ui/gl/gl_surface_egl_x11.h" |
| 17 #include "ui/gl/gl_surface_glx.h" | 20 #include "ui/gl/gl_surface_glx.h" |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 | 196 |
| 194 gfx::Size size = GetSize(); | 197 gfx::Size size = GetSize(); |
| 195 | 198 |
| 196 XWindowAttributes attributes; | 199 XWindowAttributes attributes; |
| 197 if (!XGetWindowAttributes(xdisplay_, window_, &attributes)) { | 200 if (!XGetWindowAttributes(xdisplay_, window_, &attributes)) { |
| 198 LOG(ERROR) << "XGetWindowAttributes failed for window " << window_ << "."; | 201 LOG(ERROR) << "XGetWindowAttributes failed for window " << window_ << "."; |
| 199 return gfx::SwapResult::SWAP_FAILED; | 202 return gfx::SwapResult::SWAP_FAILED; |
| 200 } | 203 } |
| 201 | 204 |
| 202 // Copy the frame into the pixmap. | 205 // Copy the frame into the pixmap. |
| 203 gfx::PutARGBImage(xdisplay_, | 206 gfx::PutARGBImage(xdisplay_, attributes.visual, attributes.depth, pixmap_, |
| 204 attributes.visual, | |
| 205 attributes.depth, | |
| 206 pixmap_, | |
| 207 pixmap_graphics_context_, | 207 pixmap_graphics_context_, |
| 208 static_cast<const uint8*>(GetHandle()), | 208 static_cast<const uint8_t*>(GetHandle()), size.width(), |
| 209 size.width(), | |
| 210 size.height()); | 209 size.height()); |
| 211 | 210 |
| 212 // Copy the pixmap to the window. | 211 // Copy the pixmap to the window. |
| 213 XCopyArea(xdisplay_, | 212 XCopyArea(xdisplay_, |
| 214 pixmap_, | 213 pixmap_, |
| 215 window_, | 214 window_, |
| 216 window_graphics_context_, | 215 window_graphics_context_, |
| 217 0, | 216 0, |
| 218 0, | 217 0, |
| 219 size.width(), | 218 size.width(), |
| (...skipping 17 matching lines...) Expand all Loading... |
| 237 // Move (0,0) from lower-left to upper-left | 236 // Move (0,0) from lower-left to upper-left |
| 238 y = size.height() - y - height; | 237 y = size.height() - y - height; |
| 239 | 238 |
| 240 XWindowAttributes attributes; | 239 XWindowAttributes attributes; |
| 241 if (!XGetWindowAttributes(xdisplay_, window_, &attributes)) { | 240 if (!XGetWindowAttributes(xdisplay_, window_, &attributes)) { |
| 242 LOG(ERROR) << "XGetWindowAttributes failed for window " << window_ << "."; | 241 LOG(ERROR) << "XGetWindowAttributes failed for window " << window_ << "."; |
| 243 return gfx::SwapResult::SWAP_FAILED; | 242 return gfx::SwapResult::SWAP_FAILED; |
| 244 } | 243 } |
| 245 | 244 |
| 246 // Copy the frame into the pixmap. | 245 // Copy the frame into the pixmap. |
| 247 gfx::PutARGBImage(xdisplay_, | 246 gfx::PutARGBImage(xdisplay_, attributes.visual, attributes.depth, pixmap_, |
| 248 attributes.visual, | |
| 249 attributes.depth, | |
| 250 pixmap_, | |
| 251 pixmap_graphics_context_, | 247 pixmap_graphics_context_, |
| 252 static_cast<const uint8*>(GetHandle()), | 248 static_cast<const uint8_t*>(GetHandle()), size.width(), |
| 253 size.width(), | 249 size.height(), x, y, x, y, width, height); |
| 254 size.height(), | |
| 255 x, | |
| 256 y, | |
| 257 x, | |
| 258 y, | |
| 259 width, | |
| 260 height); | |
| 261 | 250 |
| 262 // Copy the pixmap to the window. | 251 // Copy the pixmap to the window. |
| 263 XCopyArea(xdisplay_, | 252 XCopyArea(xdisplay_, |
| 264 pixmap_, | 253 pixmap_, |
| 265 window_, | 254 window_, |
| 266 window_graphics_context_, | 255 window_graphics_context_, |
| 267 x, | 256 x, |
| 268 y, | 257 y, |
| 269 width, | 258 width, |
| 270 height, | 259 height, |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 NOTREACHED(); | 335 NOTREACHED(); |
| 347 return NULL; | 336 return NULL; |
| 348 } | 337 } |
| 349 } | 338 } |
| 350 | 339 |
| 351 EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay() { | 340 EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay() { |
| 352 return gfx::GetXDisplay(); | 341 return gfx::GetXDisplay(); |
| 353 } | 342 } |
| 354 | 343 |
| 355 } // namespace gfx | 344 } // namespace gfx |
| OLD | NEW |