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

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

Issue 301793003: During image destroy, delete textures only if we have a GL context. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: resolve android clang dbg build issue. Created 6 years, 4 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_image_surface_texture.h ('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 "ui/gl/gl_image_surface_texture.h" 5 #include "ui/gl/gl_image_surface_texture.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "ui/gl/android/surface_texture.h" 8 #include "ui/gl/android/surface_texture.h"
9 #include "ui/gl/android/surface_texture_tracker.h" 9 #include "ui/gl/android/surface_texture_tracker.h"
10 10
11 namespace gfx { 11 namespace gfx {
12 12
13 GLImageSurfaceTexture::GLImageSurfaceTexture(const gfx::Size& size) 13 GLImageSurfaceTexture::GLImageSurfaceTexture(const gfx::Size& size)
14 : size_(size), texture_id_(0) { 14 : size_(size), texture_id_(0) {
15 } 15 }
16 16
17 GLImageSurfaceTexture::~GLImageSurfaceTexture() { Destroy(); } 17 GLImageSurfaceTexture::~GLImageSurfaceTexture() {
18 DCHECK(!surface_texture_);
19 DCHECK_EQ(0, texture_id_);
20 }
18 21
19 bool GLImageSurfaceTexture::Initialize( 22 bool GLImageSurfaceTexture::Initialize(
20 const gfx::GpuMemoryBufferHandle& handle) { 23 const gfx::GpuMemoryBufferHandle& handle) {
21 DCHECK(!surface_texture_); 24 DCHECK(!surface_texture_);
22 surface_texture_ = 25 surface_texture_ =
23 SurfaceTextureTracker::GetInstance()->AcquireSurfaceTexture( 26 SurfaceTextureTracker::GetInstance()->AcquireSurfaceTexture(
24 handle.surface_texture_id.primary_id, 27 handle.surface_texture_id.primary_id,
25 handle.surface_texture_id.secondary_id); 28 handle.surface_texture_id.secondary_id);
26 return !!surface_texture_; 29 return !!surface_texture_;
27 } 30 }
28 31
29 void GLImageSurfaceTexture::Destroy() { 32 void GLImageSurfaceTexture::Destroy(bool have_context) {
30 surface_texture_ = NULL; 33 surface_texture_ = NULL;
31 texture_id_ = 0; 34 texture_id_ = 0;
32 } 35 }
33 36
34 gfx::Size GLImageSurfaceTexture::GetSize() { return size_; } 37 gfx::Size GLImageSurfaceTexture::GetSize() { return size_; }
35 38
36 bool GLImageSurfaceTexture::BindTexImage(unsigned target) { 39 bool GLImageSurfaceTexture::BindTexImage(unsigned target) {
37 TRACE_EVENT0("gpu", "GLImageSurfaceTexture::BindTexImage"); 40 TRACE_EVENT0("gpu", "GLImageSurfaceTexture::BindTexImage");
38 41
39 if (target != GL_TEXTURE_EXTERNAL_OES) { 42 if (target != GL_TEXTURE_EXTERNAL_OES) {
(...skipping 28 matching lines...) Expand all
68 // GL_TEXTURE_EXTERNAL_OES target. 71 // GL_TEXTURE_EXTERNAL_OES target.
69 surface_texture_->AttachToGLContext(); 72 surface_texture_->AttachToGLContext();
70 texture_id_ = texture_id; 73 texture_id_ = texture_id;
71 } 74 }
72 75
73 surface_texture_->UpdateTexImage(); 76 surface_texture_->UpdateTexImage();
74 return true; 77 return true;
75 } 78 }
76 79
77 } // namespace gfx 80 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gl/gl_image_surface_texture.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698