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

Side by Side Diff: cc/resources/resource_provider.cc

Issue 2748903002: cc: Add gfx::BufferFormat to cc::ResourceProvider::Resource. (Closed)
Patch Set: Always initialize buffer_format. Created 3 years, 9 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 | « cc/resources/resource_provider.h ('k') | cc/resources/transferable_resource.h » ('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 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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 size(size), 249 size(size),
250 origin(origin), 250 origin(origin),
251 target(target), 251 target(target),
252 original_filter(filter), 252 original_filter(filter),
253 filter(filter), 253 filter(filter),
254 image_id(0), 254 image_id(0),
255 bound_image_id(0), 255 bound_image_id(0),
256 hint(hint), 256 hint(hint),
257 type(type), 257 type(type),
258 usage(gfx::BufferUsage::GPU_READ_CPU_READ_WRITE), 258 usage(gfx::BufferUsage::GPU_READ_CPU_READ_WRITE),
259 buffer_format(gfx::BufferFormat::RGBA_8888),
259 format(format), 260 format(format),
260 shared_bitmap(nullptr) { 261 shared_bitmap(nullptr) {
261 } 262 }
262 263
263 ResourceProvider::Resource::Resource(uint8_t* pixels, 264 ResourceProvider::Resource::Resource(uint8_t* pixels,
264 SharedBitmap* bitmap, 265 SharedBitmap* bitmap,
265 const gfx::Size& size, 266 const gfx::Size& size,
266 Origin origin, 267 Origin origin,
267 GLenum filter) 268 GLenum filter)
268 : child_id(0), 269 : child_id(0),
(...skipping 20 matching lines...) Expand all
289 read_lock_fence(nullptr), 290 read_lock_fence(nullptr),
290 size(size), 291 size(size),
291 origin(origin), 292 origin(origin),
292 target(0), 293 target(0),
293 original_filter(filter), 294 original_filter(filter),
294 filter(filter), 295 filter(filter),
295 image_id(0), 296 image_id(0),
296 bound_image_id(0), 297 bound_image_id(0),
297 hint(TEXTURE_HINT_IMMUTABLE), 298 hint(TEXTURE_HINT_IMMUTABLE),
298 type(RESOURCE_TYPE_BITMAP), 299 type(RESOURCE_TYPE_BITMAP),
300 buffer_format(gfx::BufferFormat::RGBA_8888),
299 format(RGBA_8888), 301 format(RGBA_8888),
300 shared_bitmap(bitmap) { 302 shared_bitmap(bitmap) {
301 DCHECK(origin == DELEGATED || pixels); 303 DCHECK(origin == DELEGATED || pixels);
302 if (bitmap) 304 if (bitmap)
303 shared_bitmap_id = bitmap->id(); 305 shared_bitmap_id = bitmap->id();
304 } 306 }
305 307
306 ResourceProvider::Resource::Resource(const SharedBitmapId& bitmap_id, 308 ResourceProvider::Resource::Resource(const SharedBitmapId& bitmap_id,
307 const gfx::Size& size, 309 const gfx::Size& size,
308 Origin origin, 310 Origin origin,
(...skipping 22 matching lines...) Expand all
331 read_lock_fence(nullptr), 333 read_lock_fence(nullptr),
332 size(size), 334 size(size),
333 origin(origin), 335 origin(origin),
334 target(0), 336 target(0),
335 original_filter(filter), 337 original_filter(filter),
336 filter(filter), 338 filter(filter),
337 image_id(0), 339 image_id(0),
338 bound_image_id(0), 340 bound_image_id(0),
339 hint(TEXTURE_HINT_IMMUTABLE), 341 hint(TEXTURE_HINT_IMMUTABLE),
340 type(RESOURCE_TYPE_BITMAP), 342 type(RESOURCE_TYPE_BITMAP),
343 buffer_format(gfx::BufferFormat::RGBA_8888),
341 format(RGBA_8888), 344 format(RGBA_8888),
342 shared_bitmap_id(bitmap_id), 345 shared_bitmap_id(bitmap_id),
343 shared_bitmap(nullptr) { 346 shared_bitmap(nullptr) {
344 } 347 }
345 348
346 ResourceProvider::Resource::Resource(Resource&& other) = default; 349 ResourceProvider::Resource::Resource(Resource&& other) = default;
347 350
348 void ResourceProvider::Resource::set_mailbox(const TextureMailbox& mailbox) { 351 void ResourceProvider::Resource::set_mailbox(const TextureMailbox& mailbox) {
349 mailbox_ = mailbox; 352 mailbox_ = mailbox;
350 if (IsGpuResourceType(type)) { 353 if (IsGpuResourceType(type)) {
(...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 return !resource->locked_for_write && !resource->lock_for_read_count && 1099 return !resource->locked_for_write && !resource->lock_for_read_count &&
1097 !resource->exported_count && resource->origin == Resource::INTERNAL && 1100 !resource->exported_count && resource->origin == Resource::INTERNAL &&
1098 !resource->lost && ReadLockFenceHasPassed(resource); 1101 !resource->lost && ReadLockFenceHasPassed(resource);
1099 } 1102 }
1100 1103
1101 bool ResourceProvider::IsOverlayCandidate(ResourceId id) { 1104 bool ResourceProvider::IsOverlayCandidate(ResourceId id) {
1102 Resource* resource = GetResource(id); 1105 Resource* resource = GetResource(id);
1103 return resource->is_overlay_candidate; 1106 return resource->is_overlay_candidate;
1104 } 1107 }
1105 1108
1109 gfx::BufferFormat ResourceProvider::GetBufferFormat(ResourceId id) {
1110 Resource* resource = GetResource(id);
1111 return resource->buffer_format;
1112 }
1113
1106 #if defined(OS_ANDROID) 1114 #if defined(OS_ANDROID)
1107 bool ResourceProvider::IsBackedBySurfaceTexture(ResourceId id) { 1115 bool ResourceProvider::IsBackedBySurfaceTexture(ResourceId id) {
1108 Resource* resource = GetResource(id); 1116 Resource* resource = GetResource(id);
1109 return resource->is_backed_by_surface_texture; 1117 return resource->is_backed_by_surface_texture;
1110 } 1118 }
1111 1119
1112 bool ResourceProvider::WantsPromotionHint(ResourceId id) { 1120 bool ResourceProvider::WantsPromotionHint(ResourceId id) {
1113 return wants_promotion_hints_set_.count(id) > 0; 1121 return wants_promotion_hints_set_.count(id) > 0;
1114 } 1122 }
1115 1123
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
1593 if (it->is_software) { 1601 if (it->is_software) {
1594 resource = InsertResource(local_id, 1602 resource = InsertResource(local_id,
1595 Resource(it->mailbox_holder.mailbox, it->size, 1603 Resource(it->mailbox_holder.mailbox, it->size,
1596 Resource::DELEGATED, GL_LINEAR)); 1604 Resource::DELEGATED, GL_LINEAR));
1597 } else { 1605 } else {
1598 resource = InsertResource( 1606 resource = InsertResource(
1599 local_id, Resource(0, it->size, Resource::DELEGATED, 1607 local_id, Resource(0, it->size, Resource::DELEGATED,
1600 it->mailbox_holder.texture_target, it->filter, 1608 it->mailbox_holder.texture_target, it->filter,
1601 TEXTURE_HINT_IMMUTABLE, RESOURCE_TYPE_GL_TEXTURE, 1609 TEXTURE_HINT_IMMUTABLE, RESOURCE_TYPE_GL_TEXTURE,
1602 it->format)); 1610 it->format));
1611 resource->buffer_format = it->buffer_format;
1603 resource->set_mailbox(TextureMailbox(it->mailbox_holder.mailbox, 1612 resource->set_mailbox(TextureMailbox(it->mailbox_holder.mailbox,
1604 it->mailbox_holder.sync_token, 1613 it->mailbox_holder.sync_token,
1605 it->mailbox_holder.texture_target)); 1614 it->mailbox_holder.texture_target));
1606 resource->read_lock_fences_enabled = it->read_lock_fences_enabled; 1615 resource->read_lock_fences_enabled = it->read_lock_fences_enabled;
1607 resource->is_overlay_candidate = it->is_overlay_candidate; 1616 resource->is_overlay_candidate = it->is_overlay_candidate;
1608 #if defined(OS_ANDROID) 1617 #if defined(OS_ANDROID)
1609 resource->is_backed_by_surface_texture = it->is_backed_by_surface_texture; 1618 resource->is_backed_by_surface_texture = it->is_backed_by_surface_texture;
1610 resource->wants_promotion_hint = it->wants_promotion_hint; 1619 resource->wants_promotion_hint = it->wants_promotion_hint;
1611 if (resource->wants_promotion_hint) 1620 if (resource->wants_promotion_hint)
1612 wants_promotion_hints_set_.insert(local_id); 1621 wants_promotion_hints_set_.insert(local_id);
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
1758 1767
1759 void ResourceProvider::TransferResource(Resource* source, 1768 void ResourceProvider::TransferResource(Resource* source,
1760 ResourceId id, 1769 ResourceId id,
1761 TransferableResource* resource) { 1770 TransferableResource* resource) {
1762 DCHECK(!source->locked_for_write); 1771 DCHECK(!source->locked_for_write);
1763 DCHECK(!source->lock_for_read_count); 1772 DCHECK(!source->lock_for_read_count);
1764 DCHECK(source->origin != Resource::EXTERNAL || source->mailbox().IsValid()); 1773 DCHECK(source->origin != Resource::EXTERNAL || source->mailbox().IsValid());
1765 DCHECK(source->allocated); 1774 DCHECK(source->allocated);
1766 resource->id = id; 1775 resource->id = id;
1767 resource->format = source->format; 1776 resource->format = source->format;
1777 resource->buffer_format = source->buffer_format;
1768 resource->mailbox_holder.texture_target = source->target; 1778 resource->mailbox_holder.texture_target = source->target;
1769 resource->filter = source->filter; 1779 resource->filter = source->filter;
1770 resource->size = source->size; 1780 resource->size = source->size;
1771 resource->read_lock_fences_enabled = source->read_lock_fences_enabled; 1781 resource->read_lock_fences_enabled = source->read_lock_fences_enabled;
1772 resource->is_overlay_candidate = source->is_overlay_candidate; 1782 resource->is_overlay_candidate = source->is_overlay_candidate;
1773 #if defined(OS_ANDROID) 1783 #if defined(OS_ANDROID)
1774 resource->is_backed_by_surface_texture = source->is_backed_by_surface_texture; 1784 resource->is_backed_by_surface_texture = source->is_backed_by_surface_texture;
1775 resource->wants_promotion_hint = source->wants_promotion_hint; 1785 resource->wants_promotion_hint = source->wants_promotion_hint;
1776 #endif 1786 #endif
1777 resource->color_space = source->color_space; 1787 resource->color_space = source->color_space;
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
2177 2187
2178 const int kImportance = 2; 2188 const int kImportance = 2;
2179 pmd->CreateSharedGlobalAllocatorDump(guid); 2189 pmd->CreateSharedGlobalAllocatorDump(guid);
2180 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); 2190 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance);
2181 } 2191 }
2182 2192
2183 return true; 2193 return true;
2184 } 2194 }
2185 2195
2186 } // namespace cc 2196 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/resource_provider.h ('k') | cc/resources/transferable_resource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698