blob: 2423a3467e60cd855e14283b2c444d1e8ee0da84 [file] [log] [blame]
Vishnu Nairf19544f2020-02-03 11:23:26 -08001/*
2 * Copyright 2020 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#include <GLES/gl.h>
18#include <GLES/glext.h>
19#include <GLES2/gl2.h>
20#include <GLES2/gl2ext.h>
21#include <GLES3/gl3.h>
22
23#include "GLShadowTexture.h"
24#include "GLSkiaShadowPort.h"
25
26namespace android {
27namespace renderengine {
28namespace gl {
29
30GLShadowTexture::GLShadowTexture() {
31 fillShadowTextureData(mTextureData, SHADOW_TEXTURE_WIDTH);
32
33 glGenTextures(1, &mName);
34 glBindTexture(GL_TEXTURE_2D, mName);
35 glTexImage2D(GL_TEXTURE_2D, 0 /* base image level */, GL_ALPHA, SHADOW_TEXTURE_WIDTH,
36 SHADOW_TEXTURE_HEIGHT, 0 /* border */, GL_ALPHA, GL_UNSIGNED_BYTE, mTextureData);
37 mTexture.init(Texture::TEXTURE_2D, mName);
38 mTexture.setFiltering(true);
39 mTexture.setDimensions(SHADOW_TEXTURE_WIDTH, 1);
40}
41
42GLShadowTexture::~GLShadowTexture() {
43 glDeleteTextures(1, &mName);
44}
45
46const Texture& GLShadowTexture::getTexture() {
47 return mTexture;
48}
49
50} // namespace gl
51} // namespace renderengine
52} // namespace android