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

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

Issue 1868363002: Replace scoped_ptr with std::unique_ptr in //ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scopedptrcc
Patch Set: scopedptrui: rebase-make_scoped_ptr Created 4 years, 8 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_surface_osmesa.h ('k') | ui/gl/gl_surface_ozone.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 (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_osmesa.h" 5 #include "ui/gl/gl_surface_osmesa.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/numerics/safe_math.h" 10 #include "base/numerics/safe_math.h"
(...skipping 18 matching lines...) Expand all
29 return Resize(size_, 1.f, true); 29 return Resize(size_, 1.f, true);
30 } 30 }
31 31
32 void GLSurfaceOSMesa::Destroy() { 32 void GLSurfaceOSMesa::Destroy() {
33 buffer_.reset(); 33 buffer_.reset();
34 } 34 }
35 35
36 bool GLSurfaceOSMesa::Resize(const gfx::Size& new_size, 36 bool GLSurfaceOSMesa::Resize(const gfx::Size& new_size,
37 float scale_factor, 37 float scale_factor,
38 bool has_alpha) { 38 bool has_alpha) {
39 scoped_ptr<ui::ScopedMakeCurrent> scoped_make_current; 39 std::unique_ptr<ui::ScopedMakeCurrent> scoped_make_current;
40 GLContext* current_context = GLContext::GetCurrent(); 40 GLContext* current_context = GLContext::GetCurrent();
41 bool was_current = 41 bool was_current =
42 current_context && current_context->IsCurrent(this); 42 current_context && current_context->IsCurrent(this);
43 if (was_current) { 43 if (was_current) {
44 scoped_make_current.reset( 44 scoped_make_current.reset(
45 new ui::ScopedMakeCurrent(current_context, this)); 45 new ui::ScopedMakeCurrent(current_context, this));
46 current_context->ReleaseCurrent(this); 46 current_context->ReleaseCurrent(this);
47 } 47 }
48 48
49 // Preserve the old buffer. 49 // Preserve the old buffer.
50 scoped_ptr<int32_t[]> old_buffer(buffer_.release()); 50 std::unique_ptr<int32_t[]> old_buffer(buffer_.release());
51 51
52 base::CheckedNumeric<int> checked_size = sizeof(buffer_[0]); 52 base::CheckedNumeric<int> checked_size = sizeof(buffer_[0]);
53 checked_size *= new_size.width(); 53 checked_size *= new_size.width();
54 checked_size *= new_size.height(); 54 checked_size *= new_size.height();
55 if (!checked_size.IsValid()) 55 if (!checked_size.IsValid())
56 return false; 56 return false;
57 57
58 // Allocate a new one. 58 // Allocate a new one.
59 buffer_.reset(new int32_t[new_size.GetArea()]); 59 buffer_.reset(new int32_t[new_size.GetArea()]);
60 if (!buffer_.get()) 60 if (!buffer_.get())
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 return gfx::SwapResult::SWAP_ACK; 109 return gfx::SwapResult::SWAP_ACK;
110 } 110 }
111 111
112 GLSurfaceOSMesaHeadless::GLSurfaceOSMesaHeadless() 112 GLSurfaceOSMesaHeadless::GLSurfaceOSMesaHeadless()
113 : GLSurfaceOSMesa(SURFACE_OSMESA_BGRA, gfx::Size(1, 1)) { 113 : GLSurfaceOSMesa(SURFACE_OSMESA_BGRA, gfx::Size(1, 1)) {
114 } 114 }
115 115
116 GLSurfaceOSMesaHeadless::~GLSurfaceOSMesaHeadless() { Destroy(); } 116 GLSurfaceOSMesaHeadless::~GLSurfaceOSMesaHeadless() { Destroy(); }
117 117
118 } // namespace gfx 118 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gl/gl_surface_osmesa.h ('k') | ui/gl/gl_surface_ozone.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698