Romain Guy | 6c319ca | 2011-01-11 14:29:25 -0800 | [diff] [blame] | 1 | /* |
| 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 Guy | 6c319ca | 2011-01-11 14:29:25 -0800 | [diff] [blame] | 17 | #include "LayerRenderer.h" |
Romain Guy | aa6c24c | 2011-04-28 18:40:04 -0700 | [diff] [blame] | 18 | #include "Matrix.h" |
Romain Guy | 1fc883b | 2011-01-12 14:30:59 -0800 | [diff] [blame] | 19 | #include "Properties.h" |
Romain Guy | 3a3133d | 2011-02-01 22:59:58 -0800 | [diff] [blame] | 20 | #include "Rect.h" |
Chris Craik | 65fe5ee | 2015-01-26 18:06:29 -0800 | [diff] [blame] | 21 | #include "renderstate/RenderState.h" |
Chris Craik | 5686bae | 2015-06-23 10:33:46 -0700 | [diff] [blame] | 22 | #include "utils/GLUtils.h" |
Chris Craik | 70850ea | 2014-11-18 10:49:23 -0800 | [diff] [blame] | 23 | #include "utils/TraceUtils.h" |
Romain Guy | 6c319ca | 2011-01-11 14:29:25 -0800 | [diff] [blame] | 24 | |
Chris Craik | 65fe5ee | 2015-01-26 18:06:29 -0800 | [diff] [blame] | 25 | #include <ui/Rect.h> |
| 26 | |
| 27 | #include <private/hwui/DrawGlInfo.h> |
| 28 | |
Romain Guy | 6c319ca | 2011-01-11 14:29:25 -0800 | [diff] [blame] | 29 | namespace android { |
| 30 | namespace uirenderer { |
| 31 | |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 32 | Layer* LayerRenderer::createTextureLayer(RenderState& renderState) { |
Romain Guy | 4a5a715 | 2011-06-24 17:53:53 -0700 | [diff] [blame] | 33 | LAYER_RENDERER_LOGD("Creating new texture layer"); |
| 34 | |
Chris Craik | 5e00c7c | 2016-07-06 16:10:09 -0700 | [diff] [blame^] | 35 | Layer* layer = new Layer(renderState, 0, 0); |
Romain Guy | 4a5a715 | 2011-06-24 17:53:53 -0700 | [diff] [blame] | 36 | layer->layer.set(0.0f, 0.0f, 0.0f, 0.0f); |
Romain Guy | a9dc86b | 2011-10-11 14:06:21 -0700 | [diff] [blame] | 37 | layer->texCoords.set(0.0f, 1.0f, 1.0f, 0.0f); |
Romain Guy | 9ace8f5 | 2011-07-07 20:50:11 -0700 | [diff] [blame] | 38 | layer->setRenderTarget(GL_NONE); // see ::updateTextureLayer() |
Romain Guy | 4a5a715 | 2011-06-24 17:53:53 -0700 | [diff] [blame] | 39 | |
Chris Craik | 44eb2c0 | 2015-01-29 09:45:09 -0800 | [diff] [blame] | 40 | Caches::getInstance().textureState().activateTexture(0); |
Romain Guy | 9ace8f5 | 2011-07-07 20:50:11 -0700 | [diff] [blame] | 41 | layer->generateTexture(); |
Romain Guy | 4a5a715 | 2011-06-24 17:53:53 -0700 | [diff] [blame] | 42 | |
| 43 | return layer; |
| 44 | } |
| 45 | |
Romain Guy | aa6c24c | 2011-04-28 18:40:04 -0700 | [diff] [blame] | 46 | void LayerRenderer::updateTextureLayer(Layer* layer, uint32_t width, uint32_t height, |
Chris Craik | 5e00c7c | 2016-07-06 16:10:09 -0700 | [diff] [blame^] | 47 | 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 Guy | 8f0095c | 2011-05-02 17:24:22 -0700 | [diff] [blame] | 53 | |
Chris Craik | 5e00c7c | 2016-07-06 16:10:09 -0700 | [diff] [blame^] | 54 | 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 Guy | aa6c24c | 2011-04-28 18:40:04 -0700 | [diff] [blame] | 59 | } |
| 60 | } |
| 61 | |
Romain Guy | 6c319ca | 2011-01-11 14:29:25 -0800 | [diff] [blame] | 62 | }; // namespace uirenderer |
| 63 | }; // namespace android |