Home | History | Annotate | Download | only in resources

Lines Matching defs:Resource

164 ResourceProvider::Resource::Resource()
197 ResourceProvider::Resource::~Resource() {}
199 ResourceProvider::Resource::Resource(GLuint texture_id,
241 ResourceProvider::Resource::Resource(uint8_t* pixels,
322 Resource* resource = GetResource(id);
323 return resource->lock_for_read_count > 0 || resource->exported_count > 0 ||
324 resource->lost;
328 Resource* resource = GetResource(id);
329 return resource->lost;
353 LOG(FATAL) << "Invalid default resource type.";
379 LOG(FATAL) << "Invalid default resource type.";
395 Resource resource(
397 resource.allocated = false;
398 resources_[id] = resource;
417 Resource resource(
419 resource.allocated = true;
420 resources_[id] = resource;
441 Resource resource(texture_id,
449 resource.external = true;
450 resource.allocated = true;
451 resources_[id] = resource;
462 Resource& resource = resources_[id];
464 resource = Resource(0,
482 resource = Resource(pixels,
488 resource.external = true;
489 resource.allocated = true;
490 resource.mailbox = mailbox;
491 resource.release_callback =
501 Resource* resource = &it->second;
502 DCHECK(!resource->lock_for_read_count);
503 DCHECK(!resource->marked_for_deletion);
504 DCHECK_EQ(resource->imported_count, 0);
505 DCHECK(resource->pending_set_pixels || !resource->locked_for_write);
507 if (resource->exported_count > 0) {
508 resource->marked_for_deletion = true;
518 Resource* resource = &it->second;
519 bool lost_resource = resource->lost;
521 DCHECK(resource->exported_count == 0 || style != Normal);
522 if (style == ForShutdown && resource->exported_count > 0)
525 if (resource->image_id) {
528 GLC(gl, gl->DestroyImageCHROMIUM(resource->image_id));
531 if (resource->gl_id && !resource->external) {
534 GLC(gl, gl->DeleteTextures(1, &resource->gl_id));
536 if (resource->gl_upload_query_id) {
539 GLC(gl, gl->DeleteQueriesEXT(1, &resource->gl_upload_query_id));
541 if (resource->gl_pixel_buffer_id) {
544 GLC(gl, gl->DeleteBuffers(1, &resource->gl_pixel_buffer_id));
546 if (resource->mailbox.IsValid() && resource->external) {
547 GLuint sync_point = resource->mailbox.sync_point();
548 if (resource->mailbox.IsTexture()) {
552 if (resource->gl_id)
553 GLC(gl, gl->DeleteTextures(1, &resource->gl_id));
554 if (!lost_resource && resource->gl_id)
557 DCHECK(resource->mailbox.IsSharedMemory());
558 base::SharedMemory* shared_memory = resource->mailbox.shared_memory();
559 if (resource->pixels && shared_memory) {
560 DCHECK(shared_memory->memory() == resource->pixels);
561 resource->pixels = NULL;
562 delete resource->shared_bitmap;
563 resource->shared_bitmap = NULL;
566 resource->release_callback.Run(sync_point, lost_resource);
568 if (resource->shared_bitmap) {
569 delete resource->shared_bitmap;
570 resource->pixels = NULL;
572 if (resource->pixels)
573 delete[] resource->pixels;
574 if (resource->pixel_buffer)
575 delete[] resource->pixel_buffer;
590 Resource* resource = GetResource(id);
591 DCHECK(!resource->locked_for_write);
592 DCHECK(!resource->lock_for_read_count);
593 DCHECK(!resource->external);
594 DCHECK_EQ(resource->exported_count, 0);
595 DCHECK(ReadLockFenceHasPassed(resource));
596 LazyAllocate(resource);
598 if (resource->gl_id) {
599 DCHECK(!resource->pending_set_pixels);
600 DCHECK_EQ(resource->target, static_cast<GLenum>(GL_TEXTURE_2D));
604 gl->BindTexture(GL_TEXTURE_2D, resource->gl_id);
609 resource->format,
610 resource->size);
613 if (resource->pixels) {
614 DCHECK(resource->allocated);
615 DCHECK_EQ(RGBA_8888, resource->format);
677 // Software resource uploads happen on impl thread, so don't bother batching
717 ResourceProvider::Resource* ResourceProvider::GetResource(ResourceId id) {
724 const ResourceProvider::Resource* ResourceProvider::LockForRead(ResourceId id) {
725 Resource* resource = GetResource(id);
726 DCHECK(!resource->locked_for_write ||
727 resource->set_pixels_completion_forced) <<
728 "locked for write: " << resource->locked_for_write <<
729 " pixels completion forced: " << resource->set_pixels_completion_forced;
730 DCHECK_EQ(resource->exported_count, 0);
732 DCHECK(resource->allocated);
734 LazyCreate(resource);
736 if (resource->external) {
737 if (!resource->gl_id && resource->mailbox.IsTexture()) {
740 if (resource->mailbox.sync_point()) {
741 GLC(gl, gl->WaitSyncPointCHROMIUM(resource->mailbox.sync_point()));
742 resource->mailbox.ResetSyncPoint();
744 resource->gl_id = texture_id_allocator_->NextId();
745 GLC(gl, gl->BindTexture(resource->target, resource->gl_id));
747 gl->ConsumeTextureCHROMIUM(resource->target,
748 resource->mailbox.data()));
752 resource->lock_for_read_count++;
753 if (resource->enable_read_lock_fences)
754 resource->read_lock_fence = current_read_lock_fence_;
756 return resource;
760 Resource* resource = GetResource(id);
761 DCHECK_GT(resource->lock_for_read_count, 0);
762 DCHECK_EQ(resource->exported_count, 0);
763 resource->lock_for_read_count--;
766 const ResourceProvider::Resource* ResourceProvider::LockForWrite(
768 Resource* resource = GetResource(id);
769 DCHECK(!resource->locked_for_write);
770 DCHECK(!resource->lock_for_read_count);
771 DCHECK_EQ(resource->exported_count, 0);
772 DCHECK(!resource->external);
773 DCHECK(!resource->lost);
774 DCHECK(ReadLockFenceHasPassed(resource));
775 LazyAllocate(resource);
777 resource->locked_for_write = true;
778 return resource;
782 Resource* resource = GetResource(id);
783 return !resource->locked_for_write && !resource->lock_for_read_count &&
784 !resource->exported_count && !resource->external && !resource->lost &&
785 ReadLockFenceHasPassed(resource);
789 Resource* resource = GetResource(id);
790 DCHECK(resource->locked_for_write);
791 DCHECK_EQ(resource->exported_count, 0);
792 DCHECK(!resource->external);
793 resource->locked_for_write = false;
845 SkBitmap* sk_bitmap, const Resource* resource) {
846 DCHECK(resource->pixels);
847 DCHECK_EQ(RGBA_8888, resource->format);
849 resource->size.width(),
850 resource->size.height());
851 sk_bitmap->setPixels(resource->pixels);
859 const Resource* resource = resource_provider->LockForRead(resource_id);
860 wrap_mode_ = resource->wrap_mode;
861 ResourceProvider::PopulateSkBitmapWithResource(&sk_bitmap_, resource);
1023 TransferableResource resource;
1024 TransferResource(gl, *it, &resource);
1025 if (!resource.sync_point && !resource.is_software)
1028 list->push_back(resource);
1076 Resource& resource = resources_[local_id];
1078 resource = Resource(
1093 resource = Resource(texture_id,
1101 resource.mailbox.SetName(it->mailbox);
1103 resource.child_id = child;
1105 resource.allocated = true;
1106 resource.imported_count = 1;
1150 const Resource& a_resource = a_it->second;
1151 const Resource& b_resource = b_it->second;
1172 // Resource was already lost (e.g. it belonged to a child that was
1190 Resource* resource = &map_iterator->second;
1192 CHECK_GE(resource->exported_count, returned.count);
1193 resource->exported_count -= returned.count;
1194 resource->lost |= returned.lost;
1195 if (resource->exported_count)
1198 if (resource->gl_id) {
1201 } else if (!resource->shared_bitmap) {
1202 resource->mailbox =
1203 TextureMailbox(resource->mailbox.name(), returned.sync_point);
1206 if (!resource->marked_for_deletion)
1209 if (!resource->child_id) {
1210 // The resource belongs to this ResourceProvider, so it can be destroyed.
1215 // Delete the resource and return it to the child it came from one.
1216 if (resource->child_id != child_id) {
1225 child_it = children_.find(resource->child_id);
1227 child_id = resource->child_id;
1242 TransferableResource* resource) {
1243 Resource* source = GetResource(id);
1249 resource->id = id;
1250 resource->format = source->format;
1251 resource->target = source->target;
1252 resource->filter = source->filter;
1253 resource->size = source->size;
1256 resource->mailbox = source->shared_bitmap->id();
1257 resource->is_software = true;
1259 // This is a resource allocated by the compositor, we need to produce it.
1262 GLC(gl, gl->BindTexture(resource->target, source->gl_id));
1263 GLC(gl, gl->GenMailboxCHROMIUM(resource->mailbox.name));
1265 gl->ProduceTextureCHROMIUM(resource->target, resource->mailbox.name));
1266 source->mailbox.SetName(resource->mailbox);
1269 // This is either an external resource, or a compositor resource that we
1271 resource->mailbox = source->mailbox.name();
1272 resource->sync_point = source->mailbox.sync_point();
1297 Resource& resource = it->second;
1299 DCHECK(!resource.locked_for_write);
1300 DCHECK(!resource.lock_for_read_count);
1308 resource.lost || (!resource.shared_bitmap && lost_output_surface_);
1309 if (resource.exported_count > 0) {
1311 // Defer this until we receive the resource back from the parent.
1312 resource.marked_for_deletion = true;
1320 if (gl && resource.filter != resource.original_filter) {
1321 DCHECK(resource.target);
1322 DCHECK(resource.gl_id);
1324 GLC(gl, gl->BindTexture(resource.target, resource.gl_id));
1326 gl->TexParameteri(resource.target,
1328 resource.original_filter));
1330 gl->TexParameteri(resource.target,
1332 resource.original_filter));
1337 returned.sync_point = resource.mailbox.sync_point();
1338 if (!returned.sync_point && !resource.shared_bitmap)
1340 returned.count = resource.imported_count;
1346 resource.imported_count = 0;
1369 Resource* resource = GetResource(id);
1370 DCHECK(!resource->external);
1371 DCHECK_EQ(resource->exported_count, 0);
1372 DCHECK(!resource->image_id);
1373 DCHECK_NE(ETC1, resource->format);
1375 if (resource->type == GLTexture) {
1378 if (!resource->gl_pixel_buffer_id)
1379 resource->gl_pixel_buffer_id = buffer_id_allocator_->NextId();
1381 resource->gl_pixel_buffer_id);
1382 unsigned bytes_per_pixel = BitsPerPixel(resource->format) / 8;
1384 resource->size.height() *
1385 RoundUp(bytes_per_pixel * resource->size.width(), 4u),
1391 if (resource->pixels) {
1392 if (resource->pixel_buffer)
1395 resource->pixel_buffer = new uint8_t[4 * resource->size.GetArea()];
1400 Resource* resource = GetResource(id);
1401 DCHECK(!resource->external);
1402 DCHECK_EQ(resource->exported_count, 0);
1403 DCHECK(!resource->image_id);
1409 // reuse any query id associated with this resource before they complete
1411 if (resource->pending_set_pixels) {
1412 DCHECK(resource->set_pixels_completion_forced);
1413 resource->pending_set_pixels = false;
1417 if (resource->type == GLTexture) {
1418 if (!resource->gl_pixel_buffer_id)
1423 resource->gl_pixel_buffer_id);
1429 if (resource->pixels) {
1430 if (!resource->pixel_buffer)
1432 delete[] resource->pixel_buffer;
1433 resource->pixel_buffer = NULL;
1438 Resource* resource = GetResource(id);
1439 DCHECK(!resource->external);
1440 DCHECK_EQ(resource->exported_count, 0);
1441 DCHECK(!resource->image_id);
1443 if (resource->type == GLTexture) {
1446 DCHECK(resource->gl_pixel_buffer_id);
1448 resource->gl_pixel_buffer_id);
1457 if (resource->pixels)
1458 return resource->pixel_buffer;
1464 Resource* resource = GetResource(id);
1465 DCHECK(!resource->external);
1466 DCHECK_EQ(resource->exported_count, 0);
1467 DCHECK(!resource->image_id);
1469 if (resource->type == GLTexture) {
1472 DCHECK(resource->gl_pixel_buffer_id);
1474 resource->gl_pixel_buffer_id);
1488 Resource* resource = &it->second;
1489 DCHECK(resource->lock_for_read_count);
1490 DCHECK(!resource->locked_for_write || resource->set_pixels_completion_forced);
1493 GLenum target = resource->target;
1494 GLC(gl, gl->BindTexture(target, resource->gl_id));
1495 if (filter != resource->filter) {
1498 resource->filter = filter;
1501 if (resource->image_id && resource->dirty_image) {
1503 if (resource->bound_image_id)
1504 gl->ReleaseTexImage2DCHROMIUM(target, resource->bound_image_id);
1505 gl->BindTexImage2DCHROMIUM(target, resource->image_id);
1506 resource->bound_image_id = resource->image_id;
1507 resource->dirty_image = false;
1514 Resourceresource = GetResource(id);
1515 DCHECK(!resource->pending_set_pixels);
1517 LazyCreate(resource);
1518 DCHECK(resource->gl_id || resource->allocated);
1519 DCHECK(ReadLockFenceHasPassed(resource));
1520 DCHECK(!resource->image_id);
1522 bool allocate = !resource->allocated;
1523 resource->allocated = true;
1526 if (resource->gl_id) {
1529 DCHECK(resource->gl_pixel_buffer_id);
1530 DCHECK_EQ(resource->target, static_cast<GLenum>(GL_TEXTURE_2D));
1531 gl->BindTexture(GL_TEXTURE_2D, resource->gl_id);
1533 resource->gl_pixel_buffer_id);
1534 if (!resource->gl_upload_query_id)
1535 gl->GenQueriesEXT(1, &resource->gl_upload_query_id);
1537 resource->gl_upload_query_id);
1541 GLInternalFormat(resource->format),
1542 resource->size.width(),
1543 resource->size.height(),
1545 GLDataFormat(resource->format),
1546 GLDataType(resource->format),
1553 resource->size.width(),
1554 resource->size.height(),
1555 GLDataFormat(resource->format),
1556 GLDataType(resource->format),
1563 if (resource->pixels) {
1564 DCHECK(!resource->mailbox.IsValid());
1565 DCHECK(resource->pixel_buffer);
1566 DCHECK_EQ(RGBA_8888, resource->format);
1568 std::swap(resource->pixels, resource->pixel_buffer);
1569 delete[] resource->pixel_buffer;
1570 resource->pixel_buffer = NULL;
1573 resource->pending_set_pixels = true;
1574 resource->set_pixels_completion_forced = false;
1578 Resource* resource = GetResource(id);
1579 DCHECK(resource->locked_for_write);
1580 DCHECK(resource->pending_set_pixels);
1581 DCHECK(!resource->set_pixels_completion_forced);
1583 if (resource->gl_id) {
1585 GLC(gl, gl->BindTexture(GL_TEXTURE_2D, resource->gl_id));
1590 resource->set_pixels_completion_forced = true;
1594 Resource* resource = GetResource(id);
1595 DCHECK(resource->locked_for_write);
1596 DCHECK(resource->pending_set_pixels);
1598 if (resource->gl_id) {
1601 DCHECK(resource->gl_upload_query_id);
1604 resource->gl_upload_query_id, GL_QUERY_RESULT_AVAILABLE_EXT, &complete);
1609 resource->pending_set_pixels = false;
1620 Resource* resource = GetResource(id);
1621 return resource->target;
1624 void ResourceProvider::LazyCreate(Resource* resource) {
1625 if (resource->type != GLTexture || resource->gl_id != 0)
1629 if (resource->texture_pool == 0)
1632 resource->gl_id = texture_id_allocator_->NextId();
1638 GLC(gl, gl->BindTexture(resource->target, resource->gl_id));
1640 gl->TexParameteri(resource->target, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
1642 gl->TexParameteri(resource->target, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
1645 resource->target, GL_TEXTURE_WRAP_S, resource->wrap_mode));
1648 resource->target, GL_TEXTURE_WRAP_T, resource->wrap_mode));
1651 resource->target, GL_TEXTURE_POOL_CHROMIUM, resource->texture_pool));
1652 if (use_texture_usage_hint_ && resource->hint == TextureUsageFramebuffer) {
1654 gl->TexParameteri(resource->target,
1664 void ResourceProvider::LazyAllocate(Resource* resource) {
1665 DCHECK(resource);
1666 LazyCreate(resource);
1668 DCHECK(resource->gl_id || resource->allocated);
1669 if (resource->allocated || !resource->gl_id)
1671 resource->allocated = true;
1673 gfx::Size& size = resource->size;
1674 DCHECK_EQ(resource->target, static_cast<GLenum>(GL_TEXTURE_2D));
1675 ResourceFormat format = resource->format;
1676 GLC(gl, gl->BindTexture(GL_TEXTURE_2D, resource->gl_id));
1678 resource->hint != TextureUsageFramebuffer) {
1702 Resource* resource = GetResource(id);
1703 resource->enable_read_lock_fences = enable;
1707 Resource* resource = GetResource(id);
1708 DCHECK(!resource->external);
1709 DCHECK_EQ(resource->exported_count, 0);
1711 if (resource->type != GLTexture)
1714 if (resource->image_id)
1717 resource->allocated = true;
1720 resource->image_id =
1721 gl->CreateImageCHROMIUM(resource->size.width(),
1722 resource->size.height(),
1723 TextureToStorageFormat(resource->format));
1724 DCHECK(resource->image_id);
1728 Resource* resource = GetResource(id);
1729 DCHECK(!resource->external);
1730 DCHECK_EQ(resource->exported_count, 0);
1732 if (!resource->image_id)
1737 gl->DestroyImageCHROMIUM(resource->image_id);
1738 resource->image_id = 0;
1739 resource->bound_image_id = 0;
1740 resource->dirty_image = false;
1741 resource->allocated = false;
1745 Resource* resource = GetResource(id);
1746 DCHECK(ReadLockFenceHasPassed(resource));
1747 DCHECK(!resource->external);
1748 DCHECK_EQ(resource->exported_count, 0);
1750 if (resource->image_id) {
1754 gl->MapImageCHROMIUM(resource->image_id, GL_READ_WRITE));
1757 if (resource->pixels)
1758 return resource->pixels;
1764 Resource* resource = GetResource(id);
1765 DCHECK(!resource->external);
1766 DCHECK_EQ(resource->exported_count, 0);
1768 if (resource->image_id) {
1771 gl->UnmapImageCHROMIUM(resource->image_id);
1772 resource->dirty_image = true;
1777 Resource* resource = GetResource(id);
1778 DCHECK(!resource->external);
1779 DCHECK_EQ(resource->exported_count, 0);
1783 if (resource->image_id) {
1787 resource->image_id, GL_IMAGE_ROWBYTES_CHROMIUM, &stride);
1794 Resource* resource = GetResource(id);
1795 DCHECK(!resource->external);
1796 DCHECK_EQ(resource->exported_count, 0);
1798 if (!resource->shared_bitmap)
1800 return resource->shared_bitmap->memory();