blob: fcf421bbc3f2d8d5e9f488f98162d8a7cc1d9342 [file] [log] [blame]
Romain Guyaa6c24c2011-04-28 18:40:04 -07001/*
2 * Copyright (C) 2011 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 android.view;
18
19import android.graphics.Canvas;
20import android.graphics.SurfaceTexture;
21
22/**
23 * An OpenGL ES 2.0 implementation of {@link HardwareLayer}. This
24 * implementation can be used as a texture. Rendering into this
25 * layer is not controlled by a {@link HardwareCanvas}.
26 */
27class GLES20TextureLayer extends GLES20Layer {
28 private int mTexture;
29 private SurfaceTexture mSurface;
30
31 GLES20TextureLayer() {
32 int[] layerInfo = new int[2];
33 mLayer = GLES20Canvas.nCreateTextureLayer(layerInfo);
34
35 if (mLayer != 0) {
36 mTexture = layerInfo[0];
37 mFinalizer = new Finalizer(mLayer);
38 } else {
39 mFinalizer = null;
40 }
41 }
42
43 @Override
44 boolean isValid() {
45 return mLayer != 0 && mTexture != 0;
46 }
47
48 @Override
49 void resize(int width, int height) {
50 }
51
52 @Override
53 HardwareCanvas getCanvas() {
54 return null;
55 }
56
57 @Override
58 HardwareCanvas start(Canvas currentCanvas) {
59 return null;
60 }
61
62 @Override
63 void end(Canvas currentCanvas) {
64 }
65
66 SurfaceTexture getSurfaceTexture() {
67 if (mSurface == null) {
68 mSurface = new SurfaceTexture(mTexture);
69 }
70 return mSurface;
71 }
72
Romain Guy8f0095c2011-05-02 17:24:22 -070073 void update(int width, int height, int surface) {
74 GLES20Canvas.nUpdateTextureLayer(mLayer, width, height, surface);
Romain Guyaa6c24c2011-04-28 18:40:04 -070075 }
76}