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

Side by Side Diff: Source/platform/graphics/Canvas2DLayerBridge.cpp

Issue 141273002: Code problems detected by cppcheck (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add a few more fixes 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 GraphicsLayer::registerContentsLayer(m_layer->layer()); 94 GraphicsLayer::registerContentsLayer(m_layer->layer());
95 m_layer->setRateLimitContext(m_rateLimitingEnabled); 95 m_layer->setRateLimitContext(m_rateLimitingEnabled);
96 m_canvas->setNotificationClient(this); 96 m_canvas->setNotificationClient(this);
97 } 97 }
98 98
99 Canvas2DLayerBridge::~Canvas2DLayerBridge() 99 Canvas2DLayerBridge::~Canvas2DLayerBridge()
100 { 100 {
101 ASSERT(m_destructionInProgress); 101 ASSERT(m_destructionInProgress);
102 m_layer.clear(); 102 m_layer.clear();
103 Vector<MailboxInfo>::iterator mailboxInfo; 103 Vector<MailboxInfo>::iterator mailboxInfo;
104 for (mailboxInfo = m_mailboxes.begin(); mailboxInfo < m_mailboxes.end(); mai lboxInfo++) { 104 for (mailboxInfo = m_mailboxes.begin(); mailboxInfo < m_mailboxes.end(); ++m ailboxInfo) {
105 ASSERT(mailboxInfo->m_status != MailboxInUse); 105 ASSERT(mailboxInfo->m_status != MailboxInUse);
106 if (mailboxInfo->m_status == MailboxReleased) { 106 if (mailboxInfo->m_status == MailboxReleased) {
107 if (mailboxInfo->m_mailbox.syncPoint) { 107 if (mailboxInfo->m_mailbox.syncPoint) {
108 context()->waitSyncPoint(mailboxInfo->m_mailbox.syncPoint); 108 context()->waitSyncPoint(mailboxInfo->m_mailbox.syncPoint);
109 mailboxInfo->m_mailbox.syncPoint = 0; 109 mailboxInfo->m_mailbox.syncPoint = 0;
110 } 110 }
111 // Invalidate texture state in case the compositor altered it since the copy-on-write. 111 // Invalidate texture state in case the compositor altered it since the copy-on-write.
112 mailboxInfo->m_image->getTexture()->invalidateCachedState(); 112 mailboxInfo->m_image->getTexture()->invalidateCachedState();
113 } 113 }
114 } 114 }
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 return false; 271 return false;
272 } 272 }
273 if (!isValid()) 273 if (!isValid())
274 return false; 274 return false;
275 // Release to skia textures that were previouosly released by the 275 // Release to skia textures that were previouosly released by the
276 // compositor. We do this before acquiring the next snapshot in 276 // compositor. We do this before acquiring the next snapshot in
277 // order to cap maximum gpu memory consumption. 277 // order to cap maximum gpu memory consumption.
278 m_context->makeContextCurrent(); 278 m_context->makeContextCurrent();
279 flush(); 279 flush();
280 Vector<MailboxInfo>::iterator mailboxInfo; 280 Vector<MailboxInfo>::iterator mailboxInfo;
281 for (mailboxInfo = m_mailboxes.begin(); mailboxInfo < m_mailboxes.end(); mai lboxInfo++) { 281 for (mailboxInfo = m_mailboxes.begin(); mailboxInfo < m_mailboxes.end(); ++m ailboxInfo) {
282 if (mailboxInfo->m_status == MailboxReleased) { 282 if (mailboxInfo->m_status == MailboxReleased) {
283 if (mailboxInfo->m_mailbox.syncPoint) { 283 if (mailboxInfo->m_mailbox.syncPoint) {
284 context()->waitSyncPoint(mailboxInfo->m_mailbox.syncPoint); 284 context()->waitSyncPoint(mailboxInfo->m_mailbox.syncPoint);
285 mailboxInfo->m_mailbox.syncPoint = 0; 285 mailboxInfo->m_mailbox.syncPoint = 0;
286 } 286 }
287 // Invalidate texture state in case the compositor altered it since the copy-on-write. 287 // Invalidate texture state in case the compositor altered it since the copy-on-write.
288 mailboxInfo->m_image->getTexture()->invalidateCachedState(); 288 mailboxInfo->m_image->getTexture()->invalidateCachedState();
289 mailboxInfo->m_image.reset(0); 289 mailboxInfo->m_image.reset(0);
290 mailboxInfo->m_status = MailboxAvailable; 290 mailboxInfo->m_status = MailboxAvailable;
291 } 291 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 // Because of crbug.com/247874, it needs to be kMaxSwapBuffersPending+2. 349 // Because of crbug.com/247874, it needs to be kMaxSwapBuffersPending+2.
350 // TODO(piman): fix this. 350 // TODO(piman): fix this.
351 ASSERT(m_mailboxes.size() <= 4); 351 ASSERT(m_mailboxes.size() <= 4);
352 ASSERT(mailboxInfo < m_mailboxes.end()); 352 ASSERT(mailboxInfo < m_mailboxes.end());
353 return mailboxInfo; 353 return mailboxInfo;
354 } 354 }
355 355
356 void Canvas2DLayerBridge::mailboxReleased(const blink::WebExternalTextureMailbox & mailbox) 356 void Canvas2DLayerBridge::mailboxReleased(const blink::WebExternalTextureMailbox & mailbox)
357 { 357 {
358 Vector<MailboxInfo>::iterator mailboxInfo; 358 Vector<MailboxInfo>::iterator mailboxInfo;
359 for (mailboxInfo = m_mailboxes.begin(); mailboxInfo < m_mailboxes.end(); mai lboxInfo++) { 359 for (mailboxInfo = m_mailboxes.begin(); mailboxInfo < m_mailboxes.end(); ++m ailboxInfo) {
360 if (!memcmp(mailboxInfo->m_mailbox.name, mailbox.name, sizeof(mailbox.na me))) { 360 if (!memcmp(mailboxInfo->m_mailbox.name, mailbox.name, sizeof(mailbox.na me))) {
361 mailboxInfo->m_mailbox.syncPoint = mailbox.syncPoint; 361 mailboxInfo->m_mailbox.syncPoint = mailbox.syncPoint;
362 ASSERT(mailboxInfo->m_status == MailboxInUse); 362 ASSERT(mailboxInfo->m_status == MailboxInUse);
363 mailboxInfo->m_status = MailboxReleased; 363 mailboxInfo->m_status = MailboxReleased;
364 // Trigger Canvas2DLayerBridge self-destruction if this is the 364 // Trigger Canvas2DLayerBridge self-destruction if this is the
365 // last live mailbox and the layer bridge is not externally 365 // last live mailbox and the layer bridge is not externally
366 // referenced. 366 // referenced.
367 ASSERT(mailboxInfo->m_parentLayerBridge.get() == this); 367 ASSERT(mailboxInfo->m_parentLayerBridge.get() == this);
368 mailboxInfo->m_parentLayerBridge.clear(); 368 mailboxInfo->m_parentLayerBridge.clear();
369 return; 369 return;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 Canvas2DLayerBridge::MailboxInfo::MailboxInfo(const MailboxInfo& other) { 402 Canvas2DLayerBridge::MailboxInfo::MailboxInfo(const MailboxInfo& other) {
403 // This copy constructor should only be used for Vector reallocation 403 // This copy constructor should only be used for Vector reallocation
404 // Assuming 'other' is to be destroyed, we swap m_image ownership 404 // Assuming 'other' is to be destroyed, we swap m_image ownership
405 // rather than do a refcount dance. 405 // rather than do a refcount dance.
406 memcpy(&m_mailbox, &other.m_mailbox, sizeof(m_mailbox)); 406 memcpy(&m_mailbox, &other.m_mailbox, sizeof(m_mailbox));
407 m_image.swap(const_cast<SkAutoTUnref<SkImage>*>(&other.m_image)); 407 m_image.swap(const_cast<SkAutoTUnref<SkImage>*>(&other.m_image));
408 m_status = other.m_status; 408 m_status = other.m_status;
409 } 409 }
410 410
411 } 411 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698