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

Side by Side Diff: cc/resource_provider.cc

Issue 12321053: cc: Complete pending tile uploads if they are needed for tree activation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Only flush when not in smoothness/animations Created 7 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 | Annotate | Revision Log
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/resource_provider.h" 5 #include "cc/resource_provider.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 8
9 #include "base/debug/alias.h" 9 #include "base/debug/alias.h"
10 #include "base/hash_tables.h" 10 #include "base/hash_tables.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 gl_pixel_buffer_id(0), 67 gl_pixel_buffer_id(0),
68 gl_upload_query_id(0), 68 gl_upload_query_id(0),
69 pixels(NULL), 69 pixels(NULL),
70 pixel_buffer(NULL), 70 pixel_buffer(NULL),
71 lock_for_read_count(0), 71 lock_for_read_count(0),
72 locked_for_write(false), 72 locked_for_write(false),
73 external(false), 73 external(false),
74 exported(false), 74 exported(false),
75 marked_for_deletion(false), 75 marked_for_deletion(false),
76 pending_set_pixels(false), 76 pending_set_pixels(false),
77 wait_for_set_pixels_inserted(false),
77 allocated(false), 78 allocated(false),
78 enable_read_lock_fences(false), 79 enable_read_lock_fences(false),
79 read_lock_fence(NULL), 80 read_lock_fence(NULL),
80 size(), 81 size(),
81 format(0), 82 format(0),
82 filter(0), 83 filter(0),
83 type(static_cast<ResourceType>(0)) {} 84 type(static_cast<ResourceType>(0)) {}
84 85
85 ResourceProvider::Resource::~Resource() {} 86 ResourceProvider::Resource::~Resource() {}
86 87
87 ResourceProvider::Resource::Resource( 88 ResourceProvider::Resource::Resource(
88 unsigned texture_id, gfx::Size size, GLenum format, GLenum filter) 89 unsigned texture_id, gfx::Size size, GLenum format, GLenum filter)
89 : gl_id(texture_id), 90 : gl_id(texture_id),
90 gl_pixel_buffer_id(0), 91 gl_pixel_buffer_id(0),
91 gl_upload_query_id(0), 92 gl_upload_query_id(0),
92 pixels(NULL), 93 pixels(NULL),
93 pixel_buffer(NULL), 94 pixel_buffer(NULL),
94 lock_for_read_count(0), 95 lock_for_read_count(0),
95 locked_for_write(false), 96 locked_for_write(false),
96 external(false), 97 external(false),
97 exported(false), 98 exported(false),
98 marked_for_deletion(false), 99 marked_for_deletion(false),
99 pending_set_pixels(false), 100 pending_set_pixels(false),
101 wait_for_set_pixels_inserted(false),
100 allocated(false), 102 allocated(false),
101 enable_read_lock_fences(false), 103 enable_read_lock_fences(false),
102 read_lock_fence(NULL), 104 read_lock_fence(NULL),
103 size(size), 105 size(size),
104 format(format), 106 format(format),
105 filter(filter), 107 filter(filter),
106 type(GLTexture) {} 108 type(GLTexture) {}
107 109
108 ResourceProvider::Resource::Resource( 110 ResourceProvider::Resource::Resource(
109 uint8_t* pixels, gfx::Size size, GLenum format, GLenum filter) 111 uint8_t* pixels, gfx::Size size, GLenum format, GLenum filter)
110 : gl_id(0), 112 : gl_id(0),
111 gl_pixel_buffer_id(0), 113 gl_pixel_buffer_id(0),
112 gl_upload_query_id(0), 114 gl_upload_query_id(0),
113 pixels(pixels), 115 pixels(pixels),
114 pixel_buffer(NULL), 116 pixel_buffer(NULL),
115 lock_for_read_count(0), 117 lock_for_read_count(0),
116 locked_for_write(false), 118 locked_for_write(false),
117 external(false), 119 external(false),
118 exported(false), 120 exported(false),
119 marked_for_deletion(false), 121 marked_for_deletion(false),
120 pending_set_pixels(false), 122 pending_set_pixels(false),
123 wait_for_set_pixels_inserted(false),
121 allocated(false), 124 allocated(false),
122 enable_read_lock_fences(false), 125 enable_read_lock_fences(false),
123 read_lock_fence(NULL), 126 read_lock_fence(NULL),
124 size(size), 127 size(size),
125 format(format), 128 format(format),
126 filter(filter), 129 filter(filter),
127 type(Bitmap) {} 130 type(Bitmap) {}
128 131
129 ResourceProvider::Child::Child() {} 132 ResourceProvider::Child::Child() {}
130 133
(...skipping 949 matching lines...) Expand 10 before | Expand all | Expand 10 after
1080 context3d->endQueryEXT(GL_ASYNC_PIXEL_TRANSFERS_COMPLETED_CHROMIUM); 1083 context3d->endQueryEXT(GL_ASYNC_PIXEL_TRANSFERS_COMPLETED_CHROMIUM);
1081 context3d->bindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0); 1084 context3d->bindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0);
1082 } 1085 }
1083 1086
1084 if (resource->pixels) 1087 if (resource->pixels)
1085 SetPixelsFromBuffer(id); 1088 SetPixelsFromBuffer(id);
1086 1089
1087 resource->pending_set_pixels = true; 1090 resource->pending_set_pixels = true;
1088 } 1091 }
1089 1092
1093 void ResourceProvider::InsertWaitForSetPixels(ResourceId id) {
1094 DCHECK(thread_checker_.CalledOnValidThread());
1095 ResourceMap::iterator it = resources_.find(id);
1096 CHECK(it != resources_.end());
1097 Resource* resource = &it->second;
1098 DCHECK(resource->locked_for_write);
1099 DCHECK(resource->pending_set_pixels);
1100 DCHECK(!resource->wait_for_set_pixels_inserted);
1101
1102 if (resource->gl_id) {
1103 WebGraphicsContext3D* context3d = output_surface_->context3d();
1104 GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, resource->gl_id));
1105 GLC(context3d, context3d->waitAsyncTexImage2DCHROMIUM(GL_TEXTURE_2D));
1106 GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, 0));
1107 }
1108
1109 UnlockForWrite(id);
1110 resource->wait_for_set_pixels_inserted = true;
1111 }
1112
1090 bool ResourceProvider::DidSetPixelsComplete(ResourceId id) { 1113 bool ResourceProvider::DidSetPixelsComplete(ResourceId id) {
1091 DCHECK(thread_checker_.CalledOnValidThread()); 1114 DCHECK(thread_checker_.CalledOnValidThread());
1092 ResourceMap::iterator it = resources_.find(id); 1115 ResourceMap::iterator it = resources_.find(id);
1093 CHECK(it != resources_.end()); 1116 CHECK(it != resources_.end());
1094 Resource* resource = &it->second; 1117 Resource* resource = &it->second;
1095 DCHECK(resource->locked_for_write); 1118 DCHECK(resource->locked_for_write || resource->wait_for_set_pixels_inserted);
1096 DCHECK(resource->pending_set_pixels); 1119 DCHECK(resource->pending_set_pixels);
1097 1120
1098 if (resource->gl_id) { 1121 if (resource->gl_id) {
1099 WebGraphicsContext3D* context3d = output_surface_->context3d(); 1122 WebGraphicsContext3D* context3d = output_surface_->context3d();
1100 DCHECK(context3d); 1123 DCHECK(context3d);
1101 DCHECK(resource->gl_upload_query_id); 1124 DCHECK(resource->gl_upload_query_id);
1102 unsigned complete = 1; 1125 unsigned complete = 1;
1103 context3d->getQueryObjectuivEXT( 1126 context3d->getQueryObjectuivEXT(
1104 resource->gl_upload_query_id, 1127 resource->gl_upload_query_id,
1105 GL_QUERY_RESULT_AVAILABLE_EXT, 1128 GL_QUERY_RESULT_AVAILABLE_EXT,
1106 &complete); 1129 &complete);
1107 if (!complete) 1130 if (!complete)
1108 return false; 1131 return false;
1109 } 1132 }
1110 1133
1111 resource->pending_set_pixels = false; 1134 resource->pending_set_pixels = false;
1112 UnlockForWrite(id); 1135 if (!resource->wait_for_set_pixels_inserted)
1136 UnlockForWrite(id);
epenner 2013/03/11 19:18:40 Can you explain why we do this only when there is
Sami 2013/03/12 14:13:07 I guess the confusion comes from the fact that for
1137 resource->wait_for_set_pixels_inserted = false;
1113 1138
1114 return true; 1139 return true;
1115 } 1140 }
1116 1141
1117 void ResourceProvider::AbortSetPixels(ResourceId id) { 1142 void ResourceProvider::AbortSetPixels(ResourceId id) {
1118 DCHECK(thread_checker_.CalledOnValidThread()); 1143 DCHECK(thread_checker_.CalledOnValidThread());
1119 ResourceMap::iterator it = resources_.find(id); 1144 ResourceMap::iterator it = resources_.find(id);
1120 CHECK(it != resources_.end()); 1145 CHECK(it != resources_.end());
1121 Resource* resource = &it->second; 1146 Resource* resource = &it->second;
1122 DCHECK(resource->locked_for_write); 1147 DCHECK(resource->locked_for_write);
reveman 2013/03/12 06:25:58 you need a "|| resource->wait_for_set_pixels_inser
Sami 2013/03/12 14:13:07 Well spotted, done.
1123 DCHECK(resource->pending_set_pixels); 1148 DCHECK(resource->pending_set_pixels);
1124 1149
1125 if (resource->gl_id) { 1150 if (resource->gl_id) {
1126 WebGraphicsContext3D* context3d = output_surface_->context3d(); 1151 WebGraphicsContext3D* context3d = output_surface_->context3d();
1127 DCHECK(context3d); 1152 DCHECK(context3d);
1128 DCHECK(resource->gl_upload_query_id); 1153 DCHECK(resource->gl_upload_query_id);
1129 // CHROMIUM_async_pixel_transfers currently doesn't have a way to 1154 // CHROMIUM_async_pixel_transfers currently doesn't have a way to
1130 // abort an upload. The best we can do is delete the query and 1155 // abort an upload. The best we can do is delete the query and
1131 // the texture. 1156 // the texture.
1132 context3d->deleteQueryEXT(resource->gl_upload_query_id); 1157 context3d->deleteQueryEXT(resource->gl_upload_query_id);
1133 resource->gl_upload_query_id = 0; 1158 resource->gl_upload_query_id = 0;
1134 context3d->deleteTexture(resource->gl_id); 1159 context3d->deleteTexture(resource->gl_id);
1135 resource->gl_id = CreateTextureId(context3d); 1160 resource->gl_id = CreateTextureId(context3d);
1136 resource->allocated = false; 1161 resource->allocated = false;
1137 } 1162 }
1138 1163
1139 resource->pending_set_pixels = false; 1164 resource->pending_set_pixels = false;
1140 UnlockForWrite(id); 1165 UnlockForWrite(id);
reveman 2013/03/12 06:25:58 and you'll need your wait_for_set_pixels_inserted
Sami 2013/03/12 14:13:07 Done.
1141 } 1166 }
1142 1167
1143 void ResourceProvider::AllocateForTesting(ResourceId id) { 1168 void ResourceProvider::AllocateForTesting(ResourceId id) {
1144 ResourceMap::iterator it = resources_.find(id); 1169 ResourceMap::iterator it = resources_.find(id);
1145 CHECK(it != resources_.end()); 1170 CHECK(it != resources_.end());
1146 Resource* resource = &it->second; 1171 Resource* resource = &it->second;
1147 LazyAllocate(resource); 1172 LazyAllocate(resource);
1148 } 1173 }
1149 1174
1150 void ResourceProvider::LazyAllocate(Resource* resource) { 1175 void ResourceProvider::LazyAllocate(Resource* resource) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1187 } 1212 }
1188 1213
1189 void ResourceProvider::SetOffscreenContextProvider( 1214 void ResourceProvider::SetOffscreenContextProvider(
1190 scoped_refptr<cc::ContextProvider> offscreen_context_provider) { 1215 scoped_refptr<cc::ContextProvider> offscreen_context_provider) {
1191 if (offscreen_context_provider) 1216 if (offscreen_context_provider)
1192 offscreen_context_provider->BindToCurrentThread(); 1217 offscreen_context_provider->BindToCurrentThread();
1193 offscreen_context_provider_ = offscreen_context_provider; 1218 offscreen_context_provider_ = offscreen_context_provider;
1194 } 1219 }
1195 1220
1196 } // namespace cc 1221 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698