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

Side by Side Diff: mojo/gpu/gl_texture.cc

Issue 1537783002: Improve GL helpers. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years 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
« mojo/gpu/gl_context_owner.cc ('K') | « mojo/gpu/gl_context_owner.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "mojo/gpu/gl_texture.h" 5 #include "mojo/gpu/gl_texture.h"
6 6
7 #include <GLES2/gl2.h> 7 #include <GLES2/gl2.h>
8 8
9 namespace mojo { 9 namespace mojo {
10 10
11 GLTexture::GLTexture(base::WeakPtr<GLContext> context, mojo::Size size) 11 GLTexture::GLTexture(base::WeakPtr<GLContext> context, mojo::Size size)
12 : context_(context), size_(size), texture_id_(0u) { 12 : context_(context), size_(size), texture_id_(0u) {
13 DCHECK(context_); 13 DCHECK(context_);
14 context_->MakeCurrent(); 14 context_->MakeCurrent();
15 glGenTextures(1, &texture_id_); 15 glGenTextures(1, &texture_id_);
16 glBindTexture(GL_TEXTURE_2D, texture_id_); 16 glBindTexture(GL_TEXTURE_2D, texture_id_);
17 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, size_.width, size_.height, 0, GL_RGBA, 17 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, size_.width, size_.height, 0, GL_RGBA,
18 GL_UNSIGNED_BYTE, 0); 18 GL_UNSIGNED_BYTE, 0);
19 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 19 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
20 glBindTexture(GL_TEXTURE_2D, 0);
20 } 21 }
21 22
22 GLTexture::~GLTexture() { 23 GLTexture::~GLTexture() {
23 if (context_) { 24 if (context_) {
24 context_->MakeCurrent(); 25 context_->MakeCurrent();
25 glDeleteTextures(1, &texture_id_); 26 glDeleteTextures(1, &texture_id_);
26 } 27 }
27 } 28 }
28 29
29 } // namespace mojo 30 } // namespace mojo
OLDNEW
« mojo/gpu/gl_context_owner.cc ('K') | « mojo/gpu/gl_context_owner.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698