blob: 8d50dc2ccd9452384bdc7bb62b74fad580d4cf03 [file] [log] [blame]
Romain Guy6c319ca2011-01-11 14:29:25 -08001/*
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
Romain Guy6c319ca2011-01-11 14:29:25 -080017#include "LayerRenderer.h"
Romain Guyaa6c24c2011-04-28 18:40:04 -070018#include "Matrix.h"
Romain Guy1fc883b2011-01-12 14:30:59 -080019#include "Properties.h"
Romain Guy3a3133d2011-02-01 22:59:58 -080020#include "Rect.h"
Chris Craik65fe5ee2015-01-26 18:06:29 -080021#include "renderstate/RenderState.h"
Chris Craik5686bae2015-06-23 10:33:46 -070022#include "utils/GLUtils.h"
Chris Craik70850ea2014-11-18 10:49:23 -080023#include "utils/TraceUtils.h"
Romain Guy6c319ca2011-01-11 14:29:25 -080024
Chris Craik65fe5ee2015-01-26 18:06:29 -080025#include <ui/Rect.h>
26
27#include <private/hwui/DrawGlInfo.h>
28
Romain Guy6c319ca2011-01-11 14:29:25 -080029namespace android {
30namespace uirenderer {
31
John Reck3b202512014-06-23 13:13:08 -070032Layer* LayerRenderer::createTextureLayer(RenderState& renderState) {
Romain Guy4a5a7152011-06-24 17:53:53 -070033 LAYER_RENDERER_LOGD("Creating new texture layer");
34
Chris Craik5e00c7c2016-07-06 16:10:09 -070035 Layer* layer = new Layer(renderState, 0, 0);
Romain Guy4a5a7152011-06-24 17:53:53 -070036 layer->layer.set(0.0f, 0.0f, 0.0f, 0.0f);
Romain Guya9dc86b2011-10-11 14:06:21 -070037 layer->texCoords.set(0.0f, 1.0f, 1.0f, 0.0f);
Romain Guy9ace8f52011-07-07 20:50:11 -070038 layer->setRenderTarget(GL_NONE); // see ::updateTextureLayer()
Romain Guy4a5a7152011-06-24 17:53:53 -070039
Chris Craik44eb2c02015-01-29 09:45:09 -080040 Caches::getInstance().textureState().activateTexture(0);
Romain Guy9ace8f52011-07-07 20:50:11 -070041 layer->generateTexture();
Romain Guy4a5a7152011-06-24 17:53:53 -070042
43 return layer;
44}
45
Romain Guyaa6c24c2011-04-28 18:40:04 -070046void LayerRenderer::updateTextureLayer(Layer* layer, uint32_t width, uint32_t height,
Chris Craik5e00c7c2016-07-06 16:10:09 -070047 bool isOpaque, bool forceFilter, GLenum renderTarget, const float* textureTransform) {
48 layer->setBlend(!isOpaque);
49 layer->setForceFilter(forceFilter);
50 layer->setSize(width, height);
51 layer->layer.set(0.0f, 0.0f, width, height);
52 layer->getTexTransform().load(textureTransform);
Romain Guy8f0095c2011-05-02 17:24:22 -070053
Chris Craik5e00c7c2016-07-06 16:10:09 -070054 if (renderTarget != layer->getRenderTarget()) {
55 layer->setRenderTarget(renderTarget);
56 layer->bindTexture();
57 layer->setFilter(GL_NEAREST, false, true);
58 layer->setWrap(GL_CLAMP_TO_EDGE, false, true);
Romain Guyaa6c24c2011-04-28 18:40:04 -070059 }
60}
61
Romain Guy6c319ca2011-01-11 14:29:25 -080062}; // namespace uirenderer
63}; // namespace android