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

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

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: Thread safe reference counting and disposal of shared data (m_data that is) 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 12 matching lines...) Expand all
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #ifndef ThreadSafeDataTransport_h 26 #ifndef ThreadSafeDataTransport_h
27 #define ThreadSafeDataTransport_h 27 #define ThreadSafeDataTransport_h
28 28
29 #include "platform/PlatformExport.h" 29 #include "platform/PlatformExport.h"
30 #include "wtf/OwnPtr.h" 30 #include "wtf/OwnPtr.h"
31 #include "wtf/PassOwnPtr.h" 31 #include "wtf/PassOwnPtr.h"
32 #include "wtf/RefPtr.h" 32 #include "wtf/RefPtr.h"
33 #include "wtf/ThreadSafeRefCounted.h"
33 #include "wtf/ThreadingPrimitives.h" 34 #include "wtf/ThreadingPrimitives.h"
34 #include "wtf/Vector.h" 35 #include "wtf/Vector.h"
35 36
36 namespace blink { 37 namespace blink {
37 38
38 class SharedBuffer; 39 class SharedBuffer;
39 40
40 // The purpose of this class is to allow the transfer of data stored in 41 // The purpose of this class is to allow the transfer of data stored in
41 // SharedBuffer in a thread-safe manner, and to minimize memory copies 42 // SharedBuffer in a thread-safe manner, and to minimize memory copies
42 // and thread contention. 43 // and thread contention.
43 // 44 //
44 // This class is designed such that there is only one producer and 45 // This class is designed such that there is only one producer and
45 // one consumer. 46 // one consumer.
46 class PLATFORM_EXPORT ThreadSafeDataTransport { 47 class PLATFORM_EXPORT ThreadSafeDataTransport : public ThreadSafeRefCounted<Thre adSafeDataTransport> {
47 public: 48 public:
48 ThreadSafeDataTransport(); 49 ThreadSafeDataTransport();
49 ~ThreadSafeDataTransport(); 50 ~ThreadSafeDataTransport();
50 51
51 // This method is being called subsequently with an expanding 52 // This method is being called subsequently with an expanding
52 // SharedBuffer. 53 // SharedBuffer.
53 void setData(SharedBuffer*, bool allDataReceived); 54 void setData(SharedBuffer*, bool allDataReceived);
54 55
55 // Get the data submitted to this class so far. 56 // Get the data submitted to this class so far.
56 void data(SharedBuffer**, bool* allDataReceived); 57 void data(SharedBuffer**, bool* allDataReceived);
57 58
58 // Return true of there is new data submitted to this class 59 // Return true of there is new data submitted to this class
59 // since last time data() was called. 60 // since last time data() was called.
60 bool hasNewData(); 61 bool hasNewData();
61 62
62 private: 63 private:
63 Mutex m_mutex; 64 Mutex m_mutex;
64 65
65 Vector<RefPtr<SharedBuffer>> m_newBufferQueue; 66 Vector<RefPtr<SharedBuffer>> m_newBufferQueue;
67 bool m_newAllDataReceived;
66 RefPtr<SharedBuffer> m_readBuffer; 68 RefPtr<SharedBuffer> m_readBuffer;
67 bool m_allDataReceived; 69 bool m_allDataReceived;
68 size_t m_readPosition; 70 size_t m_readPosition;
69 }; 71 };
70 72
71 } // namespace blink 73 } // namespace blink
72 74
73 #endif 75 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698