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