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

Side by Side Diff: ui/gl/gl_image_io_surface.mm

Issue 1390083002: Revert of ui: Add GLImage unit test framework. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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_io_surface.h ('k') | ui/gl/gl_image_ref_counted_memory_unittest.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_io_surface.h" 5 #include "ui/gl/gl_image_io_surface.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/mac/foundation_util.h" 10 #include "base/mac/foundation_util.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 NOTREACHED(); 131 NOTREACHED();
132 return 0; 132 return 0;
133 } 133 }
134 134
135 NOTREACHED(); 135 NOTREACHED();
136 return 0; 136 return 0;
137 } 137 }
138 138
139 } // namespace 139 } // namespace
140 140
141 GLImageIOSurface::GLImageIOSurface(const gfx::Size& size, 141 GLImageIOSurface::GLImageIOSurface(gfx::GenericSharedMemoryId io_surface_id,
142 const gfx::Size& size,
142 unsigned internalformat) 143 unsigned internalformat)
143 : size_(size), 144 : io_surface_id_(io_surface_id),
145 size_(size),
144 internalformat_(internalformat), 146 internalformat_(internalformat),
145 format_(BufferFormat::RGBA_8888) {} 147 format_(BufferFormat::RGBA_8888) {}
146 148
147 GLImageIOSurface::~GLImageIOSurface() { 149 GLImageIOSurface::~GLImageIOSurface() {
148 DCHECK(thread_checker_.CalledOnValidThread()); 150 DCHECK(thread_checker_.CalledOnValidThread());
149 DCHECK(!io_surface_); 151 DCHECK(!io_surface_);
150 } 152 }
151 153
152 bool GLImageIOSurface::Initialize(IOSurfaceRef io_surface, 154 bool GLImageIOSurface::Initialize(IOSurfaceRef io_surface,
153 gfx::GenericSharedMemoryId io_surface_id,
154 BufferFormat format) { 155 BufferFormat format) {
155 DCHECK(thread_checker_.CalledOnValidThread()); 156 DCHECK(thread_checker_.CalledOnValidThread());
156 DCHECK(!io_surface_); 157 DCHECK(!io_surface_);
157 158
158 if (!ValidInternalFormat(internalformat_)) { 159 if (!ValidInternalFormat(internalformat_)) {
159 LOG(ERROR) << "Invalid internalformat: " << internalformat_; 160 LOG(ERROR) << "Invalid internalformat: " << internalformat_;
160 return false; 161 return false;
161 } 162 }
162 163
163 if (!ValidFormat(format)) { 164 if (!ValidFormat(format)) {
164 LOG(ERROR) << "Invalid format: " << static_cast<int>(format); 165 LOG(ERROR) << "Invalid format: " << static_cast<int>(format);
165 return false; 166 return false;
166 } 167 }
167 168
168 format_ = format; 169 format_ = format;
169 io_surface_.reset(io_surface, base::scoped_policy::RETAIN); 170 io_surface_.reset(io_surface, base::scoped_policy::RETAIN);
170 io_surface_id_ = io_surface_id;
171 return true; 171 return true;
172 } 172 }
173 173
174 void GLImageIOSurface::Destroy(bool have_context) { 174 void GLImageIOSurface::Destroy(bool have_context) {
175 DCHECK(thread_checker_.CalledOnValidThread()); 175 DCHECK(thread_checker_.CalledOnValidThread());
176 io_surface_.reset(); 176 io_surface_.reset();
177 } 177 }
178 178
179 gfx::Size GLImageIOSurface::GetSize() { return size_; } 179 gfx::Size GLImageIOSurface::GetSize() { return size_; }
180 180
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 // static 246 // static
247 void GLImageIOSurface::SetLayerForWidget( 247 void GLImageIOSurface::SetLayerForWidget(
248 gfx::AcceleratedWidget widget, CALayer* layer) { 248 gfx::AcceleratedWidget widget, CALayer* layer) {
249 if (layer) 249 if (layer)
250 g_widget_to_layer_map.Pointer()->insert(std::make_pair(widget, layer)); 250 g_widget_to_layer_map.Pointer()->insert(std::make_pair(widget, layer));
251 else 251 else
252 g_widget_to_layer_map.Pointer()->erase(widget); 252 g_widget_to_layer_map.Pointer()->erase(widget);
253 } 253 }
254 254
255 } // namespace gfx 255 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gl/gl_image_io_surface.h ('k') | ui/gl/gl_image_ref_counted_memory_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698