Chromium Code Reviews| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 | 9 |
| 10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 268 return id; | 268 return id; |
| 269 } | 269 } |
| 270 | 270 |
| 271 ResourceProvider::ResourceId ResourceProvider::CreateResourceFromTextureMailbox( | 271 ResourceProvider::ResourceId ResourceProvider::CreateResourceFromTextureMailbox( |
| 272 const TextureMailbox& mailbox) { | 272 const TextureMailbox& mailbox) { |
| 273 DCHECK(thread_checker_.CalledOnValidThread()); | 273 DCHECK(thread_checker_.CalledOnValidThread()); |
| 274 // Just store the information. Mailbox will be consumed in LockForRead(). | 274 // Just store the information. Mailbox will be consumed in LockForRead(). |
| 275 ResourceId id = next_id_++; | 275 ResourceId id = next_id_++; |
| 276 DCHECK(mailbox.IsValid()); | 276 DCHECK(mailbox.IsValid()); |
| 277 Resource& resource = resources_[id]; | 277 Resource& resource = resources_[id]; |
| 278 if (mailbox.IsTexture()) { | 278 if (mailbox.IsBitmap()) { |
| 279 SkBitmap bitmap = mailbox.bitmap(); | |
| 280 SkAutoLockPixels bitmapLock(bitmap); | |
|
tfarina
2013/06/26 16:27:38
minornit: bitmap_lock
| |
| 281 uint8_t* pixels = reinterpret_cast<uint8_t*>(bitmap.getPixels()); | |
| 282 resource = Resource(pixels, mailbox.shared_memory_size(), | |
| 283 GL_RGBA, GL_LINEAR); | |
| 284 } else if (mailbox.IsTexture()) { | |
| 279 resource = Resource(0, gfx::Size(), 0, GL_LINEAR, 0, TextureUsageAny); | 285 resource = Resource(0, gfx::Size(), 0, GL_LINEAR, 0, TextureUsageAny); |
| 280 } else { | 286 } else { |
| 281 DCHECK(mailbox.IsSharedMemory()); | 287 DCHECK(mailbox.IsSharedMemory()); |
| 282 base::SharedMemory* shared_memory = mailbox.shared_memory(); | 288 base::SharedMemory* shared_memory = mailbox.shared_memory(); |
| 283 DCHECK(shared_memory->memory()); | 289 DCHECK(shared_memory->memory()); |
| 284 uint8_t* pixels = reinterpret_cast<uint8_t*>(shared_memory->memory()); | 290 uint8_t* pixels = reinterpret_cast<uint8_t*>(shared_memory->memory()); |
| 285 resource = Resource(pixels, mailbox.shared_memory_size(), | 291 resource = Resource(pixels, mailbox.shared_memory_size(), |
| 286 GL_RGBA, GL_LINEAR); | 292 GL_RGBA, GL_LINEAR); |
| 287 } | 293 } |
| 288 resource.external = true; | 294 resource.external = true; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 347 GLC(context3d, context3d->bindTexture( | 353 GLC(context3d, context3d->bindTexture( |
| 348 resource->mailbox.target(), resource->gl_id)); | 354 resource->mailbox.target(), resource->gl_id)); |
| 349 GLC(context3d, context3d->produceTextureCHROMIUM( | 355 GLC(context3d, context3d->produceTextureCHROMIUM( |
| 350 resource->mailbox.target(), resource->mailbox.data())); | 356 resource->mailbox.target(), resource->mailbox.data())); |
| 351 } | 357 } |
| 352 if (resource->gl_id) | 358 if (resource->gl_id) |
| 353 GLC(context3d, context3d->deleteTexture(resource->gl_id)); | 359 GLC(context3d, context3d->deleteTexture(resource->gl_id)); |
| 354 if (!lost_resource && resource->gl_id) | 360 if (!lost_resource && resource->gl_id) |
| 355 sync_point = context3d->insertSyncPoint(); | 361 sync_point = context3d->insertSyncPoint(); |
| 356 } else { | 362 } else { |
| 357 DCHECK(resource->mailbox.IsSharedMemory()); | 363 DCHECK(resource->mailbox.IsSharedMemory() || |
| 364 resource->mailbox.IsBitmap()); | |
| 358 base::SharedMemory* shared_memory = resource->mailbox.shared_memory(); | 365 base::SharedMemory* shared_memory = resource->mailbox.shared_memory(); |
| 359 if (resource->pixels && shared_memory) { | 366 if (resource->pixels) { |
| 360 DCHECK(shared_memory->memory() == resource->pixels); | 367 DCHECK(!shared_memory || shared_memory->memory() == resource->pixels); |
| 361 resource->pixels = NULL; | 368 resource->pixels = NULL; |
| 362 } | 369 } |
| 363 } | 370 } |
| 364 resource->mailbox.RunReleaseCallback(sync_point, lost_resource); | 371 resource->mailbox.RunReleaseCallback(sync_point, lost_resource); |
| 365 } | 372 } |
| 366 if (resource->pixels) | 373 if (resource->pixels) |
| 367 delete[] resource->pixels; | 374 delete[] resource->pixels; |
| 368 if (resource->pixel_buffer) | 375 if (resource->pixel_buffer) |
| 369 delete[] resource->pixel_buffer; | 376 delete[] resource->pixel_buffer; |
| 370 | 377 |
| (...skipping 1036 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1407 | 1414 |
| 1408 WebGraphicsContext3D* context3d = output_surface_->context3d(); | 1415 WebGraphicsContext3D* context3d = output_surface_->context3d(); |
| 1409 DCHECK(context3d); | 1416 DCHECK(context3d); |
| 1410 int stride = 0; | 1417 int stride = 0; |
| 1411 context3d->getImageParameterivCHROMIUM( | 1418 context3d->getImageParameterivCHROMIUM( |
| 1412 resource->image_id, GL_IMAGE_ROWBYTES_CHROMIUM, &stride); | 1419 resource->image_id, GL_IMAGE_ROWBYTES_CHROMIUM, &stride); |
| 1413 return stride; | 1420 return stride; |
| 1414 } | 1421 } |
| 1415 | 1422 |
| 1416 } // namespace cc | 1423 } // namespace cc |
| OLD | NEW |