| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 "cc/resources/resource_provider.h" | 5 #include "cc/resources/resource_provider.h" |
| 6 | 6 |
| 7 #include <limits.h> | 7 #include <limits.h> |
| 8 | 8 |
| 9 #include "base/debug/alias.h" | 9 #include "base/debug/alias.h" |
| 10 #include "base/hash_tables.h" | 10 #include "base/hash_tables.h" |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 | 228 |
| 229 uint8_t* pixels = new uint8_t[size.width() * size.height() * 4]; | 229 uint8_t* pixels = new uint8_t[size.width() * size.height() * 4]; |
| 230 | 230 |
| 231 ResourceId id = next_id_++; | 231 ResourceId id = next_id_++; |
| 232 Resource resource(pixels, size, GL_RGBA, GL_LINEAR); | 232 Resource resource(pixels, size, GL_RGBA, GL_LINEAR); |
| 233 resource.allocated = true; | 233 resource.allocated = true; |
| 234 resources_[id] = resource; | 234 resources_[id] = resource; |
| 235 return id; | 235 return id; |
| 236 } | 236 } |
| 237 | 237 |
| 238 ResourceProvider::ResourceId ResourceProvider:: | 238 ResourceProvider::ResourceId |
| 239 CreateResourceFromExternalTexture(unsigned texture_id) { | 239 ResourceProvider::CreateResourceFromExternalTexture( |
| 240 unsigned texture_target, |
| 241 unsigned texture_id) { |
| 240 DCHECK(thread_checker_.CalledOnValidThread()); | 242 DCHECK(thread_checker_.CalledOnValidThread()); |
| 241 | 243 |
| 242 WebGraphicsContext3D* context3d = output_surface_->context3d(); | 244 WebGraphicsContext3D* context3d = output_surface_->context3d(); |
| 243 DCHECK(context3d); | 245 DCHECK(context3d); |
| 244 GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, texture_id)); | 246 GLC(context3d, context3d->bindTexture(texture_target, texture_id)); |
| 245 GLC(context3d, context3d->texParameteri( | 247 GLC(context3d, context3d->texParameteri( |
| 246 GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); | 248 texture_target, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); |
| 247 GLC(context3d, context3d->texParameteri( | 249 GLC(context3d, context3d->texParameteri( |
| 248 GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); | 250 texture_target, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); |
| 249 GLC(context3d, context3d->texParameteri( | 251 GLC(context3d, context3d->texParameteri( |
| 250 GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)); | 252 texture_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)); |
| 251 GLC(context3d, context3d->texParameteri( | 253 GLC(context3d, context3d->texParameteri( |
| 252 GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)); | 254 texture_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)); |
| 253 | 255 |
| 254 ResourceId id = next_id_++; | 256 ResourceId id = next_id_++; |
| 255 Resource resource(texture_id, gfx::Size(), 0, GL_LINEAR); | 257 Resource resource(texture_id, gfx::Size(), 0, GL_LINEAR); |
| 256 resource.external = true; | 258 resource.external = true; |
| 257 resource.allocated = true; | 259 resource.allocated = true; |
| 258 resources_[id] = resource; | 260 resources_[id] = resource; |
| 259 return id; | 261 return id; |
| 260 } | 262 } |
| 261 | 263 |
| 262 ResourceProvider::ResourceId ResourceProvider::CreateResourceFromTextureMailbox( | 264 ResourceProvider::ResourceId ResourceProvider::CreateResourceFromTextureMailbox( |
| (...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1219 void ResourceProvider::EnableReadLockFences(ResourceProvider::ResourceId id, | 1221 void ResourceProvider::EnableReadLockFences(ResourceProvider::ResourceId id, |
| 1220 bool enable) { | 1222 bool enable) { |
| 1221 DCHECK(thread_checker_.CalledOnValidThread()); | 1223 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1222 ResourceMap::iterator it = resources_.find(id); | 1224 ResourceMap::iterator it = resources_.find(id); |
| 1223 CHECK(it != resources_.end()); | 1225 CHECK(it != resources_.end()); |
| 1224 Resource* resource = &it->second; | 1226 Resource* resource = &it->second; |
| 1225 resource->enable_read_lock_fences = enable; | 1227 resource->enable_read_lock_fences = enable; |
| 1226 } | 1228 } |
| 1227 | 1229 |
| 1228 } // namespace cc | 1230 } // namespace cc |
| OLD | NEW |