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

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

Issue 1354483004: Re-land: ui: Add GLImage unit test framework. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase 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(gfx::GenericSharedMemoryId io_surface_id, 141 GLImageIOSurface::GLImageIOSurface(const gfx::Size& size,
142 const gfx::Size& size,
143 unsigned internalformat) 142 unsigned internalformat)
144 : io_surface_id_(io_surface_id), 143 : size_(size),
145 size_(size),
146 internalformat_(internalformat), 144 internalformat_(internalformat),
147 format_(BufferFormat::RGBA_8888) {} 145 format_(BufferFormat::RGBA_8888) {}
148 146
149 GLImageIOSurface::~GLImageIOSurface() { 147 GLImageIOSurface::~GLImageIOSurface() {
150 DCHECK(thread_checker_.CalledOnValidThread()); 148 DCHECK(thread_checker_.CalledOnValidThread());
151 DCHECK(!io_surface_); 149 DCHECK(!io_surface_);
152 } 150 }
153 151
154 bool GLImageIOSurface::Initialize(IOSurfaceRef io_surface, 152 bool GLImageIOSurface::Initialize(IOSurfaceRef io_surface,
153 gfx::GenericSharedMemoryId io_surface_id,
155 BufferFormat format) { 154 BufferFormat format) {
156 DCHECK(thread_checker_.CalledOnValidThread()); 155 DCHECK(thread_checker_.CalledOnValidThread());
157 DCHECK(!io_surface_); 156 DCHECK(!io_surface_);
158 157
159 if (!ValidInternalFormat(internalformat_)) { 158 if (!ValidInternalFormat(internalformat_)) {
160 LOG(ERROR) << "Invalid internalformat: " << internalformat_; 159 LOG(ERROR) << "Invalid internalformat: " << internalformat_;
161 return false; 160 return false;
162 } 161 }
163 162
164 if (!ValidFormat(format)) { 163 if (!ValidFormat(format)) {
165 LOG(ERROR) << "Invalid format: " << static_cast<int>(format); 164 LOG(ERROR) << "Invalid format: " << static_cast<int>(format);
166 return false; 165 return false;
167 } 166 }
168 167
169 format_ = format; 168 format_ = format;
170 io_surface_.reset(io_surface, base::scoped_policy::RETAIN); 169 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