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

Side by Side Diff: ui/gl/gl_image_memory.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_memory.h ('k') | ui/gl/gl_image_ref_counted_memory.h » ('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 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_memory.h" 5 #include "ui/gl/gl_image_memory.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "ui/gl/gl_bindings.h" 9 #include "ui/gl/gl_bindings.h"
10 #include "ui/gl/scoped_binders.h" 10 #include "ui/gl/scoped_binders.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 #if defined(OS_WIN) || defined(USE_X11) || defined(OS_ANDROID) || \ 74 #if defined(OS_WIN) || defined(USE_X11) || defined(OS_ANDROID) || \
75 defined(USE_OZONE) 75 defined(USE_OZONE)
76 , 76 ,
77 egl_texture_id_(0u), 77 egl_texture_id_(0u),
78 egl_image_(EGL_NO_IMAGE_KHR) 78 egl_image_(EGL_NO_IMAGE_KHR)
79 #endif 79 #endif
80 { 80 {
81 } 81 }
82 82
83 GLImageMemory::~GLImageMemory() { 83 GLImageMemory::~GLImageMemory() {
84 #if defined(OS_WIN) || defined(USE_X11) || defined(OS_ANDROID) || \
85 defined(USE_OZONE)
86 DCHECK_EQ(EGL_NO_IMAGE_KHR, egl_image_);
87 DCHECK_EQ(0u, egl_texture_id_);
88 #endif
84 } 89 }
85 90
86 bool GLImageMemory::Initialize(const unsigned char* memory) { 91 bool GLImageMemory::Initialize(const unsigned char* memory) {
87 if (!ValidFormat(internalformat_)) { 92 if (!ValidFormat(internalformat_)) {
88 DVLOG(0) << "Invalid format: " << internalformat_; 93 DVLOG(0) << "Invalid format: " << internalformat_;
89 return false; 94 return false;
90 } 95 }
91 96
92 DCHECK(memory); 97 DCHECK(memory);
93 DCHECK(!memory_); 98 DCHECK(!memory_);
94 memory_ = memory; 99 memory_ = memory;
95 return true; 100 return true;
96 } 101 }
97 102
98 void GLImageMemory::Destroy() { 103 void GLImageMemory::Destroy(bool have_context) {
99 #if defined(OS_WIN) || defined(USE_X11) || defined(OS_ANDROID) || \ 104 #if defined(OS_WIN) || defined(USE_X11) || defined(OS_ANDROID) || \
100 defined(USE_OZONE) 105 defined(USE_OZONE)
101 if (egl_image_ != EGL_NO_IMAGE_KHR) { 106 if (egl_image_ != EGL_NO_IMAGE_KHR) {
102 eglDestroyImageKHR(GLSurfaceEGL::GetHardwareDisplay(), egl_image_); 107 eglDestroyImageKHR(GLSurfaceEGL::GetHardwareDisplay(), egl_image_);
103 egl_image_ = EGL_NO_IMAGE_KHR; 108 egl_image_ = EGL_NO_IMAGE_KHR;
104 } 109 }
105 110
106 if (egl_texture_id_) { 111 if (egl_texture_id_) {
107 glDeleteTextures(1, &egl_texture_id_); 112 if (have_context)
113 glDeleteTextures(1, &egl_texture_id_);
108 egl_texture_id_ = 0u; 114 egl_texture_id_ = 0u;
109 } 115 }
110 #endif 116 #endif
111 memory_ = NULL; 117 memory_ = NULL;
112 } 118 }
113 119
114 gfx::Size GLImageMemory::GetSize() { 120 gfx::Size GLImageMemory::GetSize() {
115 return size_; 121 return size_;
116 } 122 }
117 123
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 197
192 bool GLImageMemory::HasValidFormat() const { 198 bool GLImageMemory::HasValidFormat() const {
193 return ValidFormat(internalformat_); 199 return ValidFormat(internalformat_);
194 } 200 }
195 201
196 size_t GLImageMemory::Bytes() const { 202 size_t GLImageMemory::Bytes() const {
197 return size_.GetArea() * BytesPerPixel(internalformat_); 203 return size_.GetArea() * BytesPerPixel(internalformat_);
198 } 204 }
199 205
200 } // namespace gfx 206 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gl/gl_image_memory.h ('k') | ui/gl/gl_image_ref_counted_memory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698