Loading libs/hwui/Glop.h +15 −4 Original line number Diff line number Diff line Loading @@ -39,7 +39,6 @@ class RoundRectClipState; * are enabled/disabled dynamically based on mesh content. */ enum VertexAttribFlags { // NOTE: position attribute always enabled kNone_Attrib = 0, kTextureCoord_Attrib = 1 << 0, kColor_Attrib = 1 << 1, Loading @@ -61,9 +60,6 @@ enum VertexAttribFlags { */ // TODO: PREVENT_COPY_AND_ASSIGN(...) or similar struct Glop { Rect bounds; const RoundRectClipState* roundRectClipState; /* * Stores mesh - vertex and index data. * Loading @@ -85,8 +81,10 @@ struct Glop { struct Fill { Program* program; Texture* texture; GLenum textureFilter; GLenum textureClamp; bool colorEnabled; FloatColor color; Loading @@ -113,11 +111,24 @@ struct Glop { bool fudgingOffset; } transform; const RoundRectClipState* roundRectClipState; /** * Blending to be used by this draw - both GL_NONE if blending is disabled. * * Defined by fill step, but can be force-enabled by presence of kAlpha_Attrib */ struct Blend { GLenum src; GLenum dst; } blend; /** * Bounds of the drawing command in layer space. Only mapped into layer * space once GlopBuilder::build() is called. */ Rect bounds; /** * Additional render state to enumerate: * - scissor + (bits for whether each of LTRB needed?) Loading libs/hwui/GlopBuilder.cpp +24 −2 Original line number Diff line number Diff line Loading @@ -246,6 +246,7 @@ GlopBuilder& GlopBuilder::setFillTexturePaint(Texture& texture, bool isAlphaMask mOutGlop->fill.texture = &texture; mOutGlop->fill.textureFilter = PaintUtils::getFilter(paint); mOutGlop->fill.textureClamp = GL_CLAMP_TO_EDGE; if (paint) { int color = paint->getColor(); Loading Loading @@ -289,7 +290,8 @@ GlopBuilder& GlopBuilder::setFillPaint(const SkPaint& paint, float alphaScale) { REQUIRE_STAGES(kMeshStage); mOutGlop->fill.texture = nullptr; mOutGlop->fill.textureFilter = GL_NEAREST; mOutGlop->fill.textureFilter = GL_INVALID_ENUM; mOutGlop->fill.textureClamp = GL_INVALID_ENUM; setFill(paint.getColor(), alphaScale, PaintUtils::getXfermode(paint.getXfermode()), paint.getShader(), paint.getColorFilter()); Loading @@ -297,6 +299,27 @@ GlopBuilder& GlopBuilder::setFillPaint(const SkPaint& paint, float alphaScale) { return *this; } GlopBuilder& GlopBuilder::setFillPathTexturePaint(Texture& texture, const SkPaint& paint, float alphaScale) { TRIGGER_STAGE(kFillStage); REQUIRE_STAGES(kMeshStage); mOutGlop->fill.texture = &texture; //specify invalid, since these are always static for path textures mOutGlop->fill.textureFilter = GL_INVALID_ENUM; mOutGlop->fill.textureClamp = GL_INVALID_ENUM; setFill(paint.getColor(), alphaScale, PaintUtils::getXfermode(paint.getXfermode()), paint.getShader(), paint.getColorFilter()); mDescription.modulate = mOutGlop->fill.color.a < 1.0f || mOutGlop->fill.color.r > 0.0f || mOutGlop->fill.color.g > 0.0f || mOutGlop->fill.color.b > 0.0f; return *this; } //////////////////////////////////////////////////////////////////////////////// // Transform //////////////////////////////////////////////////////////////////////////////// Loading @@ -311,7 +334,6 @@ GlopBuilder& GlopBuilder::setTransformClip(const Matrix4& ortho, return *this; } //////////////////////////////////////////////////////////////////////////////// // ModelView //////////////////////////////////////////////////////////////////////////////// Loading libs/hwui/GlopBuilder.h +2 −0 Original line number Diff line number Diff line Loading @@ -45,6 +45,8 @@ public: GlopBuilder& setFillPaint(const SkPaint& paint, float alphaScale); GlopBuilder& setFillTexturePaint(Texture& texture, bool isAlphaMaskTexture, const SkPaint* paint, float alphaScale); GlopBuilder& setFillPathTexturePaint(Texture& texture, const SkPaint& paint, float alphaScale); GlopBuilder& setTransformClip(const Matrix4& ortho, const Matrix4& transform, bool fudgingOffset); Loading libs/hwui/OpenGLRenderer.cpp +22 −8 Original line number Diff line number Diff line Loading @@ -2505,7 +2505,7 @@ void OpenGLRenderer::drawColor(int color, SkXfermode::Mode mode) { mDirty = true; } void OpenGLRenderer::drawShape(float left, float top, const PathTexture* texture, void OpenGLRenderer::drawShape(float left, float top, PathTexture* texture, const SkPaint* paint) { if (!texture) return; const AutoTexture autoCleanup(texture); Loading @@ -2528,7 +2528,7 @@ void OpenGLRenderer::drawRoundRect(float left, float top, float right, float bot if (p->getPathEffect() != nullptr) { mCaches.textureState().activateTexture(0); const PathTexture* texture = mCaches.pathCache.getRoundRect( PathTexture* texture = mCaches.pathCache.getRoundRect( right - left, bottom - top, rx, ry, p); drawShape(left, top, texture, p); } else { Loading @@ -2546,7 +2546,7 @@ void OpenGLRenderer::drawCircle(float x, float y, float radius, const SkPaint* p } if (p->getPathEffect() != nullptr) { mCaches.textureState().activateTexture(0); const PathTexture* texture = mCaches.pathCache.getCircle(radius, p); PathTexture* texture = mCaches.pathCache.getCircle(radius, p); drawShape(x - radius, y - radius, texture, p); } else { SkPath path; Loading @@ -2569,7 +2569,7 @@ void OpenGLRenderer::drawOval(float left, float top, float right, float bottom, if (p->getPathEffect() != nullptr) { mCaches.textureState().activateTexture(0); const PathTexture* texture = mCaches.pathCache.getOval(right - left, bottom - top, p); PathTexture* texture = mCaches.pathCache.getOval(right - left, bottom - top, p); drawShape(left, top, texture, p); } else { SkPath path; Loading @@ -2593,7 +2593,7 @@ void OpenGLRenderer::drawArc(float left, float top, float right, float bottom, // TODO: support fills (accounting for concavity if useCenter && sweepAngle > 180) if (p->getStyle() != SkPaint::kStroke_Style || p->getPathEffect() != nullptr || useCenter) { mCaches.textureState().activateTexture(0); const PathTexture* texture = mCaches.pathCache.getArc(right - left, bottom - top, PathTexture* texture = mCaches.pathCache.getArc(right - left, bottom - top, startAngle, sweepAngle, useCenter, p); drawShape(left, top, texture, p); return; Loading Loading @@ -2630,7 +2630,7 @@ void OpenGLRenderer::drawRect(float left, float top, float right, float bottom, if (p->getPathEffect() != nullptr || p->getStrokeJoin() != SkPaint::kMiter_Join || p->getStrokeMiter() != SkPaintDefaults_MiterLimit) { mCaches.textureState().activateTexture(0); const PathTexture* texture = PathTexture* texture = mCaches.pathCache.getRect(right - left, bottom - top, p); drawShape(left, top, texture, p); } else { Loading Loading @@ -2974,7 +2974,7 @@ void OpenGLRenderer::drawPath(const SkPath* path, const SkPaint* paint) { mCaches.textureState().activateTexture(0); const PathTexture* texture = mCaches.pathCache.get(path, paint); PathTexture* texture = mCaches.pathCache.get(path, paint); if (!texture) return; const AutoTexture autoCleanup(texture); Loading Loading @@ -3107,12 +3107,26 @@ Texture* OpenGLRenderer::getTexture(const SkBitmap* bitmap) { return texture; } void OpenGLRenderer::drawPathTexture(const PathTexture* texture, void OpenGLRenderer::drawPathTexture(PathTexture* texture, float x, float y, const SkPaint* paint) { if (quickRejectSetupScissor(x, y, x + texture->width, y + texture->height)) { return; } if (USE_GLOPS && !paint->getShader()) { Glop glop; GlopBuilder aBuilder(mRenderState, mCaches, &glop); aBuilder.setMeshTexturedUnitQuad(nullptr, true) .setFillPathTexturePaint(*texture, *paint, currentSnapshot()->alpha) .setTransformClip(currentSnapshot()->getOrthoMatrix(), *currentTransform(), false) .setModelViewMapUnitToRect(Rect(x, y, x + texture->width, y + texture->height)) .setRoundRectClipState(currentSnapshot()->roundRectClipState) .build(); renderGlop(glop); return; } int alpha; SkXfermode::Mode mode; getAlphaAndMode(paint, &alpha, &mode); Loading libs/hwui/OpenGLRenderer.h +2 −2 Original line number Diff line number Diff line Loading @@ -690,7 +690,7 @@ private: * @param texture The texture reprsenting the shape * @param paint The paint to draw the shape with */ void drawShape(float left, float top, const PathTexture* texture, const SkPaint* paint); void drawShape(float left, float top, PathTexture* texture, const SkPaint* paint); /** * Draws the specified texture as an alpha bitmap. Alpha bitmaps obey Loading Loading @@ -819,7 +819,7 @@ private: * @param y The y coordinate where the texture will be drawn * @param paint The paint to draw the texture with */ void drawPathTexture(const PathTexture* texture, float x, float y, const SkPaint* paint); void drawPathTexture(PathTexture* texture, float x, float y, const SkPaint* paint); /** * Resets the texture coordinates stored in mMeshVertices. Setting the values Loading Loading
libs/hwui/Glop.h +15 −4 Original line number Diff line number Diff line Loading @@ -39,7 +39,6 @@ class RoundRectClipState; * are enabled/disabled dynamically based on mesh content. */ enum VertexAttribFlags { // NOTE: position attribute always enabled kNone_Attrib = 0, kTextureCoord_Attrib = 1 << 0, kColor_Attrib = 1 << 1, Loading @@ -61,9 +60,6 @@ enum VertexAttribFlags { */ // TODO: PREVENT_COPY_AND_ASSIGN(...) or similar struct Glop { Rect bounds; const RoundRectClipState* roundRectClipState; /* * Stores mesh - vertex and index data. * Loading @@ -85,8 +81,10 @@ struct Glop { struct Fill { Program* program; Texture* texture; GLenum textureFilter; GLenum textureClamp; bool colorEnabled; FloatColor color; Loading @@ -113,11 +111,24 @@ struct Glop { bool fudgingOffset; } transform; const RoundRectClipState* roundRectClipState; /** * Blending to be used by this draw - both GL_NONE if blending is disabled. * * Defined by fill step, but can be force-enabled by presence of kAlpha_Attrib */ struct Blend { GLenum src; GLenum dst; } blend; /** * Bounds of the drawing command in layer space. Only mapped into layer * space once GlopBuilder::build() is called. */ Rect bounds; /** * Additional render state to enumerate: * - scissor + (bits for whether each of LTRB needed?) Loading
libs/hwui/GlopBuilder.cpp +24 −2 Original line number Diff line number Diff line Loading @@ -246,6 +246,7 @@ GlopBuilder& GlopBuilder::setFillTexturePaint(Texture& texture, bool isAlphaMask mOutGlop->fill.texture = &texture; mOutGlop->fill.textureFilter = PaintUtils::getFilter(paint); mOutGlop->fill.textureClamp = GL_CLAMP_TO_EDGE; if (paint) { int color = paint->getColor(); Loading Loading @@ -289,7 +290,8 @@ GlopBuilder& GlopBuilder::setFillPaint(const SkPaint& paint, float alphaScale) { REQUIRE_STAGES(kMeshStage); mOutGlop->fill.texture = nullptr; mOutGlop->fill.textureFilter = GL_NEAREST; mOutGlop->fill.textureFilter = GL_INVALID_ENUM; mOutGlop->fill.textureClamp = GL_INVALID_ENUM; setFill(paint.getColor(), alphaScale, PaintUtils::getXfermode(paint.getXfermode()), paint.getShader(), paint.getColorFilter()); Loading @@ -297,6 +299,27 @@ GlopBuilder& GlopBuilder::setFillPaint(const SkPaint& paint, float alphaScale) { return *this; } GlopBuilder& GlopBuilder::setFillPathTexturePaint(Texture& texture, const SkPaint& paint, float alphaScale) { TRIGGER_STAGE(kFillStage); REQUIRE_STAGES(kMeshStage); mOutGlop->fill.texture = &texture; //specify invalid, since these are always static for path textures mOutGlop->fill.textureFilter = GL_INVALID_ENUM; mOutGlop->fill.textureClamp = GL_INVALID_ENUM; setFill(paint.getColor(), alphaScale, PaintUtils::getXfermode(paint.getXfermode()), paint.getShader(), paint.getColorFilter()); mDescription.modulate = mOutGlop->fill.color.a < 1.0f || mOutGlop->fill.color.r > 0.0f || mOutGlop->fill.color.g > 0.0f || mOutGlop->fill.color.b > 0.0f; return *this; } //////////////////////////////////////////////////////////////////////////////// // Transform //////////////////////////////////////////////////////////////////////////////// Loading @@ -311,7 +334,6 @@ GlopBuilder& GlopBuilder::setTransformClip(const Matrix4& ortho, return *this; } //////////////////////////////////////////////////////////////////////////////// // ModelView //////////////////////////////////////////////////////////////////////////////// Loading
libs/hwui/GlopBuilder.h +2 −0 Original line number Diff line number Diff line Loading @@ -45,6 +45,8 @@ public: GlopBuilder& setFillPaint(const SkPaint& paint, float alphaScale); GlopBuilder& setFillTexturePaint(Texture& texture, bool isAlphaMaskTexture, const SkPaint* paint, float alphaScale); GlopBuilder& setFillPathTexturePaint(Texture& texture, const SkPaint& paint, float alphaScale); GlopBuilder& setTransformClip(const Matrix4& ortho, const Matrix4& transform, bool fudgingOffset); Loading
libs/hwui/OpenGLRenderer.cpp +22 −8 Original line number Diff line number Diff line Loading @@ -2505,7 +2505,7 @@ void OpenGLRenderer::drawColor(int color, SkXfermode::Mode mode) { mDirty = true; } void OpenGLRenderer::drawShape(float left, float top, const PathTexture* texture, void OpenGLRenderer::drawShape(float left, float top, PathTexture* texture, const SkPaint* paint) { if (!texture) return; const AutoTexture autoCleanup(texture); Loading @@ -2528,7 +2528,7 @@ void OpenGLRenderer::drawRoundRect(float left, float top, float right, float bot if (p->getPathEffect() != nullptr) { mCaches.textureState().activateTexture(0); const PathTexture* texture = mCaches.pathCache.getRoundRect( PathTexture* texture = mCaches.pathCache.getRoundRect( right - left, bottom - top, rx, ry, p); drawShape(left, top, texture, p); } else { Loading @@ -2546,7 +2546,7 @@ void OpenGLRenderer::drawCircle(float x, float y, float radius, const SkPaint* p } if (p->getPathEffect() != nullptr) { mCaches.textureState().activateTexture(0); const PathTexture* texture = mCaches.pathCache.getCircle(radius, p); PathTexture* texture = mCaches.pathCache.getCircle(radius, p); drawShape(x - radius, y - radius, texture, p); } else { SkPath path; Loading @@ -2569,7 +2569,7 @@ void OpenGLRenderer::drawOval(float left, float top, float right, float bottom, if (p->getPathEffect() != nullptr) { mCaches.textureState().activateTexture(0); const PathTexture* texture = mCaches.pathCache.getOval(right - left, bottom - top, p); PathTexture* texture = mCaches.pathCache.getOval(right - left, bottom - top, p); drawShape(left, top, texture, p); } else { SkPath path; Loading @@ -2593,7 +2593,7 @@ void OpenGLRenderer::drawArc(float left, float top, float right, float bottom, // TODO: support fills (accounting for concavity if useCenter && sweepAngle > 180) if (p->getStyle() != SkPaint::kStroke_Style || p->getPathEffect() != nullptr || useCenter) { mCaches.textureState().activateTexture(0); const PathTexture* texture = mCaches.pathCache.getArc(right - left, bottom - top, PathTexture* texture = mCaches.pathCache.getArc(right - left, bottom - top, startAngle, sweepAngle, useCenter, p); drawShape(left, top, texture, p); return; Loading Loading @@ -2630,7 +2630,7 @@ void OpenGLRenderer::drawRect(float left, float top, float right, float bottom, if (p->getPathEffect() != nullptr || p->getStrokeJoin() != SkPaint::kMiter_Join || p->getStrokeMiter() != SkPaintDefaults_MiterLimit) { mCaches.textureState().activateTexture(0); const PathTexture* texture = PathTexture* texture = mCaches.pathCache.getRect(right - left, bottom - top, p); drawShape(left, top, texture, p); } else { Loading Loading @@ -2974,7 +2974,7 @@ void OpenGLRenderer::drawPath(const SkPath* path, const SkPaint* paint) { mCaches.textureState().activateTexture(0); const PathTexture* texture = mCaches.pathCache.get(path, paint); PathTexture* texture = mCaches.pathCache.get(path, paint); if (!texture) return; const AutoTexture autoCleanup(texture); Loading Loading @@ -3107,12 +3107,26 @@ Texture* OpenGLRenderer::getTexture(const SkBitmap* bitmap) { return texture; } void OpenGLRenderer::drawPathTexture(const PathTexture* texture, void OpenGLRenderer::drawPathTexture(PathTexture* texture, float x, float y, const SkPaint* paint) { if (quickRejectSetupScissor(x, y, x + texture->width, y + texture->height)) { return; } if (USE_GLOPS && !paint->getShader()) { Glop glop; GlopBuilder aBuilder(mRenderState, mCaches, &glop); aBuilder.setMeshTexturedUnitQuad(nullptr, true) .setFillPathTexturePaint(*texture, *paint, currentSnapshot()->alpha) .setTransformClip(currentSnapshot()->getOrthoMatrix(), *currentTransform(), false) .setModelViewMapUnitToRect(Rect(x, y, x + texture->width, y + texture->height)) .setRoundRectClipState(currentSnapshot()->roundRectClipState) .build(); renderGlop(glop); return; } int alpha; SkXfermode::Mode mode; getAlphaAndMode(paint, &alpha, &mode); Loading
libs/hwui/OpenGLRenderer.h +2 −2 Original line number Diff line number Diff line Loading @@ -690,7 +690,7 @@ private: * @param texture The texture reprsenting the shape * @param paint The paint to draw the shape with */ void drawShape(float left, float top, const PathTexture* texture, const SkPaint* paint); void drawShape(float left, float top, PathTexture* texture, const SkPaint* paint); /** * Draws the specified texture as an alpha bitmap. Alpha bitmaps obey Loading Loading @@ -819,7 +819,7 @@ private: * @param y The y coordinate where the texture will be drawn * @param paint The paint to draw the texture with */ void drawPathTexture(const PathTexture* texture, float x, float y, const SkPaint* paint); void drawPathTexture(PathTexture* texture, float x, float y, const SkPaint* paint); /** * Resets the texture coordinates stored in mMeshVertices. Setting the values Loading