OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "gpu/command_buffer/service/mailbox_manager_sync.h" | 5 #include "gpu/command_buffer/service/mailbox_manager_sync.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <queue> | 8 #include <queue> |
9 | 9 |
10 #include "base/memory/linked_ptr.h" | 10 #include "base/memory/linked_ptr.h" |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 } | 266 } |
267 | 267 |
268 void MailboxManagerSync::UpdateDefinitionLocked( | 268 void MailboxManagerSync::UpdateDefinitionLocked( |
269 Texture* texture, | 269 Texture* texture, |
270 TextureGroupRef* group_ref) { | 270 TextureGroupRef* group_ref) { |
271 g_lock.Get().AssertAcquired(); | 271 g_lock.Get().AssertAcquired(); |
272 | 272 |
273 if (SkipTextureWorkarounds(texture)) | 273 if (SkipTextureWorkarounds(texture)) |
274 return; | 274 return; |
275 | 275 |
276 gfx::GLImage* image = texture->GetLevelImage(texture->target(), 0); | 276 gfx::GLImage* gl_image = texture->GetLevelImage(texture->target(), 0); |
277 TextureGroup* group = group_ref->group.get(); | 277 TextureGroup* group = group_ref->group.get(); |
278 const TextureDefinition& definition = group->GetDefinition(); | 278 const TextureDefinition& definition = group->GetDefinition(); |
279 scoped_refptr<NativeImageBuffer> image_buffer = definition.image(); | 279 scoped_refptr<NativeImageBuffer> image_buffer = definition.image(); |
280 | 280 |
281 // Make sure we don't clobber with an older version | 281 // Make sure we don't clobber with an older version |
282 if (!definition.IsOlderThan(group_ref->version)) | 282 if (!definition.IsOlderThan(group_ref->version)) |
283 return; | 283 return; |
284 | 284 |
285 // Also don't push redundant updates. Note that it would break the | 285 // Also don't push redundant updates. Note that it would break the |
286 // versioning. | 286 // versioning. |
287 if (definition.Matches(texture)) | 287 if (definition.Matches(texture)) |
288 return; | 288 return; |
289 | 289 |
290 DCHECK_IMPLIES(image, image_buffer.get()); | 290 DCHECK_IMPLIES(gl_image, image_buffer.get()); |
291 if (image && !image_buffer->IsClient(image)) { | 291 if (gl_image && !image_buffer->IsClient(gl_image)) { |
292 LOG(ERROR) << "MailboxSync: Incompatible attachment"; | 292 LOG(ERROR) << "MailboxSync: Incompatible attachment"; |
293 return; | 293 return; |
294 } | 294 } |
295 | 295 |
296 group->SetDefinition(TextureDefinition(texture, ++group_ref->version, | 296 group->SetDefinition(TextureDefinition(texture, ++group_ref->version, |
297 image ? image_buffer : NULL)); | 297 gl_image ? image_buffer : NULL)); |
298 } | 298 } |
299 | 299 |
300 void MailboxManagerSync::PushTextureUpdates(const SyncToken& token) { | 300 void MailboxManagerSync::PushTextureUpdates(const SyncToken& token) { |
301 base::AutoLock lock(g_lock.Get()); | 301 base::AutoLock lock(g_lock.Get()); |
302 | 302 |
303 for (TextureToGroupMap::iterator it = texture_to_group_.begin(); | 303 for (TextureToGroupMap::iterator it = texture_to_group_.begin(); |
304 it != texture_to_group_.end(); it++) { | 304 it != texture_to_group_.end(); it++) { |
305 UpdateDefinitionLocked(it->first, &it->second); | 305 UpdateDefinitionLocked(it->first, &it->second); |
306 } | 306 } |
307 CreateFenceLocked(token); | 307 CreateFenceLocked(token); |
(...skipping 21 matching lines...) Expand all Loading... |
329 | 329 |
330 if (!needs_update.empty()) { | 330 if (!needs_update.empty()) { |
331 for (const TextureUpdatePair& pair : needs_update) { | 331 for (const TextureUpdatePair& pair : needs_update) { |
332 pair.second.UpdateTexture(pair.first); | 332 pair.second.UpdateTexture(pair.first); |
333 } | 333 } |
334 } | 334 } |
335 } | 335 } |
336 | 336 |
337 } // namespace gles2 | 337 } // namespace gles2 |
338 } // namespace gpu | 338 } // namespace gpu |
OLD | NEW |