Lines Matching refs:resource
69 ResourceProvider::Resource::Resource()
95 ResourceProvider::Resource::~Resource() {}
97 ResourceProvider::Resource::Resource(
129 ResourceProvider::Resource::Resource(
197 Resource* resource = &it->second;
198 return !!resource->lock_for_read_count || resource->exported;
215 LOG(FATAL) << "Invalid default resource type.";
233 LOG(FATAL) << "Invalid default resource type.";
244 Resource resource(0, size, format, GL_LINEAR, texture_pool, hint);
245 resource.allocated = false;
246 resources_[id] = resource;
256 Resource resource(pixels, size, GL_RGBA, GL_LINEAR);
257 resource.allocated = true;
258 resources_[id] = resource;
281 Resource resource(texture_id, gfx::Size(), 0, GL_LINEAR, 0, TextureUsageAny);
282 resource.external = true;
283 resource.allocated = true;
284 resources_[id] = resource;
294 Resource& resource = resources_[id];
296 resource = Resource(0, gfx::Size(), 0, GL_LINEAR, 0, TextureUsageAny);
302 resource = Resource(pixels, mailbox.shared_memory_size(),
305 resource.external = true;
306 resource.allocated = true;
307 resource.mailbox = mailbox;
315 Resource* resource = &it->second;
316 DCHECK(!resource->lock_for_read_count);
317 DCHECK(!resource->marked_for_deletion);
318 DCHECK(resource->pending_set_pixels || !resource->locked_for_write);
320 if (resource->exported) {
321 resource->marked_for_deletion = true;
330 Resource* resource = &it->second;
333 DCHECK(!resource->exported || style != Normal);
334 if (style == ForShutdown && resource->exported)
337 if (resource->image_id) {
340 GLC(context3d, context3d->destroyImageCHROMIUM(resource->image_id));
343 if (resource->gl_id && !resource->external) {
346 GLC(context3d, context3d->deleteTexture(resource->gl_id));
348 if (resource->gl_upload_query_id) {
351 GLC(context3d, context3d->deleteQueryEXT(resource->gl_upload_query_id));
353 if (resource->gl_pixel_buffer_id) {
356 GLC(context3d, context3d->deleteBuffer(resource->gl_pixel_buffer_id));
358 if (resource->mailbox.IsValid() && resource->external) {
359 unsigned sync_point = resource->mailbox.sync_point();
360 if (resource->mailbox.IsTexture()) {
363 if (resource->gl_id)
364 GLC(context3d, context3d->deleteTexture(resource->gl_id));
365 if (!lost_resource && resource->gl_id)
368 DCHECK(resource->mailbox.IsSharedMemory());
369 base::SharedMemory* shared_memory = resource->mailbox.shared_memory();
370 if (resource->pixels && shared_memory) {
371 DCHECK(shared_memory->memory() == resource->pixels);
372 resource->pixels = NULL;
375 resource->mailbox.RunReleaseCallback(sync_point, lost_resource);
377 if (resource->pixels)
378 delete[] resource->pixels;
379 if (resource->pixel_buffer)
380 delete[] resource->pixel_buffer;
389 Resource* resource = &it->second;
390 return resource->type;
401 Resource* resource = &it->second;
402 DCHECK(!resource->locked_for_write);
403 DCHECK(!resource->lock_for_read_count);
404 DCHECK(!resource->external);
405 DCHECK(!resource->exported);
406 DCHECK(ReadLockFenceHasPassed(resource));
407 LazyAllocate(resource);
409 if (resource->gl_id) {
410 DCHECK(!resource->pending_set_pixels);
414 context3d->bindTexture(GL_TEXTURE_2D, resource->gl_id);
419 resource->format,
420 resource->size);
423 if (resource->pixels) {
424 DCHECK(resource->allocated);
425 DCHECK(resource->format == GL_RGBA);
503 const ResourceProvider::Resource* ResourceProvider::LockForRead(ResourceId id) {
507 Resource* resource = &it->second;
508 DCHECK(!resource->locked_for_write ||
509 resource->set_pixels_completion_forced) <<
510 "locked for write: " << resource->locked_for_write <<
511 " pixels completion forced: " << resource->set_pixels_completion_forced;
512 DCHECK(!resource->exported);
514 DCHECK(resource->allocated);
516 LazyCreate(resource);
518 if (resource->external) {
519 if (!resource->gl_id && resource->mailbox.IsTexture()) {
522 if (resource->mailbox.sync_point()) {
524 resource->mailbox.sync_point()));
525 resource->mailbox.ResetSyncPoint();
527 resource->gl_id = context3d->createTexture();
529 resource->mailbox.target(), resource->gl_id));
531 resource->mailbox.target(), resource->mailbox.data()));
535 resource->lock_for_read_count++;
536 if (resource->enable_read_lock_fences)
537 resource->read_lock_fence = current_read_lock_fence_;
539 return resource;
546 Resource* resource = &it->second;
547 DCHECK_GT(resource->lock_for_read_count, 0);
548 DCHECK(!resource->exported);
549 resource->lock_for_read_count--;
552 const ResourceProvider::Resource* ResourceProvider::LockForWrite(
557 Resource* resource = &it->second;
558 DCHECK(!resource->locked_for_write);
559 DCHECK(!resource->lock_for_read_count);
560 DCHECK(!resource->exported);
561 DCHECK(!resource->external);
562 DCHECK(ReadLockFenceHasPassed(resource));
563 LazyAllocate(resource);
565 resource->locked_for_write = true;
566 return resource;
573 Resource* resource = &it->second;
574 return !resource->locked_for_write &&
575 !resource->lock_for_read_count &&
576 !resource->exported &&
577 !resource->external &&
578 ReadLockFenceHasPassed(resource);
585 Resource* resource = &it->second;
586 DCHECK(resource->locked_for_write);
587 DCHECK(!resource->exported);
588 DCHECK(!resource->external);
589 resource->locked_for_write = false;
645 SkBitmap* sk_bitmap, const Resource* resource) {
646 DCHECK(resource->pixels);
647 DCHECK(resource->format == GL_RGBA);
649 resource->size.width(),
650 resource->size.height());
651 sk_bitmap->setPixels(resource->pixels);
802 TransferableResource resource;
803 if (TransferResource(context3d, *it, &resource)) {
804 if (!resource.sync_point)
807 list->push_back(resource);
835 TransferableResource resource;
836 if (!TransferResource(context3d, *it, &resource))
838 if (!resource.sync_point)
842 resource.id = child_info.parent_to_child_map[*it];
844 child_info.child_to_parent_map.erase(resource.id);
845 list->push_back(resource);
885 Resource resource(
887 resource.mailbox.SetName(it->mailbox);
889 resource.allocated = true;
890 resources_[id] = resource;
909 Resource* resource = &map_iterator->second;
910 DCHECK(resource->exported);
911 resource->exported = false;
912 resource->filter = it->filter;
913 DCHECK(resource->mailbox.ContainsMailbox(it->mailbox));
914 if (resource->gl_id) {
918 resource->mailbox = TextureMailbox(resource->mailbox.name(),
919 resource->mailbox.callback(),
922 if (resource->marked_for_deletion)
929 TransferableResource* resource) {
933 Resource* source = &it->second;
940 resource->id = id;
941 resource->format = source->format;
942 resource->filter = source->filter;
943 resource->size = source->size;
949 // This is a resource allocated by the compositor, we need to produce it.
953 GLC(context, context->genMailboxCHROMIUM(resource->mailbox.name));
955 resource->mailbox.name));
956 source->mailbox.SetName(resource->mailbox);
958 // This is either an external resource, or a compositor resource that we
960 resource->mailbox = source->mailbox.name();
961 resource->sync_point = source->mailbox.sync_point();
972 Resource* resource = &it->second;
973 DCHECK(!resource->external);
974 DCHECK(!resource->exported);
975 DCHECK(!resource->image_id);
977 if (resource->type == GLTexture) {
980 if (!resource->gl_pixel_buffer_id)
981 resource->gl_pixel_buffer_id = context3d->createBuffer();
984 resource->gl_pixel_buffer_id);
987 4 * resource->size.GetArea(),
993 if (resource->pixels) {
994 if (resource->pixel_buffer)
997 resource->pixel_buffer = new uint8_t[4 * resource->size.GetArea()];
1005 Resource* resource = &it->second;
1006 DCHECK(!resource->external);
1007 DCHECK(!resource->exported);
1008 DCHECK(!resource->image_id);
1014 // reuse any query id associated with this resource before they complete
1016 if (resource->pending_set_pixels) {
1017 DCHECK(resource->set_pixels_completion_forced);
1018 resource->pending_set_pixels = false;
1022 if (resource->type == GLTexture) {
1023 if (!resource->gl_pixel_buffer_id)
1029 resource->gl_pixel_buffer_id);
1038 if (resource->pixels) {
1039 if (!resource->pixel_buffer)
1041 delete[] resource->pixel_buffer;
1042 resource->pixel_buffer = NULL;
1050 Resource* resource = &it->second;
1051 DCHECK(!resource->external);
1052 DCHECK(!resource->exported);
1053 DCHECK(!resource->image_id);
1055 if (resource->type == GLTexture) {
1058 DCHECK(resource->gl_pixel_buffer_id);
1061 resource->gl_pixel_buffer_id);
1071 if (resource->pixels)
1072 return resource->pixel_buffer;
1081 Resource* resource = &it->second;
1082 DCHECK(!resource->external);
1083 DCHECK(!resource->exported);
1084 DCHECK(!resource->image_id);
1086 if (resource->type == GLTexture) {
1089 DCHECK(resource->gl_pixel_buffer_id);
1092 resource->gl_pixel_buffer_id);
1106 Resource* resource = &it->second;
1107 DCHECK(resource->lock_for_read_count);
1108 DCHECK(!resource->locked_for_write || resource->set_pixels_completion_forced);
1113 GLC(context3d, context3d->bindTexture(target, resource->gl_id));
1114 if (filter != resource->filter) {
1121 resource->filter = filter;
1124 if (resource->image_id && resource->dirty_image) {
1126 if (resource->bound_image_id)
1127 context3d->releaseTexImage2DCHROMIUM(target, resource->bound_image_id);
1128 context3d->bindTexImage2DCHROMIUM(target, resource->image_id);
1129 resource->bound_image_id = resource->image_id;
1130 resource->dirty_image = false;
1142 Resource* resource = &it->second;
1143 DCHECK(!resource->pending_set_pixels);
1145 LazyCreate(resource);
1146 DCHECK(resource->gl_id || resource->allocated);
1147 DCHECK(ReadLockFenceHasPassed(resource));
1148 DCHECK(!resource->image_id);
1150 bool allocate = !resource->allocated;
1151 resource->allocated = true;
1154 if (resource->gl_id) {
1157 DCHECK(resource->gl_pixel_buffer_id);
1158 context3d->bindTexture(GL_TEXTURE_2D, resource->gl_id);
1161 resource->gl_pixel_buffer_id);
1162 if (!resource->gl_upload_query_id)
1163 resource->gl_upload_query_id = context3d->createQueryEXT();
1166 resource->gl_upload_query_id);
1170 resource->format,
1171 resource->size.width(),
1172 resource->size.height(),
1174 resource->format,
1182 resource->size.width(),
1183 resource->size.height(),
1184 resource->format,
1192 if (resource->pixels) {
1193 DCHECK(!resource->mailbox.IsValid());
1194 DCHECK(resource->pixel_buffer);
1195 DCHECK(resource->format == GL_RGBA);
1197 std::swap(resource->pixels, resource->pixel_buffer);
1198 delete[] resource->pixel_buffer;
1199 resource->pixel_buffer = NULL;
1202 resource->pending_set_pixels = true;
1203 resource->set_pixels_completion_forced = false;
1210 Resource* resource = &it->second;
1211 DCHECK(resource->locked_for_write);
1212 DCHECK(resource->pending_set_pixels);
1213 DCHECK(!resource->set_pixels_completion_forced);
1215 if (resource->gl_id) {
1217 GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, resource->gl_id));
1222 resource->set_pixels_completion_forced = true;
1229 Resource* resource = &it->second;
1230 DCHECK(resource->locked_for_write);
1231 DCHECK(resource->pending_set_pixels);
1233 if (resource->gl_id) {
1236 DCHECK(resource->gl_upload_query_id);
1239 resource->gl_upload_query_id,
1246 resource->pending_set_pixels = false;
1255 Resource* resource = &it->second;
1256 LazyCreate(resource);
1259 void ResourceProvider::LazyCreate(Resource* resource) {
1260 if (resource->type != GLTexture || resource->gl_id != 0)
1264 if (resource->texture_pool == 0)
1270 resource->gl_id = CreateTextureId(context3d);
1273 resource->texture_pool));
1274 if (use_texture_usage_hint_ && resource->hint == TextureUsageFramebuffer) {
1284 Resource* resource = &it->second;
1285 LazyAllocate(resource);
1288 void ResourceProvider::LazyAllocate(Resource* resource) {
1289 DCHECK(resource);
1290 LazyCreate(resource);
1292 DCHECK(resource->gl_id || resource->allocated);
1293 if (resource->allocated || !resource->gl_id)
1295 resource->allocated = true;
1297 gfx::Size& size = resource->size;
1298 GLenum format = resource->format;
1299 GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, resource->gl_id));
1325 Resource* resource = &it->second;
1326 resource->enable_read_lock_fences = enable;
1333 Resource* resource = &it->second;
1335 DCHECK(!resource->external);
1336 DCHECK(!resource->exported);
1338 if (resource->type != GLTexture)
1341 if (resource->image_id)
1344 resource->allocated = true;
1347 resource->image_id = context3d->createImageCHROMIUM(
1348 resource->size.width(), resource->size.height(), GL_RGBA8_OES);
1349 DCHECK(resource->image_id);
1356 Resource* resource = &it->second;
1358 DCHECK(!resource->external);
1359 DCHECK(!resource->exported);
1361 if (!resource->image_id)
1366 context3d->destroyImageCHROMIUM(resource->image_id);
1367 resource->image_id = 0;
1368 resource->bound_image_id = 0;
1369 resource->dirty_image = false;
1370 resource->allocated = false;
1377 Resource* resource = &it->second;
1379 DCHECK(ReadLockFenceHasPassed(resource));
1380 DCHECK(!resource->external);
1381 DCHECK(!resource->exported);
1383 if (resource->image_id) {
1387 context3d->mapImageCHROMIUM(resource->image_id, GL_READ_WRITE));
1390 if (resource->pixels)
1391 return resource->pixels;
1400 Resource* resource = &it->second;
1402 DCHECK(!resource->external);
1403 DCHECK(!resource->exported);
1405 if (resource->image_id) {
1408 context3d->unmapImageCHROMIUM(resource->image_id);
1409 resource->dirty_image = true;
1417 Resource* resource = &it->second;
1419 DCHECK(!resource->external);
1420 DCHECK(!resource->exported);
1424 if (resource->image_id) {
1428 resource->image_id, GL_IMAGE_ROWBYTES_CHROMIUM, &stride);