2010-07-06 11:39:32 -07:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2010 The Android Open Source Project
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2010-10-27 18:57:51 -07:00
|
|
|
#ifndef ANDROID_HWUI_LAYER_H
|
|
|
|
#define ANDROID_HWUI_LAYER_H
|
2010-07-06 11:39:32 -07:00
|
|
|
|
2013-12-10 12:28:58 -05:00
|
|
|
#include <cutils/compiler.h>
|
2010-07-08 19:17:03 -07:00
|
|
|
#include <sys/types.h>
|
2014-04-04 16:20:08 -07:00
|
|
|
#include <utils/StrongPointer.h>
|
2010-07-08 19:17:03 -07:00
|
|
|
|
2010-07-06 11:39:32 -07:00
|
|
|
#include <GLES2/gl2.h>
|
|
|
|
|
2010-10-27 18:57:51 -07:00
|
|
|
#include <ui/Region.h>
|
|
|
|
|
2012-08-14 16:44:52 -04:00
|
|
|
#include <SkPaint.h>
|
2010-07-06 11:39:32 -07:00
|
|
|
#include <SkXfermode.h>
|
|
|
|
|
2013-12-10 12:28:58 -05:00
|
|
|
#include "Matrix.h"
|
2010-07-06 11:39:32 -07:00
|
|
|
#include "Rect.h"
|
2013-02-06 16:51:04 -08:00
|
|
|
#include "RenderBuffer.h"
|
2011-07-07 20:50:11 -07:00
|
|
|
#include "Texture.h"
|
2011-01-16 12:54:25 -08:00
|
|
|
#include "Vertex.h"
|
2010-07-06 11:39:32 -07:00
|
|
|
|
|
|
|
namespace android {
|
|
|
|
namespace uirenderer {
|
|
|
|
|
2010-10-08 15:49:53 -07:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Layers
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2010-07-06 11:39:32 -07:00
|
|
|
|
2012-03-02 13:37:47 -08:00
|
|
|
// Forward declarations
|
2013-06-04 18:00:09 -07:00
|
|
|
class Caches;
|
2014-06-23 13:13:08 -07:00
|
|
|
class RenderState;
|
2012-03-02 13:37:47 -08:00
|
|
|
class OpenGLRenderer;
|
2014-03-12 13:56:30 -07:00
|
|
|
class RenderNode;
|
2013-03-26 15:05:58 -07:00
|
|
|
class DeferredDisplayList;
|
|
|
|
class DeferStateStruct;
|
2012-03-02 13:37:47 -08:00
|
|
|
|
2010-07-06 11:39:32 -07:00
|
|
|
/**
|
2010-10-05 18:14:38 -07:00
|
|
|
* A layer has dimensions and is backed by an OpenGL texture or FBO.
|
2010-07-06 11:39:32 -07:00
|
|
|
*/
|
2014-01-02 16:46:18 -08:00
|
|
|
class Layer {
|
|
|
|
public:
|
2014-06-23 13:13:08 -07:00
|
|
|
Layer(RenderState& renderState, const uint32_t layerWidth, const uint32_t layerHeight);
|
2012-09-05 11:40:29 -07:00
|
|
|
~Layer();
|
2010-10-08 15:49:53 -07:00
|
|
|
|
2013-01-18 16:42:51 -08:00
|
|
|
static uint32_t computeIdealWidth(uint32_t layerWidth);
|
|
|
|
static uint32_t computeIdealHeight(uint32_t layerHeight);
|
|
|
|
|
2013-01-15 18:51:42 -08:00
|
|
|
/**
|
|
|
|
* Calling this method will remove (either by recycling or
|
|
|
|
* destroying) the associated FBO, if present, and any render
|
|
|
|
* buffer (stencil for instance.)
|
|
|
|
*/
|
|
|
|
void removeFbo(bool flush = true);
|
2012-09-25 20:30:09 -07:00
|
|
|
|
2011-04-27 14:21:41 -07:00
|
|
|
/**
|
|
|
|
* Sets this layer's region to a rectangle. Computes the appropriate
|
|
|
|
* texture coordinates.
|
|
|
|
*/
|
|
|
|
void setRegionAsRect() {
|
|
|
|
const android::Rect& bounds = region.getBounds();
|
|
|
|
regionRect.set(bounds.leftTop().x, bounds.leftTop().y,
|
|
|
|
bounds.rightBottom().x, bounds.rightBottom().y);
|
|
|
|
|
2011-07-07 20:50:11 -07:00
|
|
|
const float texX = 1.0f / float(texture.width);
|
|
|
|
const float texY = 1.0f / float(texture.height);
|
2011-04-27 14:21:41 -07:00
|
|
|
const float height = layer.getHeight();
|
|
|
|
texCoords.set(
|
|
|
|
regionRect.left * texX, (height - regionRect.top) * texY,
|
|
|
|
regionRect.right * texX, (height - regionRect.bottom) * texY);
|
2011-07-07 20:50:11 -07:00
|
|
|
|
|
|
|
regionRect.translate(layer.left, layer.top);
|
|
|
|
}
|
|
|
|
|
2014-08-14 13:34:01 -07:00
|
|
|
void setWindowTransform(Matrix4& windowTransform) {
|
|
|
|
cachedInvTransformInWindow.loadInverse(windowTransform);
|
|
|
|
rendererLightPosDirty = true;
|
|
|
|
}
|
|
|
|
|
2014-06-20 16:01:00 -07:00
|
|
|
void updateDeferred(RenderNode* renderNode, int left, int top, int right, int bottom);
|
2012-03-02 13:37:47 -08:00
|
|
|
|
2013-02-06 16:51:04 -08:00
|
|
|
inline uint32_t getWidth() const {
|
2011-07-07 20:50:11 -07:00
|
|
|
return texture.width;
|
|
|
|
}
|
|
|
|
|
2013-02-06 16:51:04 -08:00
|
|
|
inline uint32_t getHeight() const {
|
2011-07-07 20:50:11 -07:00
|
|
|
return texture.height;
|
|
|
|
}
|
|
|
|
|
2013-01-18 16:42:51 -08:00
|
|
|
/**
|
|
|
|
* Resize the layer and its texture if needed.
|
|
|
|
*
|
|
|
|
* @param width The new width of the layer
|
|
|
|
* @param height The new height of the layer
|
|
|
|
*
|
|
|
|
* @return True if the layer was resized or nothing happened, false if
|
|
|
|
* a failure occurred during the resizing operation
|
|
|
|
*/
|
|
|
|
bool resize(const uint32_t width, const uint32_t height);
|
|
|
|
|
2011-07-07 20:50:11 -07:00
|
|
|
void setSize(uint32_t width, uint32_t height) {
|
|
|
|
texture.width = width;
|
|
|
|
texture.height = height;
|
|
|
|
}
|
|
|
|
|
2014-02-19 16:47:32 +00:00
|
|
|
ANDROID_API void setPaint(const SkPaint* paint);
|
2012-09-05 11:40:29 -07:00
|
|
|
|
2011-07-07 20:50:11 -07:00
|
|
|
inline void setBlend(bool blend) {
|
|
|
|
texture.blend = blend;
|
|
|
|
}
|
|
|
|
|
2013-02-06 16:51:04 -08:00
|
|
|
inline bool isBlend() const {
|
2011-07-07 20:50:11 -07:00
|
|
|
return texture.blend;
|
|
|
|
}
|
|
|
|
|
2014-02-25 18:50:17 -08:00
|
|
|
inline void setForceFilter(bool forceFilter) {
|
|
|
|
this->forceFilter = forceFilter;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool getForceFilter() const {
|
|
|
|
return forceFilter;
|
|
|
|
}
|
|
|
|
|
2011-07-07 20:50:11 -07:00
|
|
|
inline void setAlpha(int alpha) {
|
|
|
|
this->alpha = alpha;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void setAlpha(int alpha, SkXfermode::Mode mode) {
|
|
|
|
this->alpha = alpha;
|
|
|
|
this->mode = mode;
|
|
|
|
}
|
|
|
|
|
2013-02-06 16:51:04 -08:00
|
|
|
inline int getAlpha() const {
|
2011-07-07 20:50:11 -07:00
|
|
|
return alpha;
|
|
|
|
}
|
|
|
|
|
2013-02-06 16:51:04 -08:00
|
|
|
inline SkXfermode::Mode getMode() const {
|
2011-07-07 20:50:11 -07:00
|
|
|
return mode;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void setEmpty(bool empty) {
|
|
|
|
this->empty = empty;
|
|
|
|
}
|
|
|
|
|
2013-02-06 16:51:04 -08:00
|
|
|
inline bool isEmpty() const {
|
2011-07-07 20:50:11 -07:00
|
|
|
return empty;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void setFbo(GLuint fbo) {
|
|
|
|
this->fbo = fbo;
|
|
|
|
}
|
|
|
|
|
2013-02-06 16:51:04 -08:00
|
|
|
inline GLuint getFbo() const {
|
2011-07-07 20:50:11 -07:00
|
|
|
return fbo;
|
|
|
|
}
|
|
|
|
|
2013-02-06 16:51:04 -08:00
|
|
|
inline void setStencilRenderBuffer(RenderBuffer* renderBuffer) {
|
|
|
|
if (RenderBuffer::isStencilBuffer(renderBuffer->getFormat())) {
|
|
|
|
this->stencil = renderBuffer;
|
|
|
|
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
|
|
|
|
GL_RENDERBUFFER, stencil->getName());
|
|
|
|
} else {
|
|
|
|
ALOGE("The specified render buffer is not a stencil buffer");
|
|
|
|
}
|
2013-01-15 18:51:42 -08:00
|
|
|
}
|
|
|
|
|
2013-02-06 16:51:04 -08:00
|
|
|
inline RenderBuffer* getStencilRenderBuffer() const {
|
2013-01-15 18:51:42 -08:00
|
|
|
return stencil;
|
|
|
|
}
|
|
|
|
|
2013-02-06 16:51:04 -08:00
|
|
|
inline GLuint getTexture() const {
|
2011-07-07 20:50:11 -07:00
|
|
|
return texture.id;
|
|
|
|
}
|
|
|
|
|
2013-02-06 16:51:04 -08:00
|
|
|
inline GLenum getRenderTarget() const {
|
2011-07-07 20:50:11 -07:00
|
|
|
return renderTarget;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void setRenderTarget(GLenum renderTarget) {
|
|
|
|
this->renderTarget = renderTarget;
|
|
|
|
}
|
|
|
|
|
2011-11-30 20:21:23 -08:00
|
|
|
void setWrap(GLenum wrap, bool bindTexture = false, bool force = false) {
|
|
|
|
texture.setWrap(wrap, bindTexture, force, renderTarget);
|
2011-07-07 20:50:11 -07:00
|
|
|
}
|
|
|
|
|
2011-11-30 20:21:23 -08:00
|
|
|
void setFilter(GLenum filter, bool bindTexture = false, bool force = false) {
|
|
|
|
texture.setFilter(filter, bindTexture, force, renderTarget);
|
2011-07-07 20:50:11 -07:00
|
|
|
}
|
|
|
|
|
2013-02-06 16:51:04 -08:00
|
|
|
inline bool isCacheable() const {
|
2011-07-07 20:50:11 -07:00
|
|
|
return cacheable;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void setCacheable(bool cacheable) {
|
|
|
|
this->cacheable = cacheable;
|
|
|
|
}
|
|
|
|
|
2013-02-06 16:51:04 -08:00
|
|
|
inline bool isDirty() const {
|
2012-10-18 15:05:02 -07:00
|
|
|
return dirty;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void setDirty(bool dirty) {
|
|
|
|
this->dirty = dirty;
|
|
|
|
}
|
|
|
|
|
2013-02-06 16:51:04 -08:00
|
|
|
inline bool isTextureLayer() const {
|
2011-07-07 20:50:11 -07:00
|
|
|
return textureLayer;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void setTextureLayer(bool textureLayer) {
|
|
|
|
this->textureLayer = textureLayer;
|
|
|
|
}
|
|
|
|
|
2013-12-10 12:28:58 -05:00
|
|
|
inline SkColorFilter* getColorFilter() const {
|
2011-07-07 20:50:11 -07:00
|
|
|
return colorFilter;
|
|
|
|
}
|
|
|
|
|
2013-12-10 12:28:58 -05:00
|
|
|
ANDROID_API void setColorFilter(SkColorFilter* filter);
|
2011-07-07 20:50:11 -07:00
|
|
|
|
2014-04-15 16:18:08 -07:00
|
|
|
inline void setConvexMask(const SkPath* convexMask) {
|
|
|
|
this->convexMask = convexMask;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline const SkPath* getConvexMask() {
|
|
|
|
return convexMask;
|
|
|
|
}
|
|
|
|
|
2013-06-04 18:00:09 -07:00
|
|
|
void bindStencilRenderBuffer() const;
|
2013-01-18 16:42:51 -08:00
|
|
|
|
2013-06-04 18:00:09 -07:00
|
|
|
void bindTexture() const;
|
|
|
|
void generateTexture();
|
|
|
|
void allocateTexture();
|
|
|
|
void deleteTexture();
|
2012-09-25 12:17:14 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* When the caller frees the texture itself, the caller
|
|
|
|
* must call this method to tell this layer that it lost
|
|
|
|
* the texture.
|
|
|
|
*/
|
2013-06-04 18:00:09 -07:00
|
|
|
ANDROID_API void clearTexture();
|
2013-01-18 16:42:51 -08:00
|
|
|
|
2011-07-07 20:50:11 -07:00
|
|
|
inline mat4& getTexTransform() {
|
|
|
|
return texTransform;
|
2011-04-27 14:21:41 -07:00
|
|
|
}
|
|
|
|
|
2011-08-16 13:55:02 -07:00
|
|
|
inline mat4& getTransform() {
|
|
|
|
return transform;
|
|
|
|
}
|
|
|
|
|
2014-08-14 13:34:01 -07:00
|
|
|
void defer(const OpenGLRenderer& rootRenderer);
|
2013-06-17 13:14:51 -07:00
|
|
|
void cancelDefer();
|
2013-03-26 15:05:58 -07:00
|
|
|
void flush();
|
2014-08-14 13:34:01 -07:00
|
|
|
void render(const OpenGLRenderer& rootRenderer);
|
2013-03-26 15:05:58 -07:00
|
|
|
|
2010-07-06 11:39:32 -07:00
|
|
|
/**
|
2010-10-08 15:49:53 -07:00
|
|
|
* Bounds of the layer.
|
2010-07-06 11:39:32 -07:00
|
|
|
*/
|
|
|
|
Rect layer;
|
|
|
|
/**
|
2010-10-08 15:49:53 -07:00
|
|
|
* Texture coordinates of the layer.
|
2010-07-06 11:39:32 -07:00
|
|
|
*/
|
2010-10-08 15:49:53 -07:00
|
|
|
Rect texCoords;
|
2013-01-29 17:26:25 -08:00
|
|
|
/**
|
|
|
|
* Clipping rectangle.
|
|
|
|
*/
|
|
|
|
Rect clipRect;
|
2010-10-08 15:49:53 -07:00
|
|
|
|
2010-10-05 18:14:38 -07:00
|
|
|
/**
|
2011-07-07 20:50:11 -07:00
|
|
|
* Dirty region indicating what parts of the layer
|
|
|
|
* have been drawn.
|
2010-10-05 18:14:38 -07:00
|
|
|
*/
|
2011-07-07 20:50:11 -07:00
|
|
|
Region region;
|
2010-07-06 11:39:32 -07:00
|
|
|
/**
|
2011-07-07 20:50:11 -07:00
|
|
|
* If the region is a rectangle, coordinates of the
|
|
|
|
* region are stored here.
|
2010-07-06 11:39:32 -07:00
|
|
|
*/
|
2011-07-07 20:50:11 -07:00
|
|
|
Rect regionRect;
|
|
|
|
|
2010-07-06 11:39:32 -07:00
|
|
|
/**
|
2011-07-07 20:50:11 -07:00
|
|
|
* If the layer can be rendered as a mesh, this is non-null.
|
2010-07-06 11:39:32 -07:00
|
|
|
*/
|
2011-07-07 20:50:11 -07:00
|
|
|
TextureVertex* mesh;
|
|
|
|
GLsizei meshElementCount;
|
|
|
|
|
2012-03-02 13:37:47 -08:00
|
|
|
/**
|
|
|
|
* Used for deferred updates.
|
|
|
|
*/
|
|
|
|
bool deferredUpdateScheduled;
|
|
|
|
OpenGLRenderer* renderer;
|
2014-06-20 16:01:00 -07:00
|
|
|
sp<RenderNode> renderNode;
|
2012-03-02 13:37:47 -08:00
|
|
|
Rect dirtyRect;
|
2012-11-29 17:52:58 -08:00
|
|
|
bool debugDrawUpdate;
|
2013-04-15 16:08:28 -07:00
|
|
|
bool hasDrawnSinceUpdate;
|
2012-03-02 13:37:47 -08:00
|
|
|
|
2011-07-07 20:50:11 -07:00
|
|
|
private:
|
2014-03-26 15:10:40 -07:00
|
|
|
void requireRenderer();
|
2014-08-14 13:34:01 -07:00
|
|
|
void updateLightPosFromRenderer(const OpenGLRenderer& rootRenderer);
|
2014-03-26 15:10:40 -07:00
|
|
|
|
2013-06-04 18:00:09 -07:00
|
|
|
Caches& caches;
|
|
|
|
|
2014-06-23 13:13:08 -07:00
|
|
|
RenderState& renderState;
|
|
|
|
|
2010-07-06 11:39:32 -07:00
|
|
|
/**
|
2011-07-07 20:50:11 -07:00
|
|
|
* Name of the FBO used to render the layer. If the name is 0
|
|
|
|
* this layer is not backed by an FBO, but a simple texture.
|
2010-07-06 11:39:32 -07:00
|
|
|
*/
|
2011-07-07 20:50:11 -07:00
|
|
|
GLuint fbo;
|
2010-10-08 15:49:53 -07:00
|
|
|
|
2013-01-15 18:51:42 -08:00
|
|
|
/**
|
2013-02-06 16:51:04 -08:00
|
|
|
* The render buffer used as the stencil buffer.
|
2013-01-15 18:51:42 -08:00
|
|
|
*/
|
2013-02-06 16:51:04 -08:00
|
|
|
RenderBuffer* stencil;
|
2013-01-15 18:51:42 -08:00
|
|
|
|
2010-09-22 22:48:20 -07:00
|
|
|
/**
|
2010-10-01 00:25:02 -07:00
|
|
|
* Indicates whether this layer has been used already.
|
2010-09-22 22:48:20 -07:00
|
|
|
*/
|
|
|
|
bool empty;
|
2010-10-08 15:49:53 -07:00
|
|
|
|
|
|
|
/**
|
2011-07-07 20:50:11 -07:00
|
|
|
* The texture backing this layer.
|
2010-10-08 15:49:53 -07:00
|
|
|
*/
|
2011-07-07 20:50:11 -07:00
|
|
|
Texture texture;
|
|
|
|
|
2010-10-08 15:49:53 -07:00
|
|
|
/**
|
2011-07-07 20:50:11 -07:00
|
|
|
* If set to true (by default), the layer can be reused.
|
2010-10-08 15:49:53 -07:00
|
|
|
*/
|
2011-07-07 20:50:11 -07:00
|
|
|
bool cacheable;
|
2010-10-27 18:57:51 -07:00
|
|
|
|
|
|
|
/**
|
2011-07-07 20:50:11 -07:00
|
|
|
* When set to true, this layer must be treated as a texture
|
|
|
|
* layer.
|
2010-10-27 18:57:51 -07:00
|
|
|
*/
|
2011-07-07 20:50:11 -07:00
|
|
|
bool textureLayer;
|
|
|
|
|
2012-10-18 15:05:02 -07:00
|
|
|
/**
|
|
|
|
* When set to true, this layer is dirty and should be cleared
|
|
|
|
* before any rendering occurs.
|
|
|
|
*/
|
|
|
|
bool dirty;
|
|
|
|
|
2011-03-18 14:34:03 -07:00
|
|
|
/**
|
2011-07-07 20:50:11 -07:00
|
|
|
* Indicates the render target.
|
2011-03-18 14:34:03 -07:00
|
|
|
*/
|
2011-07-07 20:50:11 -07:00
|
|
|
GLenum renderTarget;
|
2011-01-06 10:04:23 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Color filter used to draw this layer. Optional.
|
|
|
|
*/
|
2013-12-10 12:28:58 -05:00
|
|
|
SkColorFilter* colorFilter;
|
2011-01-16 12:54:25 -08:00
|
|
|
|
2014-02-25 18:50:17 -08:00
|
|
|
/**
|
|
|
|
* Indicates raster data backing the layer is scaled, requiring filtration.
|
|
|
|
*/
|
|
|
|
bool forceFilter;
|
|
|
|
|
2011-01-16 12:54:25 -08:00
|
|
|
/**
|
2011-07-07 20:50:11 -07:00
|
|
|
* Opacity of the layer.
|
New widget: TextureView
Bug #4343984
TextureView can be used to render media content (video, OpenGL,
RenderScript) inside a View.
The key difference with SurfaceView is that TextureView does
not create a new Surface. This gives the ability to seamlessly
transform, animate, fade, etc. a TextureView, which was hard
if not impossible to do with a SurfaceView.
A TextureView also interacts perfectly with ScrollView,
ListView, etc. It allows application to embed media content
in a much more flexible way than before.
For instance, to render the camera preview at 50% opacity,
all you need to do is the following:
mTextureView.setAlpha(0.5f);
Camera c = Camera.open();
c.setPreviewTexture(mTextureView.getSurfaceTexture());
c.startPreview();
TextureView uses a SurfaceTexture to get the job done. More
APIs are required to make it easy to create OpenGL contexts
for a TextureView. It can currently be done with a bit of
JNI code.
Change-Id: Iaa7953097ab5beb8437bcbbfa03b2df5b7f80cd7
2011-04-28 18:40:04 -07:00
|
|
|
*/
|
2011-07-07 20:50:11 -07:00
|
|
|
int alpha;
|
2014-02-25 18:50:17 -08:00
|
|
|
|
New widget: TextureView
Bug #4343984
TextureView can be used to render media content (video, OpenGL,
RenderScript) inside a View.
The key difference with SurfaceView is that TextureView does
not create a new Surface. This gives the ability to seamlessly
transform, animate, fade, etc. a TextureView, which was hard
if not impossible to do with a SurfaceView.
A TextureView also interacts perfectly with ScrollView,
ListView, etc. It allows application to embed media content
in a much more flexible way than before.
For instance, to render the camera preview at 50% opacity,
all you need to do is the following:
mTextureView.setAlpha(0.5f);
Camera c = Camera.open();
c.setPreviewTexture(mTextureView.getSurfaceTexture());
c.startPreview();
TextureView uses a SurfaceTexture to get the job done. More
APIs are required to make it easy to create OpenGL contexts
for a TextureView. It can currently be done with a bit of
JNI code.
Change-Id: Iaa7953097ab5beb8437bcbbfa03b2df5b7f80cd7
2011-04-28 18:40:04 -07:00
|
|
|
/**
|
2011-07-07 20:50:11 -07:00
|
|
|
* Blending mode of the layer.
|
New widget: TextureView
Bug #4343984
TextureView can be used to render media content (video, OpenGL,
RenderScript) inside a View.
The key difference with SurfaceView is that TextureView does
not create a new Surface. This gives the ability to seamlessly
transform, animate, fade, etc. a TextureView, which was hard
if not impossible to do with a SurfaceView.
A TextureView also interacts perfectly with ScrollView,
ListView, etc. It allows application to embed media content
in a much more flexible way than before.
For instance, to render the camera preview at 50% opacity,
all you need to do is the following:
mTextureView.setAlpha(0.5f);
Camera c = Camera.open();
c.setPreviewTexture(mTextureView.getSurfaceTexture());
c.startPreview();
TextureView uses a SurfaceTexture to get the job done. More
APIs are required to make it easy to create OpenGL contexts
for a TextureView. It can currently be done with a bit of
JNI code.
Change-Id: Iaa7953097ab5beb8437bcbbfa03b2df5b7f80cd7
2011-04-28 18:40:04 -07:00
|
|
|
*/
|
2011-07-07 20:50:11 -07:00
|
|
|
SkXfermode::Mode mode;
|
New widget: TextureView
Bug #4343984
TextureView can be used to render media content (video, OpenGL,
RenderScript) inside a View.
The key difference with SurfaceView is that TextureView does
not create a new Surface. This gives the ability to seamlessly
transform, animate, fade, etc. a TextureView, which was hard
if not impossible to do with a SurfaceView.
A TextureView also interacts perfectly with ScrollView,
ListView, etc. It allows application to embed media content
in a much more flexible way than before.
For instance, to render the camera preview at 50% opacity,
all you need to do is the following:
mTextureView.setAlpha(0.5f);
Camera c = Camera.open();
c.setPreviewTexture(mTextureView.getSurfaceTexture());
c.startPreview();
TextureView uses a SurfaceTexture to get the job done. More
APIs are required to make it easy to create OpenGL contexts
for a TextureView. It can currently be done with a bit of
JNI code.
Change-Id: Iaa7953097ab5beb8437bcbbfa03b2df5b7f80cd7
2011-04-28 18:40:04 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Optional texture coordinates transform.
|
|
|
|
*/
|
|
|
|
mat4 texTransform;
|
2011-05-02 17:24:22 -07:00
|
|
|
|
2011-08-16 13:55:02 -07:00
|
|
|
/**
|
|
|
|
* Optional transform.
|
|
|
|
*/
|
|
|
|
mat4 transform;
|
|
|
|
|
2014-08-14 13:34:01 -07:00
|
|
|
/**
|
|
|
|
* Cached transform of layer in window, updated only on creation / resize
|
|
|
|
*/
|
|
|
|
mat4 cachedInvTransformInWindow;
|
|
|
|
bool rendererLightPosDirty;
|
|
|
|
|
2013-03-26 15:05:58 -07:00
|
|
|
/**
|
|
|
|
* Used to defer display lists when the layer is updated with a
|
|
|
|
* display list.
|
|
|
|
*/
|
|
|
|
DeferredDisplayList* deferredList;
|
|
|
|
|
2014-04-15 16:18:08 -07:00
|
|
|
/**
|
|
|
|
* This convex path should be used to mask the layer's draw to the screen.
|
|
|
|
*
|
|
|
|
* Data not owned/managed by layer object.
|
|
|
|
*/
|
|
|
|
const SkPath* convexMask;
|
|
|
|
|
2010-07-06 11:39:32 -07:00
|
|
|
}; // struct Layer
|
|
|
|
|
|
|
|
}; // namespace uirenderer
|
|
|
|
}; // namespace android
|
|
|
|
|
2010-10-27 18:57:51 -07:00
|
|
|
#endif // ANDROID_HWUI_LAYER_H
|