Home | History | Annotate | Download | only in media

Lines Matching refs:texture

75     private static final Deque<Texture> sLoadInputQueue = new Deque<Texture>();
76 private static final Deque<Texture> sLoadInputQueueCached = new Deque<Texture>();
77 private static final Deque<Texture> sLoadInputQueueVideo = new Deque<Texture>();
78 private static final Deque<Texture> sLoadOutputQueue = new Deque<Texture>();
99 // The cached texture that is bound to Texture Unit 0.
100 // We need to reset this to null whenever the active texture unit changes.
101 private Texture mBoundTexture;
103 // Weak reference to a texture that stores the associated texture ID.
104 private static final class TextureReference extends WeakReference<Texture> {
106 public TextureReference(Texture texture, GL11 gl, ReferenceQueue referenceQueue, int textureId) {
107 super(texture, referenceQueue);
174 ResourceTexture texture = cache.get(resourceId);
175 if (texture == null && resourceId != 0) {
176 texture = new ResourceTexture(resourceId, scaled);
177 cache.put(resourceId, texture);
179 return texture;
190 * ResourceTexture texture = array.get(array.keyAt(i)); if (texture !=
191 * null) { texture.clear(); } }
206 public void prime(Texture texture, boolean highPriority) {
207 if (texture != null && texture.mState == Texture.STATE_UNLOADED && (highPriority || mLoadingCount < MAX_LOADING_COUNT)) {
208 queueLoad(texture, highPriority);
212 public void loadTexture(Texture texture) {
213 if (texture != null) {
214 switch (texture.mState) {
215 case Texture.STATE_UNLOADED:
216 case Texture.STATE_QUEUED:
218 texture.mState = Texture.STATE_LOADING;
219 loadTextureAsync(texture);
220 uploadTexture(texture, textureId);
226 private void loadTextureAsync(Texture texture) {
228 Bitmap bitmap = texture.load(this);
233 texture.mWidth = width;
234 texture.mHeight = height;
250 // Store normalized width and height for use in texture
252 texture.mNormalizedWidth = (float) width / (float) paddedWidth;
253 texture.mNormalizedHeight = (float) height / (float) paddedHeight;
255 texture.mNormalizedWidth = 1.0f;
256 texture.mNormalizedHeight = 1.0f;
259 texture.mBitmap = bitmap;
261 texture.mBitmap = null;
268 public boolean bind(Texture texture) {
269 if (texture != null) {
270 if (texture == mBoundTexture)
272 switch (texture.mState) {
273 case Texture.STATE_UNLOADED:
274 if (texture.getClass().equals(ResourceTexture.class)) {
275 loadTexture(texture);
279 queueLoad(texture, false);
282 case Texture.STATE_LOADED:
283 mGL.glBindTexture(GL11.GL_TEXTURE_2D, texture.mId);
284 mBoundTexture = texture;
330 private void queueLoad(final Texture texture, boolean highPriority) {
331 // Allow the texture to defer queuing.
332 if (!texture.shouldQueue()) {
336 // Change the texture state to loading.
337 texture.mState = Texture.STATE_LOADING;
339 // Push the texture onto the load input queue.
340 Deque<Texture> inputQueue = (texture.isUncachedVideo()) ? sLoadInputQueueVideo
341 : (texture.isCached()) ? sLoadInputQueueCached : sLoadInputQueue;
345 inputQueue.addFirst(texture);
349 Texture unloadTexture = inputQueue.pollLast();
350 unloadTexture.mState = Texture.STATE_UNLOADED;
354 inputQueue.addLast(texture);
361 public void draw2D(Texture texture, float x, float y) {
362 if (bind(texture)) {
363 final float width = texture.getWidth();
364 final float height = texture.getHeight();
369 public void draw2D(Texture texture, float x, float y, float width, float height) {
370 if (bind(texture)) {
375 public void draw2D(Texture texture, int x, int y, int width, int height) {
376 if (bind(texture)) {
385 public boolean bindMixed(Texture from, Texture to, float ratio) {
425 // Switch back to the default texture unit.
430 public void drawMixed2D(Texture from, Texture to, float ratio, float x, float y, float z, float width, float height) {
459 // Draw the combined texture.
466 // Switch back to the default texture unit.
478 /** Uploads at most one texture to GL. */
491 Deque<Texture> outputQueue = sLoadOutputQueue;
492 Texture texture;
496 texture = outputQueue.pollFirst();
498 if (texture != null) {
499 // Extract the bitmap from the texture.
500 uploadTexture(texture, textureId);
510 private void uploadTexture(Texture texture, int[] textureId) {
511 Bitmap bitmap = texture.mBitmap;
515 final int width = texture.mWidth;
516 final int height = texture.mHeight;
521 // Upload the bitmap to a new texture.
537 // There was an error, we need to retry this texture at some
539 Log.i(TAG, "Texture creation fail, glError " + glError);
540 texture.mId = 0;
541 texture.mBitmap = null;
542 texture.mState = Texture.STATE_UNLOADED;
544 // Update texture state.
545 texture.mBitmap = null;
546 texture.mId = textureId[0];
547 texture.mState = Texture.STATE_LOADED;
550 final TextureReference textureRef = new TextureReference(texture, gl, mUnreferencedTextureQueue, textureId[0]);
555 texture.mState = Texture.STATE_ERROR;
826 // Clear the resource texture cache.
889 final Texture texture = iter.value.get();
890 if (texture != null) {
891 texture.mState = Texture.STATE_UNLOADED;
1018 Deque<Texture> inputQueue = (sVideoTextureLoadThread == this) ? sLoadInputQueueVideo
1020 Deque<Texture> outputQueue = sLoadOutputQueue;
1023 // Pop the next texture from the input queue.
1024 Texture texture = null;
1026 while ((texture = inputQueue.pollFirst()) == null) {
1032 // Load the texture bitmap.
1033 load(texture);
1036 // Push the texture onto the output queue.
1038 outputQueue.addLast(texture);
1046 private void load(Texture texture) {
1047 // Generate the texture bitmap.
1049 view.loadTextureAsync(texture);