MCPcopy Index your code
hub / github.com/processing/processing / getBufferPixels

Method getBufferPixels

core/src/processing/opengl/Texture.java:851–882  ·  view source on GitHub ↗
(int[] pixels)

Source from the content-addressed store, hash-verified

849 }
850
851 public void getBufferPixels(int[] pixels) {
852 // We get the buffer either from the used buffers or the cache, giving
853 // priority to the used buffers. Why? Because the used buffer was already
854 // transferred to the texture, so the pixels should be in sync with the
855 // texture.
856 BufferData data = null;
857 if (usedBuffers != null && 0 < usedBuffers.size()) {
858 data = usedBuffers.getLast();
859 } else if (bufferCache != null && 0 < bufferCache.size()) {
860 data = bufferCache.getLast();
861 }
862 if (data != null) {
863 if ((data.w != width) || (data.h != height)) {
864 init(data.w, data.h);
865 }
866
867 data.rgbBuf.rewind();
868 data.rgbBuf.get(pixels);
869 convertToARGB(pixels);
870
871 // In order to avoid a cached buffer to overwrite the texture when the
872 // renderer draws the texture, and hence put the pixels put of sync, we
873 // simply empty the cache.
874 if (usedBuffers == null) {
875 usedBuffers = new LinkedList<BufferData>();
876 }
877 while (0 < bufferCache.size()) {
878 data = bufferCache.remove(0);
879 usedBuffers.add(data);
880 }
881 }
882 }
883
884
885 public boolean hasBufferSource() {

Callers

nothing calls this directly

Calls 7

initMethod · 0.95
convertToARGBMethod · 0.95
getLastMethod · 0.80
getMethod · 0.65
sizeMethod · 0.45
removeMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected