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

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

Issue 1484853003: Ganesh: images upload to GPU performance fix (skip copying encoded data) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: process comment #101 and rebase to latest Created 5 years 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 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 ASSERT(buffer->size() >= m_readPosition); 47 ASSERT(buffer->size() >= m_readPosition);
48 Vector<RefPtr<SharedBuffer>> newBufferQueue; 48 Vector<RefPtr<SharedBuffer>> newBufferQueue;
49 49
50 const char* segment = 0; 50 const char* segment = 0;
51 while (size_t length = buffer->getSomeData(segment, m_readPosition)) { 51 while (size_t length = buffer->getSomeData(segment, m_readPosition)) {
52 m_readPosition += length; 52 m_readPosition += length;
53 newBufferQueue.append(SharedBuffer::create(segment, length)); 53 newBufferQueue.append(SharedBuffer::create(segment, length));
54 } 54 }
55 55
56 MutexLocker locker(m_mutex); 56 MutexLocker locker(m_mutex);
57
58 // If all data was previously received, don't append more to it.
59 RELEASE_ASSERT(!(m_allDataReceived && newBufferQueue.size()));
60
57 m_newBufferQueue.appendVector(newBufferQueue); 61 m_newBufferQueue.appendVector(newBufferQueue);
58 newBufferQueue.clear(); 62 newBufferQueue.clear();
59 m_allDataReceived = allDataReceived; 63 m_allDataReceived = allDataReceived;
60 } 64 }
61 65
62 void ThreadSafeDataTransport::data(SharedBuffer** buffer, bool* allDataReceived) 66 void ThreadSafeDataTransport::data(SharedBuffer** buffer, bool* allDataReceived)
63 { 67 {
64 ASSERT(buffer); 68 ASSERT(buffer);
65 ASSERT(allDataReceived); 69 ASSERT(allDataReceived);
66 Vector<RefPtr<SharedBuffer>> newBufferQueue; 70 Vector<RefPtr<SharedBuffer>> newBufferQueue;
67 { 71 {
68 MutexLocker lock(m_mutex); 72 MutexLocker lock(m_mutex);
69 m_newBufferQueue.swap(newBufferQueue); 73 m_newBufferQueue.swap(newBufferQueue);
70 *allDataReceived = m_allDataReceived; 74 *allDataReceived = m_allDataReceived;
71 } 75 }
72 for (size_t i = 0; i < newBufferQueue.size(); ++i) 76 for (size_t i = 0; i < newBufferQueue.size(); ++i)
73 m_readBuffer->append(newBufferQueue[i].get()); 77 m_readBuffer->append(newBufferQueue[i].get());
74 *buffer = m_readBuffer.get(); 78 *buffer = m_readBuffer.get();
75 } 79 }
76 80
77 bool ThreadSafeDataTransport::hasNewData() 81 bool ThreadSafeDataTransport::hasNewData()
78 { 82 {
79 MutexLocker lock(m_mutex); 83 MutexLocker lock(m_mutex);
80 return !m_newBufferQueue.isEmpty(); 84 return !m_newBufferQueue.isEmpty();
81 } 85 }
82 86
83 } // namespace blink 87 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698