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

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: 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 14 matching lines...) Expand all
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/Allocator.h" 30 #include "wtf/Allocator.h"
31 #include "wtf/Noncopyable.h" 31 #include "wtf/Noncopyable.h"
32 #include "wtf/OwnPtr.h" 32 #include "wtf/OwnPtr.h"
33 #include "wtf/PassOwnPtr.h" 33 #include "wtf/PassOwnPtr.h"
34 #include "wtf/RefPtr.h" 34 #include "wtf/RefPtr.h"
35 #include "wtf/ThreadSafeRefCounted.h"
35 #include "wtf/ThreadingPrimitives.h" 36 #include "wtf/ThreadingPrimitives.h"
36 #include "wtf/Vector.h" 37 #include "wtf/Vector.h"
37 38
38 namespace blink { 39 namespace blink {
39 40
40 class SharedBuffer; 41 class SharedBuffer;
41 42
42 // The purpose of this class is to allow the transfer of data stored in 43 // The purpose of this class is to allow the transfer of data stored in
43 // SharedBuffer in a thread-safe manner, and to minimize memory copies 44 // SharedBuffer in a thread-safe manner, and to minimize memory copies
44 // and thread contention. 45 // and thread contention.
45 // 46 //
46 // This class is designed such that there is only one producer and 47 // This class is designed such that there is only one producer and
47 // one consumer. 48 // one consumer.
48 class PLATFORM_EXPORT ThreadSafeDataTransport final { 49
49 DISALLOW_NEW(); 50 class PLATFORM_EXPORT ThreadSafeDataTransport final : public ThreadSafeRefCounte d<ThreadSafeDataTransport> {
50 WTF_MAKE_NONCOPYABLE(ThreadSafeDataTransport); 51 WTF_MAKE_NONCOPYABLE(ThreadSafeDataTransport);
51 public: 52 public:
52 ThreadSafeDataTransport(); 53 ThreadSafeDataTransport();
53 ~ThreadSafeDataTransport(); 54 ~ThreadSafeDataTransport();
54 55
55 // This method is being called subsequently with an expanding 56 // This method is being called subsequently with an expanding
56 // SharedBuffer. 57 // SharedBuffer.
57 void setData(SharedBuffer*, bool allDataReceived); 58 void setData(SharedBuffer*, bool allDataReceived);
58 59
59 // Get the data submitted to this class so far. 60 // Get the data submitted to this class so far.
60 void data(SharedBuffer**, bool* allDataReceived); 61 void data(SharedBuffer**, bool* allDataReceived);
61 62
62 // Return true of there is new data submitted to this class 63 // Return true of there is new data submitted to this class
63 // since last time data() was called. 64 // since last time data() was called.
64 bool hasNewData(); 65 bool hasNewData();
65 66
66 private: 67 private:
67 Mutex m_mutex; 68 Mutex m_mutex;
68 69
69 Vector<RefPtr<SharedBuffer>> m_newBufferQueue; 70 Vector<RefPtr<SharedBuffer>> m_newBufferQueue;
70 RefPtr<SharedBuffer> m_readBuffer; 71 RefPtr<SharedBuffer> m_readBuffer;
71 bool m_allDataReceived; 72 bool m_allDataReceived;
72 size_t m_readPosition; 73 size_t m_readPosition;
73 }; 74 };
74 75
75 } // namespace blink 76 } // namespace blink
76 77
77 #endif 78 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698