diff options
Diffstat (limited to 'libs')
-rw-r--r-- | libs/hwui/Caches.cpp | 8 | ||||
-rw-r--r-- | libs/hwui/Caches.h | 1 | ||||
-rw-r--r-- | libs/hwui/Layer.cpp | 16 | ||||
-rw-r--r-- | libs/hwui/Layer.h | 18 | ||||
-rw-r--r-- | libs/hwui/LayerCache.cpp | 2 | ||||
-rw-r--r-- | libs/hwui/LayerRenderer.cpp | 3 | ||||
-rw-r--r-- | libs/hwui/PathTessellator.cpp | 17 | ||||
-rw-r--r-- | libs/hwui/RenderNode.cpp | 4 |
8 files changed, 43 insertions, 26 deletions
diff --git a/libs/hwui/Caches.cpp b/libs/hwui/Caches.cpp index 9855f71..f853d1f 100644 --- a/libs/hwui/Caches.cpp +++ b/libs/hwui/Caches.cpp @@ -551,9 +551,13 @@ void Caches::bindTexture(GLuint texture) { } void Caches::bindTexture(GLenum target, GLuint texture) { - if (mBoundTextures[mTextureUnit] != texture) { + if (target == GL_TEXTURE_2D) { + bindTexture(texture); + } else { + // GLConsumer directly calls glBindTexture() with + // target=GL_TEXTURE_EXTERNAL_OES, don't cache this target + // since the cached state could be stale glBindTexture(target, texture); - mBoundTextures[mTextureUnit] = texture; } } diff --git a/libs/hwui/Caches.h b/libs/hwui/Caches.h index 726b74d..7aa628c 100644 --- a/libs/hwui/Caches.h +++ b/libs/hwui/Caches.h @@ -431,6 +431,7 @@ private: uint32_t mFunctorsCount; + // Caches texture bindings for the GL_TEXTURE_2D target GLuint mBoundTextures[REQUIRED_TEXTURE_UNITS_COUNT]; OverdrawColorSet mOverdrawDebugColorSet; diff --git a/libs/hwui/Layer.cpp b/libs/hwui/Layer.cpp index 25caae3..91c4aee 100644 --- a/libs/hwui/Layer.cpp +++ b/libs/hwui/Layer.cpp @@ -29,15 +29,15 @@ namespace android { namespace uirenderer { -Layer::Layer(RenderState& renderState, const uint32_t layerWidth, const uint32_t layerHeight) +Layer::Layer(Type layerType, RenderState& renderState, const uint32_t layerWidth, const uint32_t layerHeight) : caches(Caches::getInstance()) , renderState(renderState) - , texture(caches) { + , texture(caches) + , type(layerType) { mesh = NULL; meshElementCount = 0; cacheable = true; dirty = false; - textureLayer = false; renderTarget = GL_TEXTURE_2D; texture.width = layerWidth; texture.height = layerHeight; @@ -55,11 +55,17 @@ Layer::Layer(RenderState& renderState, const uint32_t layerWidth, const uint32_t caches.resourceCache.incrementRefcount(this); rendererLightPosDirty = true; wasBuildLayered = false; - renderState.registerLayer(this); + if (!isTextureLayer()) { + // track only non-texture layer lifecycles in renderstate, + // because texture layers are destroyed via finalizer + renderState.registerLayer(this); + } } Layer::~Layer() { - renderState.unregisterLayer(this); + if (!isTextureLayer()) { + renderState.unregisterLayer(this); + } SkSafeUnref(colorFilter); removeFbo(); deleteTexture(); diff --git a/libs/hwui/Layer.h b/libs/hwui/Layer.h index 911b99880..36a4ed1 100644 --- a/libs/hwui/Layer.h +++ b/libs/hwui/Layer.h @@ -54,7 +54,12 @@ class DeferStateStruct; */ class Layer { public: - Layer(RenderState& renderState, const uint32_t layerWidth, const uint32_t layerHeight); + enum Type { + kType_Texture, + kType_DisplayList, + }; + + Layer(Type type, RenderState& renderState, const uint32_t layerWidth, const uint32_t layerHeight); ~Layer(); static uint32_t computeIdealWidth(uint32_t layerWidth); @@ -219,11 +224,7 @@ public: } inline bool isTextureLayer() const { - return textureLayer; - } - - inline void setTextureLayer(bool textureLayer) { - this->textureLayer = textureLayer; + return type == kType_Texture; } inline SkColorFilter* getColorFilter() const { @@ -343,10 +344,9 @@ private: bool cacheable; /** - * When set to true, this layer must be treated as a texture - * layer. + * Denotes whether the layer is a DisplayList, or Texture layer. */ - bool textureLayer; + const Type type; /** * When set to true, this layer is dirty and should be cleared diff --git a/libs/hwui/LayerCache.cpp b/libs/hwui/LayerCache.cpp index efa30ac..d49daf6 100644 --- a/libs/hwui/LayerCache.cpp +++ b/libs/hwui/LayerCache.cpp @@ -112,7 +112,7 @@ Layer* LayerCache::get(RenderState& renderState, const uint32_t width, const uin } else { LAYER_LOGD("Creating new layer %dx%d", entry.mWidth, entry.mHeight); - layer = new Layer(renderState, entry.mWidth, entry.mHeight); + layer = new Layer(Layer::kType_DisplayList, renderState, entry.mWidth, entry.mHeight); layer->setBlend(true); layer->setEmpty(true); layer->setFbo(0); diff --git a/libs/hwui/LayerRenderer.cpp b/libs/hwui/LayerRenderer.cpp index e3b0daf..103c843 100644 --- a/libs/hwui/LayerRenderer.cpp +++ b/libs/hwui/LayerRenderer.cpp @@ -272,9 +272,8 @@ bool LayerRenderer::resizeLayer(Layer* layer, uint32_t width, uint32_t height) { Layer* LayerRenderer::createTextureLayer(RenderState& renderState) { LAYER_RENDERER_LOGD("Creating new texture layer"); - Layer* layer = new Layer(renderState, 0, 0); + Layer* layer = new Layer(Layer::kType_Texture, renderState, 0, 0); layer->setCacheable(false); - layer->setTextureLayer(true); layer->setEmpty(true); layer->setFbo(0); layer->setAlpha(255, SkXfermode::kSrcOver_Mode); diff --git a/libs/hwui/PathTessellator.cpp b/libs/hwui/PathTessellator.cpp index e30ac19..281ca02 100644 --- a/libs/hwui/PathTessellator.cpp +++ b/libs/hwui/PathTessellator.cpp @@ -162,14 +162,21 @@ public: } /** - * Outset the bounds of point data (for line endpoints or points) to account for AA stroke + * Outset the bounds of point data (for line endpoints or points) to account for stroke * geometry. + * + * bounds are in pre-scaled space. */ void expandBoundsForStroke(Rect* bounds) const { - float outset = halfStrokeWidth; - if (outset == 0) outset = 0.5f; - bounds->outset(outset * inverseScaleX + Vertex::GeometryFudgeFactor(), - outset * inverseScaleY + Vertex::GeometryFudgeFactor()); + if (halfStrokeWidth == 0) { + // hairline, outset by (0.5f + fudge factor) in post-scaling space + bounds->outset(fabs(inverseScaleX) * (0.5f + Vertex::GeometryFudgeFactor()), + fabs(inverseScaleY) * (0.5f + Vertex::GeometryFudgeFactor())); + } else { + // non hairline, outset by half stroke width pre-scaled, and fudge factor post scaled + bounds->outset(halfStrokeWidth + fabs(inverseScaleX) * Vertex::GeometryFudgeFactor(), + halfStrokeWidth + fabs(inverseScaleY) * Vertex::GeometryFudgeFactor()); + } } }; diff --git a/libs/hwui/RenderNode.cpp b/libs/hwui/RenderNode.cpp index a10e70f..254492f 100644 --- a/libs/hwui/RenderNode.cpp +++ b/libs/hwui/RenderNode.cpp @@ -872,6 +872,8 @@ void RenderNode::issueOperations(OpenGLRenderer& renderer, T& handler) { handler(new (alloc) DrawLayerOp(mLayer, 0, 0), renderer.getSaveCount() - 1, properties().getClipToBounds()); } else { + const int saveCountOffset = renderer.getSaveCount() - 1; + const int projectionReceiveIndex = mDisplayListData->projectionReceiveIndex; DisplayListLogBuffer& logBuffer = DisplayListLogBuffer::getInstance(); for (size_t chunkIndex = 0; chunkIndex < mDisplayListData->getChunks().size(); chunkIndex++) { const DisplayListData::Chunk& chunk = mDisplayListData->getChunks()[chunkIndex]; @@ -882,8 +884,6 @@ void RenderNode::issueOperations(OpenGLRenderer& renderer, T& handler) { issueOperationsOf3dChildren(kNegativeZChildren, initialTransform, zTranslatedNodes, renderer, handler); - const int saveCountOffset = renderer.getSaveCount() - 1; - const int projectionReceiveIndex = mDisplayListData->projectionReceiveIndex; for (int opIndex = chunk.beginOpIndex; opIndex < chunk.endOpIndex; opIndex++) { DisplayListOp *op = mDisplayListData->displayListOps[opIndex]; |