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

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

Issue 1379783002: Allow one-copy task tile worker pool to use compressed textures. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use memory_efficient_format* settings and revert allocation modifications Created 5 years 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
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 <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/atomic_sequence_num.h" 10 #include "base/atomic_sequence_num.h"
(...skipping 1485 matching lines...) Expand 10 before | Expand all | Expand 10 after
1496 LazyAllocate(GetResource(id)); 1496 LazyAllocate(GetResource(id));
1497 } 1497 }
1498 1498
1499 void ResourceProvider::LazyAllocate(Resource* resource) { 1499 void ResourceProvider::LazyAllocate(Resource* resource) {
1500 DCHECK(resource); 1500 DCHECK(resource);
1501 if (resource->allocated) 1501 if (resource->allocated)
1502 return; 1502 return;
1503 LazyCreate(resource); 1503 LazyCreate(resource);
1504 if (!resource->gl_id) 1504 if (!resource->gl_id)
1505 return; 1505 return;
1506 resource->allocated = true;
1507 GLES2Interface* gl = ContextGL(); 1506 GLES2Interface* gl = ContextGL();
1508 gfx::Size& size = resource->size; 1507 gfx::Size& size = resource->size;
1509 ResourceFormat format = resource->format; 1508 ResourceFormat format = resource->format;
1510 gl->BindTexture(resource->target, resource->gl_id); 1509 gl->BindTexture(resource->target, resource->gl_id);
1511 if (resource->type == RESOURCE_TYPE_GPU_MEMORY_BUFFER) { 1510 if (resource->type == RESOURCE_TYPE_GPU_MEMORY_BUFFER) {
1512 resource->gpu_memory_buffer = 1511 resource->gpu_memory_buffer =
1513 gpu_memory_buffer_manager_->AllocateGpuMemoryBuffer( 1512 gpu_memory_buffer_manager_->AllocateGpuMemoryBuffer(
1514 size, BufferFormat(format), 1513 size, BufferFormat(format),
1515 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE) 1514 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE)
1516 .release(); 1515 .release();
1517 LazyCreateImage(resource); 1516 LazyCreateImage(resource);
1518 resource->dirty_image = true; 1517 resource->dirty_image = true;
1519 resource->is_overlay_candidate = true; 1518 resource->is_overlay_candidate = true;
1520 } else if (use_texture_storage_ext_ && 1519 } else if (use_texture_storage_ext_ &&
1521 IsFormatSupportedForStorage(format, use_texture_format_bgra_) && 1520 IsFormatSupportedForStorage(format, use_texture_format_bgra_) &&
1522 (resource->hint & TEXTURE_HINT_IMMUTABLE)) { 1521 (resource->hint & TEXTURE_HINT_IMMUTABLE)) {
1523 GLenum storage_format = TextureToStorageFormat(format); 1522 GLenum storage_format = TextureToStorageFormat(format);
1524 gl->TexStorage2DEXT(resource->target, 1, storage_format, size.width(), 1523 gl->TexStorage2DEXT(resource->target, 1, storage_format, size.width(),
1525 size.height()); 1524 size.height());
1525 resource->allocated = true;
1526 } else { 1526 } else {
1527 // ETC1 does not support preallocation. 1527 // ETC1 does not support preallocation.
1528 if (format != ETC1) { 1528 if (format != ETC1) {
1529 gl->TexImage2D(resource->target, 0, GLInternalFormat(format), 1529 gl->TexImage2D(resource->target, 0, GLInternalFormat(format),
1530 size.width(), size.height(), 0, GLDataFormat(format), 1530 size.width(), size.height(), 0, GLDataFormat(format),
1531 GLDataType(format), NULL); 1531 GLDataType(format), NULL);
1532 resource->allocated = true;
1532 } 1533 }
1533 } 1534 }
1534 } 1535 }
1535 1536
1536 void ResourceProvider::LazyCreateImage(Resource* resource) { 1537 void ResourceProvider::LazyCreateImage(Resource* resource) {
1537 DCHECK(resource->gpu_memory_buffer); 1538 DCHECK(resource->gpu_memory_buffer);
1538 DCHECK(resource->gl_id); 1539 DCHECK(resource->gl_id);
1539 DCHECK(resource->allocated); 1540 DCHECK(resource->allocated);
1540 if (!resource->image_id) { 1541 if (!resource->image_id) {
1541 GLES2Interface* gl = ContextGL(); 1542 GLES2Interface* gl = ContextGL();
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1661 const int kImportance = 2; 1662 const int kImportance = 2;
1662 pmd->CreateSharedGlobalAllocatorDump(guid); 1663 pmd->CreateSharedGlobalAllocatorDump(guid);
1663 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); 1664 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance);
1664 } 1665 }
1665 } 1666 }
1666 1667
1667 return true; 1668 return true;
1668 } 1669 }
1669 1670
1670 } // namespace cc 1671 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698