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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp

Issue 2381613003: Rewrite the while loop in DrawingBuffer::createOrRecycleBitmap (Closed)
Patch Set: changed to std::move_if Created 4 years, 2 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
« no previous file with comments | « no previous file | 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 /* 1 /*
2 * Copyright (c) 2010, Google Inc. All rights reserved. 2 * Copyright (c) 2010, 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 void DrawingBuffer::freeRecycledMailboxes() 242 void DrawingBuffer::freeRecycledMailboxes()
243 { 243 {
244 while (!m_recycledMailboxQueue.isEmpty()) { 244 while (!m_recycledMailboxQueue.isEmpty()) {
245 RefPtr<RecycledMailbox> recycled = m_recycledMailboxQueue.takeLast(); 245 RefPtr<RecycledMailbox> recycled = m_recycledMailboxQueue.takeLast();
246 deleteMailbox(recycled->mailbox, recycled->syncToken); 246 deleteMailbox(recycled->mailbox, recycled->syncToken);
247 } 247 }
248 } 248 }
249 249
250 std::unique_ptr<cc::SharedBitmap> DrawingBuffer::createOrRecycleBitmap() 250 std::unique_ptr<cc::SharedBitmap> DrawingBuffer::createOrRecycleBitmap()
251 { 251 {
252 size_t i = 0; 252 auto it = std::remove_if(m_recycledBitmaps.begin(), m_recycledBitmaps.end(),
253 while (i < m_recycledBitmaps.size()) { 253 [this](const RecycledBitmap& bitmap)
254 if (m_recycledBitmaps[i].size != m_size) 254 {
255 m_recycledBitmaps.remove(i); // Removed this position so iterate on it again. 255 return bitmap.size != m_size;
256 else 256 });
257 ++i; 257 m_recycledBitmaps.shrink(it - m_recycledBitmaps.begin());
258 } 258
259 if (!m_recycledBitmaps.isEmpty()) { 259 if (!m_recycledBitmaps.isEmpty()) {
260 RecycledBitmap recycled = std::move(m_recycledBitmaps.last()); 260 RecycledBitmap recycled = std::move(m_recycledBitmaps.last());
261 m_recycledBitmaps.removeLast(); 261 m_recycledBitmaps.removeLast();
262 DCHECK(recycled.size == m_size); 262 DCHECK(recycled.size == m_size);
263 return std::move(recycled.bitmap); 263 return std::move(recycled.bitmap);
264 } 264 }
265 265
266 return Platform::current()->allocateSharedBitmap(m_size); 266 return Platform::current()->allocateSharedBitmap(m_size);
267 } 267 }
268 268
(...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after
1248 // the public interface for WebGL does not support GL_TEXTURE_RECTANGLE. 1248 // the public interface for WebGL does not support GL_TEXTURE_RECTANGLE.
1249 m_gl->BindTexture(GL_TEXTURE_2D, m_texture2DBinding); 1249 m_gl->BindTexture(GL_TEXTURE_2D, m_texture2DBinding);
1250 } 1250 }
1251 1251
1252 bool DrawingBuffer::shouldUseChromiumImage() 1252 bool DrawingBuffer::shouldUseChromiumImage()
1253 { 1253 {
1254 return RuntimeEnabledFeatures::webGLImageChromiumEnabled() && m_chromiumImag eUsage == AllowChromiumImage; 1254 return RuntimeEnabledFeatures::webGLImageChromiumEnabled() && m_chromiumImag eUsage == AllowChromiumImage;
1255 } 1255 }
1256 1256
1257 } // namespace blink 1257 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698