From aa4963b929d506fc97bdcd325d842aa775b346b7 Mon Sep 17 00:00:00 2001 From: benfry Date: Fri, 1 Jun 2012 16:00:32 +0000 Subject: [PATCH] fix naming conventions (+ to match desktop) --- android/core/src/processing/core/PApplet.java | 8 ++- .../{PFramebuffer.java => FrameBuffer.java} | 22 +++---- .../src/processing/opengl/PFontTexture.java | 16 ++--- .../processing/opengl/PGraphicsOpenGL.java | 64 +++++++++---------- .../src/processing/opengl/PShapeOpenGL.java | 2 +- .../opengl/{PTexture.java => Texture.java} | 30 ++++----- 6 files changed, 72 insertions(+), 70 deletions(-) rename android/core/src/processing/opengl/{PFramebuffer.java => FrameBuffer.java} (95%) rename android/core/src/processing/opengl/{PTexture.java => Texture.java} (94%) diff --git a/android/core/src/processing/core/PApplet.java b/android/core/src/processing/core/PApplet.java index 8315c81ac..928be34c1 100644 --- a/android/core/src/processing/core/PApplet.java +++ b/android/core/src/processing/core/PApplet.java @@ -3,7 +3,7 @@ /* Part of the Processing project - http://processing.org - Copyright (c) 2004-10 Ben Fry and Casey Reas + Copyright (c) 2004-12 Ben Fry and Casey Reas Copyright (c) 2001-04 Massachusetts Institute of Technology This library is free software; you can redistribute it and/or @@ -804,7 +804,7 @@ public class PApplet extends Activity implements PConstants, Runnable { // Set semi-arbitrary size; will be set properly when surfaceChanged() called g3.setSize(wide, high); - String depth = sketchColordepth(); + String depth = sketchColorDepth(); if (!depth.equals(DEFAULT_COLOR_DEPTH)) { // Setting user specified color depth. Otherwise, we let the // device to choose the configuration it pleases. @@ -1027,10 +1027,12 @@ public class PApplet extends Activity implements PConstants, Runnable { return true; } - public String sketchColordepth() { + + public String sketchColorDepth() { return DEFAULT_COLOR_DEPTH; } + public void orientation(int which) { if (which == PORTRAIT) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); diff --git a/android/core/src/processing/opengl/PFramebuffer.java b/android/core/src/processing/opengl/FrameBuffer.java similarity index 95% rename from android/core/src/processing/opengl/PFramebuffer.java rename to android/core/src/processing/opengl/FrameBuffer.java index 52610130d..49ceb13ce 100644 --- a/android/core/src/processing/opengl/PFramebuffer.java +++ b/android/core/src/processing/opengl/FrameBuffer.java @@ -39,7 +39,7 @@ import java.nio.IntBuffer; * By Andres Colubri. */ -public class PFramebuffer implements PConstants { +public class FrameBuffer implements PConstants { protected PApplet parent; protected PGraphicsOpenGL pg; protected PGL pgl; @@ -61,22 +61,22 @@ public class PFramebuffer implements PConstants { protected int nsamples; protected int numColorBuffers; - protected PTexture[] colorBufferTex; + protected Texture[] colorBufferTex; protected boolean screenFb; protected boolean noDepth; protected IntBuffer pixelBuffer; - PFramebuffer(PApplet parent, int w, int h) { + FrameBuffer(PApplet parent, int w, int h) { this(parent, w, h, 1, 1, 0, 0, false, false); } - PFramebuffer(PApplet parent, int w, int h, boolean screen) { + FrameBuffer(PApplet parent, int w, int h, boolean screen) { this(parent, w, h, 1, 1, 0, 0, false, screen); } - PFramebuffer(PApplet parent, int w, int h, int samples, int colorBuffers, + FrameBuffer(PApplet parent, int w, int h, int samples, int colorBuffers, int depthBits, int stencilBits, boolean packedDepthStencil, boolean screen) { this.parent = parent; @@ -109,7 +109,7 @@ public class PFramebuffer implements PConstants { } numColorBuffers = colorBuffers; - colorBufferTex = new PTexture[numColorBuffers]; + colorBufferTex = new Texture[numColorBuffers]; for (int i = 0; i < numColorBuffers; i++) { colorBufferTex[i] = null; } @@ -171,7 +171,7 @@ public class PFramebuffer implements PConstants { pg.popFramebuffer(); } - public void copy(PFramebuffer dest) { + public void copy(FrameBuffer dest) { pgl.glBindFramebuffer(PGL.GL_READ_FRAMEBUFFER, this.glFboID); pgl.glBindFramebuffer(PGL.GL_DRAW_FRAMEBUFFER, dest.glFboID); pgl.glBlitFramebuffer(0, 0, this.width, this.height, @@ -228,17 +228,17 @@ public class PFramebuffer implements PConstants { // Color buffer setters. - public void setColorBuffer(PTexture tex) { - setColorBuffers(new PTexture[] { tex }, 1); + public void setColorBuffer(Texture tex) { + setColorBuffers(new Texture[] { tex }, 1); } - public void setColorBuffers(PTexture[] textures) { + public void setColorBuffers(Texture[] textures) { setColorBuffers(textures, textures.length); } - public void setColorBuffers(PTexture[] textures, int n) { + public void setColorBuffers(Texture[] textures, int n) { if (screenFb) return; if (numColorBuffers != PApplet.min(n, textures.length)) { diff --git a/android/core/src/processing/opengl/PFontTexture.java b/android/core/src/processing/opengl/PFontTexture.java index f06dc8575..5d655ca3d 100644 --- a/android/core/src/processing/opengl/PFontTexture.java +++ b/android/core/src/processing/opengl/PFontTexture.java @@ -59,7 +59,7 @@ class PFontTexture implements PConstants { protected int offsetX; protected int offsetY; protected int lineHeight; - protected PTexture[] textures = null; + protected Texture[] textures = null; protected PImage[] images = null; protected int currentTex; protected int lastTex; @@ -117,20 +117,20 @@ class PFontTexture implements PConstants { resize = false; } - PTexture tex; + Texture tex; if (is3D) { // Bilinear sampling ensures that the texture doesn't look pixelated either // when it is magnified or minified... - tex = new PTexture(parent, w, h, new PTexture.Parameters(ARGB, BILINEAR, false)); + tex = new Texture(parent, w, h, new Texture.Parameters(ARGB, BILINEAR, false)); } else { // ...however, the effect of bilinear sampling is to add some blurriness to the text // in its original size. In 2D, we assume that text will be shown at its original // size, so linear sampling is chosen instead (which only affects minimized text). - tex = new PTexture(parent, w, h, new PTexture.Parameters(ARGB, LINEAR, false)); + tex = new Texture(parent, w, h, new Texture.Parameters(ARGB, LINEAR, false)); } if (textures == null) { - textures = new PTexture[1]; + textures = new Texture[1]; textures[0] = tex; images = new PImage[1]; images[0] = pg.wrapTexture(tex); @@ -139,7 +139,7 @@ class PFontTexture implements PConstants { // Replacing old smaller texture with larger one. // But first we must copy the contents of the older // texture into the new one. - PTexture tex0 = textures[currentTex]; + Texture tex0 = textures[currentTex]; tex.put(tex0); textures[currentTex] = tex; @@ -148,8 +148,8 @@ class PFontTexture implements PConstants { images[currentTex].height = tex.height; } else { // Adding new texture to the list. - PTexture[] tempTex = textures; - textures = new PTexture[textures.length + 1]; + Texture[] tempTex = textures; + textures = new Texture[textures.length + 1]; PApplet.arrayCopy(tempTex, textures, tempTex.length); textures[tempTex.length] = tex; currentTex = textures.length - 1; diff --git a/android/core/src/processing/opengl/PGraphicsOpenGL.java b/android/core/src/processing/opengl/PGraphicsOpenGL.java index 263d4a38f..2580ccc9f 100644 --- a/android/core/src/processing/opengl/PGraphicsOpenGL.java +++ b/android/core/src/processing/opengl/PGraphicsOpenGL.java @@ -311,16 +311,16 @@ public class PGraphicsOpenGL extends PGraphics { // Framebuffer stack: - static protected Stack fbStack; - static protected PFramebuffer screenFramebuffer; - static protected PFramebuffer currentFramebuffer; + static protected Stack fbStack; + static protected FrameBuffer screenFramebuffer; + static protected FrameBuffer currentFramebuffer; // ....................................................... // Offscreen rendering: - protected PFramebuffer offscreenFramebuffer; - protected PFramebuffer offscreenFramebufferMultisample; + protected FrameBuffer offscreenFramebuffer; + protected FrameBuffer offscreenFramebufferMultisample; protected boolean offscreenMultisample; protected boolean offscreenNotCurrent; @@ -331,7 +331,7 @@ public class PGraphicsOpenGL extends PGraphics { /** A handy reference to the PTexture bound to the drawing surface * (off or on-screen) */ - protected PTexture texture; + protected Texture texture; /** IntBuffer wrapping the pixels array. */ protected IntBuffer pixelBuffer; @@ -1038,7 +1038,7 @@ public class PGraphicsOpenGL extends PGraphics { } - public void setFramebuffer(PFramebuffer fbo) { + public void setFramebuffer(FrameBuffer fbo) { currentFramebuffer = fbo; currentFramebuffer.bind(); } @@ -1893,9 +1893,9 @@ public class PGraphicsOpenGL extends PGraphics { clearColorBuffer = false; if (fbStack == null) { - fbStack = new Stack(); + fbStack = new Stack(); - screenFramebuffer = new PFramebuffer(parent, width, height, true); + screenFramebuffer = new FrameBuffer(parent, width, height, true); setFramebuffer(screenFramebuffer); } @@ -2357,7 +2357,7 @@ public class PGraphicsOpenGL extends PGraphics { texCache.beginRender(); for (int i = 0; i < texCache.size; i++) { - PTexture tex = texCache.getTexture(i); + Texture tex = texCache.getTexture(i); // If the renderer is 2D, then lights should always be false, // so no need to worry about that. @@ -4876,8 +4876,8 @@ public class PGraphicsOpenGL extends PGraphics { protected void loadTextureImpl(int sampling, boolean mipmap) { if (width == 0 || height == 0) return; if (texture == null || texture.contextIsOutdated()) { - PTexture.Parameters params = new PTexture.Parameters(ARGB, sampling, mipmap); - texture = new PTexture(parent, width, height, params); + Texture.Parameters params = new Texture.Parameters(ARGB, sampling, mipmap); + texture = new Texture(parent, width, height, params); texture.setFlippedY(true); this.setCache(pgPrimary, texture); this.setParams(pgPrimary, params); @@ -5144,7 +5144,7 @@ public class PGraphicsOpenGL extends PGraphics { * drawing surface, making sure is updated to reflect the current contents * off the screen (or offscreen drawing surface). */ - public PTexture getTexture() { + public Texture getTexture() { loadTexture(); return texture; } @@ -5156,8 +5156,8 @@ public class PGraphicsOpenGL extends PGraphics { * * @param img the image to have a texture metadata associated to it */ - public PTexture getTexture(PImage img) { - PTexture tex = (PTexture)img.getCache(pgPrimary); + public Texture getTexture(PImage img) { + Texture tex = (Texture)img.getCache(pgPrimary); if (tex == null) { tex = addTexture(img); } else { @@ -5185,10 +5185,10 @@ public class PGraphicsOpenGL extends PGraphics { * to the metadata cache of the image. * @param img the image to have a texture metadata associated to it */ - protected PTexture addTexture(PImage img) { - PTexture.Parameters params = (PTexture.Parameters)img.getParams(pgPrimary); + protected Texture addTexture(PImage img) { + Texture.Parameters params = (Texture.Parameters)img.getParams(pgPrimary); if (params == null) { - params = new PTexture.Parameters(); + params = new Texture.Parameters(); if (hints[DISABLE_TEXTURE_MIPMAPS]) { params.mipmaps = false; } else { @@ -5215,7 +5215,7 @@ public class PGraphicsOpenGL extends PGraphics { if (img.parent == null) { img.parent = parent; } - PTexture tex = new PTexture(img.parent, img.width, img.height, params); + Texture tex = new Texture(img.parent, img.width, img.height, params); img.loadPixels(); if (img.pixels != null) tex.set(img.pixels); img.setCache(pgPrimary, tex); @@ -5223,7 +5223,7 @@ public class PGraphicsOpenGL extends PGraphics { } - protected PImage wrapTexture(PTexture tex) { + protected PImage wrapTexture(Texture tex) { // We don't use the PImage(int width, int height, int mode) constructor to // avoid initializing the pixels array. PImage img = new PImage(); @@ -5236,7 +5236,7 @@ public class PGraphicsOpenGL extends PGraphics { } - protected void updateTexture(PImage img, PTexture tex) { + protected void updateTexture(PImage img, Texture tex) { if (tex != null) { int x = img.getModifiedX1(); int y = img.getModifiedY1(); @@ -5290,7 +5290,7 @@ public class PGraphicsOpenGL extends PGraphics { } if (PGraphicsOpenGL.fboMultisampleSupported && 1 < quality) { - offscreenFramebufferMultisample = new PFramebuffer(parent, texture.glWidth, texture.glHeight, quality, 0, + offscreenFramebufferMultisample = new FrameBuffer(parent, texture.glWidth, texture.glHeight, quality, 0, depthBits, stencilBits, depthBits == 24 && stencilBits == 8 && packedDepthStencilSupported, false); @@ -5299,13 +5299,13 @@ public class PGraphicsOpenGL extends PGraphics { // The offscreen framebuffer where the multisampled image is finally drawn to doesn't // need depth and stencil buffers since they are part of the multisampled framebuffer. - offscreenFramebuffer = new PFramebuffer(parent, texture.glWidth, texture.glHeight, 1, 1, + offscreenFramebuffer = new FrameBuffer(parent, texture.glWidth, texture.glHeight, 1, 1, 0, 0, false, false); } else { quality = 0; - offscreenFramebuffer = new PFramebuffer(parent, texture.glWidth, texture.glHeight, 1, 1, + offscreenFramebuffer = new FrameBuffer(parent, texture.glWidth, texture.glHeight, 1, 1, depthBits, stencilBits, depthBits == 24 && stencilBits == 8 && packedDepthStencilSupported, false); offscreenMultisample = false; @@ -5586,7 +5586,7 @@ public class PGraphicsOpenGL extends PGraphics { public void setEmissiveAttribute(int vboId, int size, int type, int stride, int offset) { } public void setShininessAttribute(int vboId, int size, int type, int stride, int offset) { } public void setTexcoordAttribute(int vboId, int size, int type, int stride, int offset) { } - public void setTexture(PTexture tex) { } + public void setTexture(Texture tex) { } } @@ -5824,7 +5824,7 @@ public class PGraphicsOpenGL extends PGraphics { setAttribute(inTexcoordLoc, vboId, size, type, false, stride, offset); } - public void setTexture(PTexture tex) { + public void setTexture(Texture tex) { float scaleu = 1; float scalev = 1; float dispu = 0; @@ -5909,7 +5909,7 @@ public class PGraphicsOpenGL extends PGraphics { setAttribute(inTexcoordLoc, vboId, size, type, false, stride, offset); } - public void setTexture(PTexture tex) { + public void setTexture(Texture tex) { float scaleu = 1; float scalev = 1; float dispu = 0; @@ -6172,7 +6172,7 @@ public class PGraphicsOpenGL extends PGraphics { int[] firstCache; int[] lastCache; boolean hasTexture; - PTexture tex0; + Texture tex0; TexCache() { allocate(); @@ -6210,9 +6210,9 @@ public class PGraphicsOpenGL extends PGraphics { return textures[i]; } - PTexture getTexture(int i) { + Texture getTexture(int i) { PImage img = textures[i]; - PTexture tex = null; + Texture tex = null; if (img != null) { tex = pgPrimary.getTexture(img); @@ -6235,7 +6235,7 @@ public class PGraphicsOpenGL extends PGraphics { for (int i = 0; i < size; i++) { PImage img = textures[i]; if (img != null) { - PTexture tex = pgPrimary.getTexture(img); + Texture tex = pgPrimary.getTexture(img); if (tex != null) { tex.unbind(); } @@ -6246,7 +6246,7 @@ public class PGraphicsOpenGL extends PGraphics { for (int i = 0; i < size; i++) { PImage img = textures[i]; if (img != null) { - PTexture tex = pgPrimary.getTexture(img); + Texture tex = pgPrimary.getTexture(img); if (tex != null) { pgl.disableTexturing(tex.glTarget); } diff --git a/android/core/src/processing/opengl/PShapeOpenGL.java b/android/core/src/processing/opengl/PShapeOpenGL.java index 4fb73bc9b..511b9c191 100644 --- a/android/core/src/processing/opengl/PShapeOpenGL.java +++ b/android/core/src/processing/opengl/PShapeOpenGL.java @@ -3872,7 +3872,7 @@ public class PShapeOpenGL extends PShape { protected void renderPolys(PGraphicsOpenGL g, PImage textureImage) { - PTexture tex = null; + Texture tex = null; if (textureImage != null) { tex = g.getTexture(textureImage); if (tex != null) { diff --git a/android/core/src/processing/opengl/PTexture.java b/android/core/src/processing/opengl/Texture.java similarity index 94% rename from android/core/src/processing/opengl/PTexture.java rename to android/core/src/processing/opengl/Texture.java index daf3e4518..8a6142e47 100644 --- a/android/core/src/processing/opengl/PTexture.java +++ b/android/core/src/processing/opengl/Texture.java @@ -38,7 +38,7 @@ import java.util.NoSuchElementException; * By Andres Colubri * */ -public class PTexture implements PConstants { +public class Texture implements PConstants { public int width, height; protected PApplet parent; // The Processing applet @@ -65,7 +65,7 @@ public class PTexture implements PConstants { protected boolean flippedY; protected int[] tempPixels = null; - protected PFramebuffer tempFbo = null; + protected FrameBuffer tempFbo = null; protected Object bufferSource; protected LinkedList bufferCache = null; @@ -84,7 +84,7 @@ public class PTexture implements PConstants { * @param width int * @param height int */ - public PTexture(PApplet parent, int width, int height) { + public Texture(PApplet parent, int width, int height) { this(parent, width, height, new Parameters()); } @@ -97,7 +97,7 @@ public class PTexture implements PConstants { * @param height int * @param params Parameters */ - public PTexture(PApplet parent, int width, int height, Object params) { + public Texture(PApplet parent, int width, int height, Object params) { this.parent = parent; pg = (PGraphicsOpenGL)parent.g; @@ -168,7 +168,7 @@ public class PTexture implements PConstants { release(); // Creating new texture with the appropriate size. - PTexture tex = new PTexture(parent, wide, high, getParameters()); + Texture tex = new Texture(parent, wide, high, getParameters()); // Copying the contents of this texture into tex. tex.set(this); @@ -198,23 +198,23 @@ public class PTexture implements PConstants { public void set(PImage img) { - PTexture tex = (PTexture)img.getCache(pg); + Texture tex = (Texture)img.getCache(pg); set(tex); } public void set(PImage img, int x, int y, int w, int h) { - PTexture tex = (PTexture)img.getCache(pg); + Texture tex = (Texture)img.getCache(pg); set(tex, x, y, w, h); } - public void set(PTexture tex) { + public void set(Texture tex) { copyTexels(tex, 0, 0, tex.width, tex.height, true); } - public void set(PTexture tex, int x, int y, int w, int h) { + public void set(Texture tex, int x, int y, int w, int h) { copyTexels(tex, x, y, w, h, true); } @@ -346,7 +346,7 @@ public class PTexture implements PConstants { int size = glWidth * glHeight; if (tempFbo == null) { - tempFbo = new PFramebuffer(parent, glWidth, glHeight); + tempFbo = new FrameBuffer(parent, glWidth, glHeight); } // Attaching the texture to the color buffer of a FBO, binding the FBO and reading the pixels @@ -374,12 +374,12 @@ public class PTexture implements PConstants { // destination). - public void put(PTexture tex) { + public void put(Texture tex) { copyTexels(tex, 0, 0, tex.width, tex.height, false); } - public void put(PTexture tex, int x, int y, int w, int h) { + public void put(Texture tex, int x, int y, int w, int h) { copyTexels(tex, x, y, w, h, false); } @@ -863,13 +863,13 @@ public class PTexture implements PConstants { // Copies source texture tex into this. - protected void copyTexels(PTexture tex, int x, int y, int w, int h, boolean scale) { + protected void copyTexels(Texture tex, int x, int y, int w, int h, boolean scale) { if (tex == null) { throw new RuntimeException("PTexture: source texture is null"); } if (tempFbo == null) { - tempFbo = new PFramebuffer(parent, glWidth, glHeight); + tempFbo = new FrameBuffer(parent, glWidth, glHeight); } // This texture is the color (destination) buffer of the FBO. @@ -911,7 +911,7 @@ public class PTexture implements PConstants { pgl.glTexSubImage2D(glTarget, level, x, y, w, h, PGL.GL_RGBA, PGL.GL_UNSIGNED_BYTE, buffer); } - protected void copyObject(PTexture src) { + protected void copyObject(Texture src) { // The OpenGL texture of this object is replaced with the one from the source object, // so we delete the former to avoid resource wasting. release();