| 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/demo/surfaceless_gl_renderer.h" | 5 #include "ui/ozone/demo/surfaceless_gl_renderer.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 gfx::AcceleratedWidget widget, | 37 gfx::AcceleratedWidget widget, |
| 38 const gfx::Size& size) { | 38 const gfx::Size& size) { |
| 39 glGenFramebuffersEXT(1, &gl_fb_); | 39 glGenFramebuffersEXT(1, &gl_fb_); |
| 40 glGenTextures(1, &gl_tex_); | 40 glGenTextures(1, &gl_tex_); |
| 41 | 41 |
| 42 scoped_refptr<NativePixmap> pixmap = | 42 scoped_refptr<NativePixmap> pixmap = |
| 43 OzonePlatform::GetInstance() | 43 OzonePlatform::GetInstance() |
| 44 ->GetSurfaceFactoryOzone() | 44 ->GetSurfaceFactoryOzone() |
| 45 ->CreateNativePixmap(widget, size, gfx::BufferFormat::BGRX_8888, | 45 ->CreateNativePixmap(widget, size, gfx::BufferFormat::BGRX_8888, |
| 46 gfx::BufferUsage::SCANOUT); | 46 gfx::BufferUsage::SCANOUT); |
| 47 scoped_refptr<gfx::GLImageOzoneNativePixmap> image( | 47 scoped_refptr<gl::GLImageOzoneNativePixmap> image( |
| 48 new gfx::GLImageOzoneNativePixmap(size, GL_RGB)); | 48 new gl::GLImageOzoneNativePixmap(size, GL_RGB)); |
| 49 if (!image->Initialize(pixmap.get(), gfx::BufferFormat::BGRX_8888)) { | 49 if (!image->Initialize(pixmap.get(), gfx::BufferFormat::BGRX_8888)) { |
| 50 LOG(ERROR) << "Failed to create GLImage"; | 50 LOG(ERROR) << "Failed to create GLImage"; |
| 51 return false; | 51 return false; |
| 52 } | 52 } |
| 53 image_ = image; | 53 image_ = image; |
| 54 | 54 |
| 55 glBindFramebufferEXT(GL_FRAMEBUFFER, gl_fb_); | 55 glBindFramebufferEXT(GL_FRAMEBUFFER, gl_fb_); |
| 56 glBindTexture(GL_TEXTURE_2D, gl_tex_); | 56 glBindTexture(GL_TEXTURE_2D, gl_tex_); |
| 57 image_->BindTexImage(GL_TEXTURE_2D); | 57 image_->BindTexImage(GL_TEXTURE_2D); |
| 58 | 58 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 69 | 69 |
| 70 return true; | 70 return true; |
| 71 } | 71 } |
| 72 | 72 |
| 73 void SurfacelessGlRenderer::BufferWrapper::BindFramebuffer() { | 73 void SurfacelessGlRenderer::BufferWrapper::BindFramebuffer() { |
| 74 glBindFramebufferEXT(GL_FRAMEBUFFER, gl_fb_); | 74 glBindFramebufferEXT(GL_FRAMEBUFFER, gl_fb_); |
| 75 } | 75 } |
| 76 | 76 |
| 77 SurfacelessGlRenderer::SurfacelessGlRenderer( | 77 SurfacelessGlRenderer::SurfacelessGlRenderer( |
| 78 gfx::AcceleratedWidget widget, | 78 gfx::AcceleratedWidget widget, |
| 79 const scoped_refptr<gfx::GLSurface>& surface, | 79 const scoped_refptr<gl::GLSurface>& surface, |
| 80 const gfx::Size& size) | 80 const gfx::Size& size) |
| 81 : GlRenderer(widget, surface, size), weak_ptr_factory_(this) {} | 81 : GlRenderer(widget, surface, size), weak_ptr_factory_(this) {} |
| 82 | 82 |
| 83 SurfacelessGlRenderer::~SurfacelessGlRenderer() { | 83 SurfacelessGlRenderer::~SurfacelessGlRenderer() { |
| 84 // Need to make current when deleting the framebuffer resources allocated in | 84 // Need to make current when deleting the framebuffer resources allocated in |
| 85 // the buffers. | 85 // the buffers. |
| 86 context_->MakeCurrent(surface_.get()); | 86 context_->MakeCurrent(surface_.get()); |
| 87 } | 87 } |
| 88 | 88 |
| 89 bool SurfacelessGlRenderer::Initialize() { | 89 bool SurfacelessGlRenderer::Initialize() { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 case gfx::SwapResult::SWAP_ACK: | 133 case gfx::SwapResult::SWAP_ACK: |
| 134 GlRenderer::PostRenderFrameTask(result); | 134 GlRenderer::PostRenderFrameTask(result); |
| 135 break; | 135 break; |
| 136 case gfx::SwapResult::SWAP_FAILED: | 136 case gfx::SwapResult::SWAP_FAILED: |
| 137 LOG(FATAL) << "Failed to swap buffers"; | 137 LOG(FATAL) << "Failed to swap buffers"; |
| 138 break; | 138 break; |
| 139 } | 139 } |
| 140 } | 140 } |
| 141 | 141 |
| 142 } // namespace ui | 142 } // namespace ui |
| OLD | NEW |