• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2012 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.ui;
18 
19 import android.graphics.Bitmap;
20 import android.graphics.RectF;
21 
22 import com.android.gallery3d.glrenderer.BitmapTexture;
23 import com.android.gallery3d.glrenderer.GLCanvas;
24 
25 public class BitmapScreenNail implements ScreenNail {
26     private final BitmapTexture mBitmapTexture;
27 
BitmapScreenNail(Bitmap bitmap)28     public BitmapScreenNail(Bitmap bitmap) {
29         mBitmapTexture = new BitmapTexture(bitmap);
30     }
31 
32     @Override
getWidth()33     public int getWidth() {
34         return mBitmapTexture.getWidth();
35     }
36 
37     @Override
getHeight()38     public int getHeight() {
39         return mBitmapTexture.getHeight();
40     }
41 
42     @Override
draw(GLCanvas canvas, int x, int y, int width, int height)43     public void draw(GLCanvas canvas, int x, int y, int width, int height) {
44         mBitmapTexture.draw(canvas, x, y, width, height);
45     }
46 
47     @Override
noDraw()48     public void noDraw() {
49         // do nothing
50     }
51 
52     @Override
recycle()53     public void recycle() {
54         mBitmapTexture.recycle();
55     }
56 
57     @Override
draw(GLCanvas canvas, RectF source, RectF dest)58     public void draw(GLCanvas canvas, RectF source, RectF dest) {
59         canvas.drawTexture(mBitmapTexture, source, dest);
60     }
61 }
62