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

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: change destroy flow for all GLImage types. Created 6 years, 6 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
« ui/gl/gl_image_stub.cc ('K') | « 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(gfx::Size size) 13 GLImageSurfaceTexture::GLImageSurfaceTexture(gfx::Size size)
14 : size_(size), texture_id_(0) {} 14 : size_(size), texture_id_(0) {}
15 15
16 GLImageSurfaceTexture::~GLImageSurfaceTexture() { Destroy(); } 16 GLImageSurfaceTexture::~GLImageSurfaceTexture() {
17 DCHECK(!surface_texture_);
18 DCHECK_EQ(0u, texture_id_);
19 }
17 20
18 bool GLImageSurfaceTexture::Initialize(gfx::GpuMemoryBufferHandle buffer) { 21 bool GLImageSurfaceTexture::Initialize(gfx::GpuMemoryBufferHandle buffer) {
19 DCHECK(!surface_texture_); 22 DCHECK(!surface_texture_);
20 surface_texture_ = 23 surface_texture_ =
21 SurfaceTextureTracker::GetInstance()->AcquireSurfaceTexture( 24 SurfaceTextureTracker::GetInstance()->AcquireSurfaceTexture(
22 buffer.surface_texture_id.primary_id, 25 buffer.surface_texture_id.primary_id,
23 buffer.surface_texture_id.secondary_id); 26 buffer.surface_texture_id.secondary_id);
24 return !!surface_texture_; 27 return !!surface_texture_;
25 } 28 }
26 29
27 void GLImageSurfaceTexture::Destroy() { 30 void GLImageSurfaceTexture::Destroy(bool have_context) {
28 surface_texture_ = NULL; 31 surface_texture_ = NULL;
29 texture_id_ = 0; 32 texture_id_ = 0;
30 } 33 }
31 34
32 gfx::Size GLImageSurfaceTexture::GetSize() { return size_; } 35 gfx::Size GLImageSurfaceTexture::GetSize() { return size_; }
33 36
34 bool GLImageSurfaceTexture::BindTexImage(unsigned target) { 37 bool GLImageSurfaceTexture::BindTexImage(unsigned target) {
35 TRACE_EVENT0("gpu", "GLImageSurfaceTexture::BindTexImage"); 38 TRACE_EVENT0("gpu", "GLImageSurfaceTexture::BindTexImage");
36 39
37 if (target != GL_TEXTURE_EXTERNAL_OES) { 40 if (target != GL_TEXTURE_EXTERNAL_OES) {
(...skipping 28 matching lines...) Expand all
66 // GL_TEXTURE_EXTERNAL_OES target. 69 // GL_TEXTURE_EXTERNAL_OES target.
67 surface_texture_->AttachToGLContext(); 70 surface_texture_->AttachToGLContext();
68 texture_id_ = texture_id; 71 texture_id_ = texture_id;
69 } 72 }
70 73
71 surface_texture_->UpdateTexImage(); 74 surface_texture_->UpdateTexImage();
72 return true; 75 return true;
73 } 76 }
74 77
75 } // namespace gfx 78 } // namespace gfx
OLDNEW
« ui/gl/gl_image_stub.cc ('K') | « 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