| 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 "base/logging.h" | 5 #include "base/logging.h" |
| 6 #include "base/numerics/safe_math.h" | 6 #include "base/numerics/safe_math.h" |
| 7 #include "third_party/mesa/src/include/GL/osmesa.h" | 7 #include "third_party/mesa/src/include/GL/osmesa.h" |
| 8 #include "ui/gl/gl_bindings.h" | 8 #include "ui/gl/gl_bindings.h" |
| 9 #include "ui/gl/gl_context.h" | 9 #include "ui/gl/gl_context.h" |
| 10 #include "ui/gl/gl_surface_osmesa.h" | 10 #include "ui/gl/gl_surface_osmesa.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 format_ = OSMESA_RGBA; | 23 format_ = OSMESA_RGBA; |
| 24 break; | 24 break; |
| 25 } | 25 } |
| 26 // Implementations of OSMesa surface do not support having a 0 size. In such | 26 // Implementations of OSMesa surface do not support having a 0 size. In such |
| 27 // cases use a (1, 1) surface. | 27 // cases use a (1, 1) surface. |
| 28 if (size_.GetArea() == 0) | 28 if (size_.GetArea() == 0) |
| 29 size_.SetSize(1, 1); | 29 size_.SetSize(1, 1); |
| 30 } | 30 } |
| 31 | 31 |
| 32 bool GLSurfaceOSMesa::Initialize() { | 32 bool GLSurfaceOSMesa::Initialize() { |
| 33 return Resize(size_); | 33 return Resize(size_, 1.f); |
| 34 } | 34 } |
| 35 | 35 |
| 36 void GLSurfaceOSMesa::Destroy() { | 36 void GLSurfaceOSMesa::Destroy() { |
| 37 buffer_.reset(); | 37 buffer_.reset(); |
| 38 } | 38 } |
| 39 | 39 |
| 40 bool GLSurfaceOSMesa::Resize(const gfx::Size& new_size) { | 40 bool GLSurfaceOSMesa::Resize(const gfx::Size& new_size, float scale_factor) { |
| 41 scoped_ptr<ui::ScopedMakeCurrent> scoped_make_current; | 41 scoped_ptr<ui::ScopedMakeCurrent> scoped_make_current; |
| 42 GLContext* current_context = GLContext::GetCurrent(); | 42 GLContext* current_context = GLContext::GetCurrent(); |
| 43 bool was_current = | 43 bool was_current = |
| 44 current_context && current_context->IsCurrent(this); | 44 current_context && current_context->IsCurrent(this); |
| 45 if (was_current) { | 45 if (was_current) { |
| 46 scoped_make_current.reset( | 46 scoped_make_current.reset( |
| 47 new ui::ScopedMakeCurrent(current_context, this)); | 47 new ui::ScopedMakeCurrent(current_context, this)); |
| 48 current_context->ReleaseCurrent(this); | 48 current_context->ReleaseCurrent(this); |
| 49 } | 49 } |
| 50 | 50 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 return gfx::SwapResult::SWAP_ACK; | 111 return gfx::SwapResult::SWAP_ACK; |
| 112 } | 112 } |
| 113 | 113 |
| 114 GLSurfaceOSMesaHeadless::GLSurfaceOSMesaHeadless() | 114 GLSurfaceOSMesaHeadless::GLSurfaceOSMesaHeadless() |
| 115 : GLSurfaceOSMesa(OSMesaSurfaceFormatBGRA, gfx::Size(1, 1)) { | 115 : GLSurfaceOSMesa(OSMesaSurfaceFormatBGRA, gfx::Size(1, 1)) { |
| 116 } | 116 } |
| 117 | 117 |
| 118 GLSurfaceOSMesaHeadless::~GLSurfaceOSMesaHeadless() { Destroy(); } | 118 GLSurfaceOSMesaHeadless::~GLSurfaceOSMesaHeadless() { Destroy(); } |
| 119 | 119 |
| 120 } // namespace gfx | 120 } // namespace gfx |
| OLD | NEW |