MCPcopy Create free account
hub / github.com/TigerVNC/tigervnc / decodeRect

Method decodeRect

java/com/tigervnc/rfb/DecodeManager.java:80–169  ·  view source on GitHub ↗
(Rect r, int encoding,
                         ModifiablePixelBuffer pb)

Source from the content-addressed store, hash-verified

78 }
79
80 public void decodeRect(Rect r, int encoding,
81 ModifiablePixelBuffer pb)
82 {
83 Decoder decoder;
84 MemOutStream bufferStream;
85
86 QueueEntry entry;
87
88 assert(pb != null);
89
90 if (!Decoder.supported(encoding)) {
91 vlog.error("Unknown encoding " + encoding);
92 throw new Exception("Unknown encoding");
93 }
94
95 if (decoders[encoding] == null) {
96 decoders[encoding] = Decoder.createDecoder(encoding);
97 if (decoders[encoding] == null) {
98 vlog.error("Unknown encoding " + encoding);
99 throw new Exception("Unknown encoding");
100 }
101 }
102
103 decoder = decoders[encoding];
104
105 // Fast path for single CPU machines to avoid the context
106 // switching overhead
107 if (threads.size() == 1) {
108 bufferStream = freeBuffers.getFirst();
109 bufferStream.clear();
110 decoder.readRect(r, conn.getInStream(), conn.server, bufferStream);
111 decoder.decodeRect(r, (Object)bufferStream.data(), bufferStream.length(),
112 conn.server, pb);
113 return;
114 }
115
116 // Wait for an available memory buffer
117 queueMutex.lock();
118
119 try {
120 while (freeBuffers.isEmpty())
121 try {
122 producerCond.await();
123 } catch (InterruptedException e) { }
124
125 // Don't pop the buffer in case we throw an exception
126 // whilst reading
127 bufferStream = freeBuffers.getFirst();
128 } finally {
129 queueMutex.unlock();
130 }
131
132 // First check if any thread has encountered a problem
133 throwThreadException();
134
135 // Read the rect
136 bufferStream.clear();
137 decoder.readRect(r, conn.getInStream(), conn.server, bufferStream);

Callers 1

runMethod · 0.45

Calls 13

supportedMethod · 0.95
createDecoderMethod · 0.95
clearMethod · 0.95
readRectMethod · 0.95
decodeRectMethod · 0.95
dataMethod · 0.95
lengthMethod · 0.95
throwThreadExceptionMethod · 0.95
getAffectedRegionMethod · 0.95
errorMethod · 0.80
awaitMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected