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
|
|
|
|
2010-07-08 19:17:03 -07:00
|
|
|
#include <sys/types.h>
|
|
|
|
|
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>
|
|
|
|
|
|
|
|
#include "Rect.h"
|
2013-02-06 16:51:04 -08:00
|
|
|
#include "RenderBuffer.h"
|
2011-01-06 10:04:23 -08:00
|
|
|
#include "SkiaColorFilter.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
|
|
|
|
class OpenGLRenderer;
|
|
|
|
class DisplayList;
|
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
|
|
|
*/
|
|
|
|
struct Layer {
|
Fix occasional crash bug with layers
Launcher occasionally crashes with a stack trace indicating that the memory
of a Layer object is corrupt. It is possible for us to delete a Layer
structure and then, briefly, use it to draw a DisplayList again before
that DisplayList gets recreated (without the layer that got deleted).
When this happens, if the memory got corrupted, it's possible to crash.
The fix is to add Layer to the other objects which we currently refcount
(bitmaps, shaders, etc.). Then instead of deleting a Layer, we decrement the
refcount. We increment when creating it, then increment it again when it's
referenced from a DisplayList. Then we decrement the refcount instead of
deleting it, and decrement when we clear a DisplayList that refers to it.
Then when the refcount reaches 0, we delete it.
Issue #6994632 Native crash in launcher when trying to launch all apps screen
Change-Id: I0627be8d49bb2f9ba8d158a84b764bb4e7df934c
2012-09-14 15:31:25 -07:00
|
|
|
Layer(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);
|
|
|
|
}
|
|
|
|
|
2012-03-02 13:37:47 -08:00
|
|
|
void updateDeferred(OpenGLRenderer* renderer, DisplayList* displayList,
|
|
|
|
int left, int top, int right, int bottom) {
|
|
|
|
this->renderer = renderer;
|
|
|
|
this->displayList = displayList;
|
|
|
|
const Rect r(left, top, right, bottom);
|
|
|
|
dirtyRect.unionWith(r);
|
|
|
|
deferredUpdateScheduled = true;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2012-09-05 11:40:29 -07:00
|
|
|
ANDROID_API void setPaint(SkPaint* paint);
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
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-02-06 16:51:04 -08:00
|
|
|
inline SkiaColorFilter* getColorFilter() const {
|
2011-07-07 20:50:11 -07:00
|
|
|
return colorFilter;
|
|
|
|
}
|
|
|
|
|
2012-09-05 11:40:29 -07:00
|
|
|
ANDROID_API void setColorFilter(SkiaColorFilter* filter);
|
2011-07-07 20:50:11 -07:00
|
|
|
|
2013-02-06 16:51:04 -08:00
|
|
|
inline void bindTexture() const {
|
2012-09-25 12:17:14 -07:00
|
|
|
if (texture.id) {
|
|
|
|
glBindTexture(renderTarget, texture.id);
|
|
|
|
}
|
2011-07-07 20:50:11 -07:00
|
|
|
}
|
|
|
|
|
2013-02-06 16:51:04 -08:00
|
|
|
inline void bindStencilRenderBuffer() const {
|
2013-01-18 16:42:51 -08:00
|
|
|
if (stencil) {
|
2013-02-06 16:51:04 -08:00
|
|
|
stencil->bind();
|
2013-01-18 16:42:51 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-07 20:50:11 -07:00
|
|
|
inline void generateTexture() {
|
2012-09-25 12:17:14 -07:00
|
|
|
if (!texture.id) {
|
|
|
|
glGenTextures(1, &texture.id);
|
|
|
|
}
|
2011-07-07 20:50:11 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
inline void deleteTexture() {
|
2012-09-25 12:17:14 -07:00
|
|
|
if (texture.id) {
|
|
|
|
glDeleteTextures(1, &texture.id);
|
|
|
|
texture.id = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* When the caller frees the texture itself, the caller
|
|
|
|
* must call this method to tell this layer that it lost
|
|
|
|
* the texture.
|
|
|
|
*/
|
|
|
|
void clearTexture() {
|
|
|
|
texture.id = 0;
|
2011-07-07 20:50:11 -07:00
|
|
|
}
|
|
|
|
|
2013-04-04 12:27:54 -07:00
|
|
|
inline void allocateTexture() {
|
2012-10-17 18:18:35 -07:00
|
|
|
#if DEBUG_LAYERS
|
|
|
|
ALOGD(" Allocate layer: %dx%d", getWidth(), getHeight());
|
|
|
|
#endif
|
2013-01-18 16:42:51 -08:00
|
|
|
if (texture.id) {
|
2013-04-04 12:27:54 -07:00
|
|
|
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
|
|
|
|
glTexImage2D(renderTarget, 0, GL_RGBA, getWidth(), getHeight(), 0,
|
|
|
|
GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
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;
|
|
|
|
}
|
|
|
|
|
2013-03-26 15:05:58 -07:00
|
|
|
void defer();
|
|
|
|
void flush();
|
2013-03-29 12:37:16 -07:00
|
|
|
void render();
|
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;
|
|
|
|
uint16_t* meshIndices;
|
|
|
|
GLsizei meshElementCount;
|
|
|
|
|
2012-03-02 13:37:47 -08:00
|
|
|
/**
|
|
|
|
* Used for deferred updates.
|
|
|
|
*/
|
|
|
|
bool deferredUpdateScheduled;
|
|
|
|
OpenGLRenderer* renderer;
|
|
|
|
DisplayList* displayList;
|
|
|
|
Rect dirtyRect;
|
2012-11-29 17:52:58 -08:00
|
|
|
bool debugDrawUpdate;
|
2012-03-02 13:37:47 -08:00
|
|
|
|
2011-07-07 20:50:11 -07:00
|
|
|
private:
|
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.
|
|
|
|
*/
|
|
|
|
SkiaColorFilter* colorFilter;
|
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;
|
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;
|
|
|
|
|
2013-03-26 15:05:58 -07:00
|
|
|
/**
|
|
|
|
* Used to defer display lists when the layer is updated with a
|
|
|
|
* display list.
|
|
|
|
*/
|
|
|
|
DeferredDisplayList* deferredList;
|
|
|
|
|
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
|