Home | History | Annotate | Download | only in glrenderer
      1 /*
      2  * Copyright (C) 2010 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package com.android.gallery3d.glrenderer;
     18 
     19 import android.util.Log;
     20 
     21 import javax.microedition.khronos.opengles.GL11;
     22 
     23 public class RawTexture extends BasicTexture {
     24     private static final String TAG = "RawTexture";
     25 
     26     private final boolean mOpaque;
     27     private boolean mIsFlipped;
     28 
     29     public RawTexture(int width, int height, boolean opaque) {
     30         mOpaque = opaque;
     31         setSize(width, height);
     32     }
     33 
     34     @Override
     35     public boolean isOpaque() {
     36         return mOpaque;
     37     }
     38 
     39     @Override
     40     public boolean isFlippedVertically() {
     41         return mIsFlipped;
     42     }
     43 
     44     public void setIsFlippedVertically(boolean isFlipped) {
     45         mIsFlipped = isFlipped;
     46     }
     47 
     48     protected void prepare(GLCanvas canvas) {
     49         GLId glId = canvas.getGLId();
     50         mId = glId.generateTexture();
     51         canvas.initializeTextureSize(this, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE);
     52         canvas.setTextureParameters(this);
     53         mState = STATE_LOADED;
     54         setAssociatedCanvas(canvas);
     55     }
     56 
     57     @Override
     58     protected boolean onBind(GLCanvas canvas) {
     59         if (isLoaded()) return true;
     60         Log.w(TAG, "lost the content due to context change");
     61         return false;
     62     }
     63 
     64     @Override
     65      public void yield() {
     66          // we cannot free the texture because we have no backup.
     67      }
     68 
     69     @Override
     70     protected int getTarget() {
     71         return GL11.GL_TEXTURE_2D;
     72     }
     73 }
     74