OLD | NEW |
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 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 { | 240 { |
241 while (!m_recycledMailboxQueue.isEmpty()) { | 241 while (!m_recycledMailboxQueue.isEmpty()) { |
242 RefPtr<RecycledMailbox> recycled = m_recycledMailboxQueue.takeLast(); | 242 RefPtr<RecycledMailbox> recycled = m_recycledMailboxQueue.takeLast(); |
243 deleteMailbox(recycled->mailbox, recycled->syncToken); | 243 deleteMailbox(recycled->mailbox, recycled->syncToken); |
244 } | 244 } |
245 } | 245 } |
246 | 246 |
247 std::unique_ptr<cc::SharedBitmap> DrawingBuffer::createOrRecycleBitmap() | 247 std::unique_ptr<cc::SharedBitmap> DrawingBuffer::createOrRecycleBitmap() |
248 { | 248 { |
249 size_t i = 0; | 249 size_t i = 0; |
250 while (i < m_recycledBitmap.size()) { | 250 while (i < m_recycledBitmaps.size()) { |
251 if (m_recycledBitmap[i].size != m_size) | 251 if (m_recycledBitmaps[i].size != m_size) |
252 m_recycledBitmap.remove(i); // Removed this position so iterate on i
t again. | 252 m_recycledBitmaps.remove(i); // Removed this position so iterate on
it again. |
253 else | 253 else |
254 ++i; | 254 ++i; |
255 } | 255 } |
256 if (!m_recycledBitmap.isEmpty()) { | 256 if (!m_recycledBitmaps.isEmpty()) { |
257 RecycledBitmap recycled = std::move(m_recycledBitmap.last()); | 257 RecycledBitmap recycled = std::move(m_recycledBitmaps.last()); |
258 m_recycledBitmap.removeLast(); | 258 m_recycledBitmaps.removeLast(); |
259 DCHECK(recycled.size == m_size); | 259 DCHECK(recycled.size == m_size); |
260 return std::move(recycled.bitmap); | 260 return std::move(recycled.bitmap); |
261 } | 261 } |
262 | 262 |
263 return Platform::current()->allocateSharedBitmap(m_size); | 263 return Platform::current()->allocateSharedBitmap(m_size); |
264 } | 264 } |
265 | 265 |
266 bool DrawingBuffer::PrepareTextureMailbox(cc::TextureMailbox* outMailbox, std::u
nique_ptr<cc::SingleReleaseCallback>* outReleaseCallback) | 266 bool DrawingBuffer::PrepareTextureMailbox(cc::TextureMailbox* outMailbox, std::u
nique_ptr<cc::SingleReleaseCallback>* outReleaseCallback) |
267 { | 267 { |
268 bool forceGpuResult = false; | 268 bool forceGpuResult = false; |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 ASSERT_NOT_REACHED(); | 409 ASSERT_NOT_REACHED(); |
410 } | 410 } |
411 | 411 |
412 void DrawingBuffer::softwareMailboxReleased(std::unique_ptr<cc::SharedBitmap> bi
tmap, const IntSize& size, const gpu::SyncToken& syncToken, bool lostResource) | 412 void DrawingBuffer::softwareMailboxReleased(std::unique_ptr<cc::SharedBitmap> bi
tmap, const IntSize& size, const gpu::SyncToken& syncToken, bool lostResource) |
413 { | 413 { |
414 DCHECK(!syncToken.HasData()); // No sync tokens for software resources. | 414 DCHECK(!syncToken.HasData()); // No sync tokens for software resources. |
415 if (m_destructionInProgress || lostResource || m_isHidden || size != m_size) | 415 if (m_destructionInProgress || lostResource || m_isHidden || size != m_size) |
416 return; // Just delete the bitmap. | 416 return; // Just delete the bitmap. |
417 | 417 |
418 RecycledBitmap recycled = { std::move(bitmap), m_size }; | 418 RecycledBitmap recycled = { std::move(bitmap), m_size }; |
419 m_recycledBitmap.append(std::move(recycled)); | 419 m_recycledBitmaps.append(std::move(recycled)); |
420 } | 420 } |
421 | 421 |
422 PassRefPtr<StaticBitmapImage> DrawingBuffer::transferToStaticBitmapImage() | 422 PassRefPtr<StaticBitmapImage> DrawingBuffer::transferToStaticBitmapImage() |
423 { | 423 { |
424 // This can be null if the context is lost before the first call to grContex
t(). | 424 // This can be null if the context is lost before the first call to grContex
t(). |
425 GrContext* grContext = m_contextProvider->grContext(); | 425 GrContext* grContext = m_contextProvider->grContext(); |
426 | 426 |
427 cc::TextureMailbox textureMailbox; | 427 cc::TextureMailbox textureMailbox; |
428 std::unique_ptr<cc::SingleReleaseCallback> releaseCallback; | 428 std::unique_ptr<cc::SingleReleaseCallback> releaseCallback; |
429 bool success = false; | 429 bool success = false; |
(...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1240 | 1240 |
1241 void DrawingBuffer::restoreTextureBindings() | 1241 void DrawingBuffer::restoreTextureBindings() |
1242 { | 1242 { |
1243 // This class potentially modifies the bindings for GL_TEXTURE_2D and | 1243 // This class potentially modifies the bindings for GL_TEXTURE_2D and |
1244 // GL_TEXTURE_RECTANGLE. Only GL_TEXTURE_2D needs to be restored since | 1244 // GL_TEXTURE_RECTANGLE. Only GL_TEXTURE_2D needs to be restored since |
1245 // the public interface for WebGL does not support GL_TEXTURE_RECTANGLE. | 1245 // the public interface for WebGL does not support GL_TEXTURE_RECTANGLE. |
1246 m_gl->BindTexture(GL_TEXTURE_2D, m_texture2DBinding); | 1246 m_gl->BindTexture(GL_TEXTURE_2D, m_texture2DBinding); |
1247 } | 1247 } |
1248 | 1248 |
1249 } // namespace blink | 1249 } // namespace blink |
OLD | NEW |