Ejemplo n.º 1
0
            //@Override
            public void OnPostExecute(T result)
            {
                try {
                    this.mPD.Dismiss();
                } catch (Exception e) {
                    Debug.E("Error", e);
                    /* Nothing. */
                }

                if (this.IsCancelled)
                {
                    this.mException = new CancelledException();
                }

                if (this.mException == null)
                {
                    pCallback.OnCallback(result);
                }
                else
                {
                    if (pExceptionCallback == null)
                    {
                        Debug.E("Error", this.mException);
                    }
                    else
                    {
                        pExceptionCallback.OnCallback(this.mException);
                    }
                }

                base.OnPostExecute(result);
            }
Ejemplo n.º 2
0
        // ===========================================================
        // Constructors
        // ===========================================================

        public AssetTextureSource(Context pContext, String pAssetPath)
        {
            this.mContext   = pContext;
            this.mAssetPath = pAssetPath;

            BitmapFactory.Options decodeOptions = new BitmapFactory.Options();
            decodeOptions.InJustDecodeBounds = true;

            //InputStream input = null;
            System.IO.Stream input = null;
            try
            {
                //input = pContext.getAssets().open(pAssetPath);
                input = pContext.Assets.Open(pAssetPath);
                BitmapFactory.DecodeStream(input, null, decodeOptions);
            }
            catch (IOException e)
            {
                Debug.E("Failed loading Bitmap in AssetTextureSource. AssetPath: " + pAssetPath, e);
            }
            finally
            {
                StreamUtils.CloseStream(input);
            }

            this.mWidth  = decodeOptions.OutWidth;
            this.mHeight = decodeOptions.OutHeight;
        }
Ejemplo n.º 3
0
 public void OnCallback(T result)
 {
     try {
         pd.Dismiss();
     } catch (Exception e) {
         Debug.E("Error", e);
     }
 }
Ejemplo n.º 4
0
 public /* override */ void OnDrawFrame(GL10 pGL)
 {
     try
     {
         this.mEngine.OnDrawFrame(pGL);
     }
     catch (InterruptedException e)
     {
         Debug.E("GLThread interrupted!", e);
     }
 }
Ejemplo n.º 5
0
        private void WriteTextureToHardware(GL10 pGL)
        {
            bool preMultipyAlpha = this.mTextureOptions.mPreMultipyAlpha;

            //final ArrayList<TextureSourceWithLocation> textureSources = this.mTextureSources;
            List <TextureSourceWithLocation> textureSources = this.mTextureSources;
            int textureSourceCount = textureSources.Count;

            for (int j = 0; j < textureSourceCount; j++)
            {
                TextureSourceWithLocation textureSourceWithLocation = textureSources[j];
                if (textureSourceWithLocation != null)
                {
                    Bitmap bmp = textureSourceWithLocation.OnLoadBitmap();
                    try
                    {
                        if (bmp == null)
                        {
                            throw new IllegalArgumentException("TextureSource: " + textureSourceWithLocation.ToString() + " returned a null Bitmap.");
                        }
                        if (preMultipyAlpha)
                        {
                            GLUtils.TexSubImage2D(GL10Consts.GlTexture2d, 0, textureSourceWithLocation.GetTexturePositionX(), textureSourceWithLocation.GetTexturePositionY(), bmp, GL10Consts.GlRgba, GL10Consts.GlUnsignedByte);
                        }
                        else
                        {
                            GLHelper.GlTexSubImage2D(pGL, GL10Consts.GlTexture2d, 0, textureSourceWithLocation.GetTexturePositionX(), textureSourceWithLocation.GetTexturePositionY(), bmp, GL10Consts.GlRgba, GL10Consts.GlUnsignedByte);
                        }

                        bmp.Recycle();
                    }
                    catch (IllegalArgumentException iae)
                    {
                        // TODO Load some static checkerboard or so to visualize that loading the texture has failed.
                        Debug.E("Error loading: " + textureSourceWithLocation.ToString(), iae);
                        if (this.mTextureStateListener != null)
                        {
                            this.mTextureStateListener.OnTextureSourceLoadExeption(this, textureSourceWithLocation.mTextureSource, iae);
                        }
                        else
                        {
                            throw iae;
                        }
                    }
                }
            }
        }
Ejemplo n.º 6
0
        public /* override */ virtual Bitmap OnLoadBitmap()
        {
            System.IO.Stream input = null;
            //InputStream input = null;
            try
            {
                BitmapFactory.Options decodeOptions = new BitmapFactory.Options();
                decodeOptions.InPreferredConfig = Config.Argb8888;

                //input = this.mContext.getAssets().open(this.mAssetPath);
                input = this.mContext.Assets.Open(this.mAssetPath);
                return(BitmapFactory.DecodeStream(input, null, decodeOptions));
            }
            catch (IOException e)
            {
                Debug.E("Failed loading Bitmap in AssetTextureSource. AssetPath: " + this.mAssetPath, e);
                return(null);
            }
            finally
            {
                //StreamUtils.closeStream(input);
            }
        }
Ejemplo n.º 7
0
 public /* override */ virtual void OnTextureSourceLoadExeption(Texture pTexture, ITextureSource pTextureSource, Throwable pThrowable)
 {
     Debug.E("Exception loading TextureSource. Texture: " + pTexture.ToString() + " TextureSource: " + pTextureSource, pThrowable);
 }