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

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

Issue 132873006: cc: Add zero-copy texture update support to delegating renderer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove swap-fence related changes. Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « cc/resources/resource_provider.h ('k') | no next file » | 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 <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 1176 matching lines...) Expand 10 before | Expand all | Expand 10 after
1187 ResourceMap::iterator& map_iterator = sorted_resources[i].second; 1187 ResourceMap::iterator& map_iterator = sorted_resources[i].second;
1188 ResourceId local_id = map_iterator->first; 1188 ResourceId local_id = map_iterator->first;
1189 Resource* resource = &map_iterator->second; 1189 Resource* resource = &map_iterator->second;
1190 1190
1191 CHECK_GE(resource->exported_count, returned.count); 1191 CHECK_GE(resource->exported_count, returned.count);
1192 resource->exported_count -= returned.count; 1192 resource->exported_count -= returned.count;
1193 resource->lost |= returned.lost; 1193 resource->lost |= returned.lost;
1194 if (resource->exported_count) 1194 if (resource->exported_count)
1195 continue; 1195 continue;
1196 1196
1197 // Need to wait for the current read lock fence to pass before we can
1198 // recycle this resource.
1199 if (resource->enable_read_lock_fences)
1200 resource->read_lock_fence = current_read_lock_fence_;
1201
1197 if (resource->gl_id) { 1202 if (resource->gl_id) {
1198 if (returned.sync_point) 1203 if (returned.sync_point)
1199 GLC(gl, gl->WaitSyncPointCHROMIUM(returned.sync_point)); 1204 GLC(gl, gl->WaitSyncPointCHROMIUM(returned.sync_point));
1200 } else if (!resource->shared_bitmap) { 1205 } else if (!resource->shared_bitmap) {
1201 resource->mailbox = 1206 resource->mailbox =
1202 TextureMailbox(resource->mailbox.name(), returned.sync_point); 1207 TextureMailbox(resource->mailbox.name(), returned.sync_point);
1203 } 1208 }
1204 1209
1205 if (!resource->marked_for_deletion) 1210 if (!resource->marked_for_deletion)
1206 continue; 1211 continue;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1244 DCHECK(!source->lock_for_read_count); 1249 DCHECK(!source->lock_for_read_count);
1245 DCHECK(!source->external || (source->external && source->mailbox.IsValid())); 1250 DCHECK(!source->external || (source->external && source->mailbox.IsValid()));
1246 DCHECK(source->allocated); 1251 DCHECK(source->allocated);
1247 DCHECK_EQ(source->wrap_mode, GL_CLAMP_TO_EDGE); 1252 DCHECK_EQ(source->wrap_mode, GL_CLAMP_TO_EDGE);
1248 resource->id = id; 1253 resource->id = id;
1249 resource->format = source->format; 1254 resource->format = source->format;
1250 resource->target = source->target; 1255 resource->target = source->target;
1251 resource->filter = source->filter; 1256 resource->filter = source->filter;
1252 resource->size = source->size; 1257 resource->size = source->size;
1253 1258
1259 LazyCreate(source);
danakj 2014/01/16 17:55:52 Why this? You're transferring a resource that has
piman 2014/01/16 21:54:34 I don't think it's correct here, actually. This wo
reveman 2014/01/17 01:38:39 We've created and written to the GLImage but it ha
reveman 2014/01/17 01:38:39 Hm, is texture_pool not 0 in those cases? Makes se
1260
1254 if (source->shared_bitmap) { 1261 if (source->shared_bitmap) {
1255 resource->mailbox = source->shared_bitmap->id(); 1262 resource->mailbox = source->shared_bitmap->id();
1256 resource->is_software = true; 1263 resource->is_software = true;
1257 } else if (!source->mailbox.IsValid()) { 1264 } else if (!source->mailbox.IsValid()) {
1258 // This is a resource allocated by the compositor, we need to produce it. 1265 // This is a resource allocated by the compositor, we need to produce it.
1259 // Don't set a sync point, the caller will do it. 1266 // Don't set a sync point, the caller will do it.
1260 DCHECK(source->gl_id); 1267 DCHECK(source->gl_id);
1261 GLC(gl, gl->BindTexture(resource->target, source->gl_id)); 1268 GLC(gl, gl->BindTexture(resource->target, source->gl_id));
1269 if (source->image_id) {
1270 DCHECK(source->dirty_image);
1271 BindImageForSampling(source);
1272 }
1262 GLC(gl, gl->GenMailboxCHROMIUM(resource->mailbox.name)); 1273 GLC(gl, gl->GenMailboxCHROMIUM(resource->mailbox.name));
1263 GLC(gl, 1274 GLC(gl,
1264 gl->ProduceTextureCHROMIUM(resource->target, resource->mailbox.name)); 1275 gl->ProduceTextureCHROMIUM(resource->target, resource->mailbox.name));
1265 source->mailbox.SetName(resource->mailbox); 1276 source->mailbox.SetName(resource->mailbox);
1266 } else { 1277 } else {
1267 DCHECK(source->mailbox.IsTexture()); 1278 DCHECK(source->mailbox.IsTexture());
1279 if (source->image_id && source->dirty_image) {
piman 2014/01/16 21:54:34 Add a DCHECK(source->gl_id); The only reason we'd
reveman 2014/01/17 01:38:39 Done.
1280 GLC(gl, gl->BindTexture(resource->target, source->gl_id));
1281 BindImageForSampling(source);
1282 }
1268 // This is either an external resource, or a compositor resource that we 1283 // This is either an external resource, or a compositor resource that we
1269 // already exported. Make sure to forward the sync point that we were given. 1284 // already exported. Make sure to forward the sync point that we were given.
1270 resource->mailbox = source->mailbox.name(); 1285 resource->mailbox = source->mailbox.name();
1271 resource->sync_point = source->mailbox.sync_point(); 1286 resource->sync_point = source->mailbox.sync_point();
1272 source->mailbox.ResetSyncPoint(); 1287 source->mailbox.ResetSyncPoint();
1273 } 1288 }
1274 } 1289 }
1275 1290
1276 void ResourceProvider::DeleteAndReturnUnusedResourcesToChild( 1291 void ResourceProvider::DeleteAndReturnUnusedResourcesToChild(
1277 ChildMap::iterator child_it, 1292 ChildMap::iterator child_it,
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
1490 1505
1491 ScopedSetActiveTexture scoped_active_tex(gl, unit); 1506 ScopedSetActiveTexture scoped_active_tex(gl, unit);
1492 GLenum target = resource->target; 1507 GLenum target = resource->target;
1493 GLC(gl, gl->BindTexture(target, resource->gl_id)); 1508 GLC(gl, gl->BindTexture(target, resource->gl_id));
1494 if (filter != resource->filter) { 1509 if (filter != resource->filter) {
1495 GLC(gl, gl->TexParameteri(target, GL_TEXTURE_MIN_FILTER, filter)); 1510 GLC(gl, gl->TexParameteri(target, GL_TEXTURE_MIN_FILTER, filter));
1496 GLC(gl, gl->TexParameteri(target, GL_TEXTURE_MAG_FILTER, filter)); 1511 GLC(gl, gl->TexParameteri(target, GL_TEXTURE_MAG_FILTER, filter));
1497 resource->filter = filter; 1512 resource->filter = filter;
1498 } 1513 }
1499 1514
1500 if (resource->image_id && resource->dirty_image) { 1515 if (resource->image_id && resource->dirty_image)
1501 // Release image currently bound to texture. 1516 BindImageForSampling(resource);
1502 if (resource->bound_image_id)
1503 gl->ReleaseTexImage2DCHROMIUM(target, resource->bound_image_id);
1504 gl->BindTexImage2DCHROMIUM(target, resource->image_id);
1505 resource->bound_image_id = resource->image_id;
1506 resource->dirty_image = false;
1507 }
1508 1517
1509 return target; 1518 return target;
1510 } 1519 }
1511 1520
1512 void ResourceProvider::BeginSetPixels(ResourceId id) { 1521 void ResourceProvider::BeginSetPixels(ResourceId id) {
1513 Resource* resource = GetResource(id); 1522 Resource* resource = GetResource(id);
1514 DCHECK(!resource->pending_set_pixels); 1523 DCHECK(!resource->pending_set_pixels);
1515 1524
1516 LazyCreate(resource); 1525 LazyCreate(resource);
1517 DCHECK(resource->gl_id || resource->allocated); 1526 DCHECK(resource->gl_id || resource->allocated);
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1689 size.width(), 1698 size.width(),
1690 size.height(), 1699 size.height(),
1691 0, 1700 0,
1692 GLDataFormat(format), 1701 GLDataFormat(format),
1693 GLDataType(format), 1702 GLDataType(format),
1694 NULL)); 1703 NULL));
1695 } 1704 }
1696 } 1705 }
1697 } 1706 }
1698 1707
1708 void ResourceProvider::BindImageForSampling(Resource* resource) {
1709 GLES2Interface* gl = ContextGL();
1710 DCHECK(resource->gl_id);
1711 DCHECK(resource->image_id);
1712
1713 // Release image currently bound to texture.
1714 if (resource->bound_image_id)
1715 gl->ReleaseTexImage2DCHROMIUM(resource->target, resource->bound_image_id);
1716 gl->BindTexImage2DCHROMIUM(resource->target, resource->image_id);
1717 resource->bound_image_id = resource->image_id;
1718 resource->dirty_image = false;
1719 }
1720
1699 void ResourceProvider::EnableReadLockFences(ResourceProvider::ResourceId id, 1721 void ResourceProvider::EnableReadLockFences(ResourceProvider::ResourceId id,
1700 bool enable) { 1722 bool enable) {
1701 Resource* resource = GetResource(id); 1723 Resource* resource = GetResource(id);
1702 resource->enable_read_lock_fences = enable; 1724 resource->enable_read_lock_fences = enable;
1703 } 1725 }
1704 1726
1705 void ResourceProvider::AcquireImage(ResourceId id) { 1727 void ResourceProvider::AcquireImage(ResourceId id) {
1706 Resource* resource = GetResource(id); 1728 Resource* resource = GetResource(id);
1707 DCHECK(!resource->external); 1729 DCHECK(!resource->external);
1708 DCHECK_EQ(resource->exported_count, 0); 1730 DCHECK_EQ(resource->exported_count, 0);
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
1804 gl->GetIntegerv(GL_ACTIVE_TEXTURE, &active_unit); 1826 gl->GetIntegerv(GL_ACTIVE_TEXTURE, &active_unit);
1805 return active_unit; 1827 return active_unit;
1806 } 1828 }
1807 1829
1808 GLES2Interface* ResourceProvider::ContextGL() const { 1830 GLES2Interface* ResourceProvider::ContextGL() const {
1809 ContextProvider* context_provider = output_surface_->context_provider(); 1831 ContextProvider* context_provider = output_surface_->context_provider();
1810 return context_provider ? context_provider->ContextGL() : NULL; 1832 return context_provider ? context_provider->ContextGL() : NULL;
1811 } 1833 }
1812 1834
1813 } // namespace cc 1835 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/resource_provider.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698