Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2a38c42e authored by sergeyv's avatar sergeyv
Browse files

Add target to texture

Test: refactoring cl.
bug:32413624

Change-Id: I94b1c31cd4e0712dfcfd7777a0012424c1bf0dca
parent 98fa4f9e
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -119,7 +119,6 @@ public:

        struct TextureData {
            Texture* texture;
            GLenum target;
            GLenum filter;
            GLenum clamp;
            Matrix4* textureTransform;
+13 −16
Original line number Diff line number Diff line
@@ -308,8 +308,7 @@ GlopBuilder& GlopBuilder::setFillTexturePaint(Texture& texture,

    GLenum filter = (textureFillFlags & TextureFillFlags::ForceFilter)
            ? GL_LINEAR : PaintUtils::getFilter(paint);
    mOutGlop->fill.texture = { &texture,
            GL_TEXTURE_2D, filter, GL_CLAMP_TO_EDGE, nullptr };
    mOutGlop->fill.texture = { &texture, filter, GL_CLAMP_TO_EDGE, nullptr };

    if (paint) {
        int color = paint->getColor();
@@ -352,10 +351,10 @@ GlopBuilder& GlopBuilder::setFillPaint(const SkPaint& paint, float alphaScale, b

    if (CC_LIKELY(!shadowInterp)) {
        mOutGlop->fill.texture = {
                nullptr, GL_INVALID_ENUM, GL_INVALID_ENUM, GL_INVALID_ENUM, nullptr };
                nullptr, GL_INVALID_ENUM, GL_INVALID_ENUM, nullptr };
    } else {
        mOutGlop->fill.texture = {
                mCaches.textureState().getShadowLutTexture(), GL_TEXTURE_2D,
                mCaches.textureState().getShadowLutTexture(),
                GL_INVALID_ENUM, GL_INVALID_ENUM, nullptr };
    }

@@ -373,7 +372,7 @@ GlopBuilder& GlopBuilder::setFillPathTexturePaint(PathTexture& texture,
    REQUIRE_STAGES(kMeshStage | kRoundRectClipStage);

    //specify invalid filter/clamp, since these are always static for PathTextures
    mOutGlop->fill.texture = { &texture, GL_TEXTURE_2D, GL_INVALID_ENUM, GL_INVALID_ENUM, nullptr };
    mOutGlop->fill.texture = { &texture, GL_INVALID_ENUM, GL_INVALID_ENUM, nullptr };

    setFill(paint.getColor(), alphaScale,
            paint.getBlendMode(), Blend::ModeOrderSwap::NoSwap,
@@ -390,7 +389,7 @@ GlopBuilder& GlopBuilder::setFillShadowTexturePaint(ShadowTexture& texture, int
    REQUIRE_STAGES(kMeshStage | kRoundRectClipStage);

    //specify invalid filter/clamp, since these are always static for ShadowTextures
    mOutGlop->fill.texture = { &texture, GL_TEXTURE_2D, GL_INVALID_ENUM, GL_INVALID_ENUM, nullptr };
    mOutGlop->fill.texture = { &texture, GL_INVALID_ENUM, GL_INVALID_ENUM, nullptr };

    const int ALPHA_BITMASK = SK_ColorBLACK;
    const int COLOR_BITMASK = ~ALPHA_BITMASK;
@@ -412,7 +411,7 @@ GlopBuilder& GlopBuilder::setFillBlack() {
    TRIGGER_STAGE(kFillStage);
    REQUIRE_STAGES(kMeshStage | kRoundRectClipStage);

    mOutGlop->fill.texture = { nullptr, GL_INVALID_ENUM, GL_INVALID_ENUM, GL_INVALID_ENUM, nullptr };
    mOutGlop->fill.texture = { nullptr, GL_INVALID_ENUM, GL_INVALID_ENUM, nullptr };
    setFill(SK_ColorBLACK, 1.0f, SkBlendMode::kSrcOver, Blend::ModeOrderSwap::NoSwap,
            nullptr, nullptr);
    return *this;
@@ -422,7 +421,7 @@ GlopBuilder& GlopBuilder::setFillClear() {
    TRIGGER_STAGE(kFillStage);
    REQUIRE_STAGES(kMeshStage | kRoundRectClipStage);

    mOutGlop->fill.texture = { nullptr, GL_INVALID_ENUM, GL_INVALID_ENUM, GL_INVALID_ENUM, nullptr };
    mOutGlop->fill.texture = { nullptr, GL_INVALID_ENUM, GL_INVALID_ENUM, nullptr };
    setFill(SK_ColorBLACK, 1.0f, SkBlendMode::kClear, Blend::ModeOrderSwap::NoSwap,
            nullptr, nullptr);
    return *this;
@@ -433,8 +432,7 @@ GlopBuilder& GlopBuilder::setFillLayer(Texture& texture, const SkColorFilter* co
    TRIGGER_STAGE(kFillStage);
    REQUIRE_STAGES(kMeshStage | kRoundRectClipStage);

    mOutGlop->fill.texture = { &texture,
            GL_TEXTURE_2D, GL_LINEAR, GL_CLAMP_TO_EDGE, nullptr };
    mOutGlop->fill.texture = { &texture, GL_LINEAR, GL_CLAMP_TO_EDGE, nullptr };

    setFill(SK_ColorWHITE, alpha, mode, modeUsage, nullptr, colorFilter);

@@ -447,7 +445,7 @@ GlopBuilder& GlopBuilder::setFillTextureLayer(Layer& layer, float alpha) {
    REQUIRE_STAGES(kMeshStage | kRoundRectClipStage);

    mOutGlop->fill.texture = { &(layer.getTexture()),
            layer.getRenderTarget(), GL_LINEAR, GL_CLAMP_TO_EDGE, &layer.getTexTransform() };
            GL_LINEAR, GL_CLAMP_TO_EDGE, &layer.getTexTransform() };

    setFill(SK_ColorWHITE, alpha, layer.getMode(), Blend::ModeOrderSwap::NoSwap,
            nullptr, layer.getColorFilter());
@@ -461,9 +459,7 @@ GlopBuilder& GlopBuilder::setFillExternalTexture(Texture& texture, Matrix4& text
    TRIGGER_STAGE(kFillStage);
    REQUIRE_STAGES(kMeshStage | kRoundRectClipStage);

    mOutGlop->fill.texture = { &texture,
            GL_TEXTURE_EXTERNAL_OES, GL_LINEAR, GL_CLAMP_TO_EDGE,
            &textureTransform };
    mOutGlop->fill.texture = { &texture, GL_LINEAR, GL_CLAMP_TO_EDGE, &textureTransform };

    setFill(SK_ColorWHITE, 1.0f, SkBlendMode::kSrc, Blend::ModeOrderSwap::NoSwap,
            nullptr, nullptr);
@@ -603,7 +599,7 @@ void verify(const ProgramDescription& description, const Glop& glop) {
void GlopBuilder::build() {
    REQUIRE_STAGES(kAllStages);
    if (mOutGlop->mesh.vertices.attribFlags & VertexAttribFlags::TextureCoord) {
        if (mOutGlop->fill.texture.target == GL_TEXTURE_2D) {
        if (mOutGlop->fill.texture.texture->target() == GL_TEXTURE_2D) {
            mDescription.hasTexture = true;
        } else {
            mDescription.hasExternalTexture = true;
@@ -668,7 +664,8 @@ void GlopBuilder::dump(const Glop& glop) {
    ALOGD("    program %p", fill.program);
    if (fill.texture.texture) {
        ALOGD("    texture %p, target %d, filter %d, clamp %d",
                fill.texture.texture, fill.texture.target, fill.texture.filter, fill.texture.clamp);
                fill.texture.texture, fill.texture.texture->target(),
                fill.texture.filter, fill.texture.clamp);
        if (fill.texture.textureTransform) {
            fill.texture.textureTransform->dump("texture transform");
        }
+2 −3
Original line number Diff line number Diff line
@@ -72,9 +72,8 @@ public:
    GlopBuilder& setFillLayer(Texture& texture, const SkColorFilter* colorFilter,
            float alpha, SkBlendMode mode, Blend::ModeOrderSwap modeUsage);
    GlopBuilder& setFillTextureLayer(Layer& layer, float alpha);
    // TODO: Texture should probably know and own its target.
    // setFillLayer() forces it to GL_TEXTURE which isn't always correct.
    // Similarly setFillLayer normally forces its own wrap & filter mode
    // TODO: setFillLayer normally forces its own wrap & filter mode,
    // which isn't always correct.
    GlopBuilder& setFillExternalTexture(Texture& texture, Matrix4& textureTransform);

    GlopBuilder& setTransform(const Matrix4& canvas, const int transformFlags);
+1 −2
Original line number Diff line number Diff line
@@ -41,7 +41,6 @@ Layer::Layer(RenderState& renderState, uint32_t layerWidth, uint32_t layerHeight
    // TODO: This is a violation of Android's typical ref counting, but it
    // preserves the old inc/dec ref locations. This should be changed...
    incStrong(nullptr);
    renderTarget = GL_NONE;  // see DeferredLayerUpdater::updateLayer()
    texture.mWidth = layerWidth;
    texture.mHeight = layerHeight;
    renderState.registerLayer(this);
@@ -66,7 +65,7 @@ void Layer::setColorFilter(SkColorFilter* filter) {

void Layer::bindTexture() const {
    if (texture.mId) {
        caches.textureState().bindTexture(renderTarget, texture.mId);
        caches.textureState().bindTexture(texture.target(), texture.mId);
    }
}

+7 −11
Original line number Diff line number Diff line
@@ -75,7 +75,8 @@ public:
    }

    void setSize(uint32_t width, uint32_t height) {
        texture.updateSize(width, height, texture.internalFormat(), texture.format());
        texture.updateSize(width, height, texture.internalFormat(), texture.format(),
                texture.target());
    }

    inline void setBlend(bool blend) {
@@ -120,23 +121,23 @@ public:
    }

    inline GLenum getRenderTarget() const {
        return renderTarget;
        return texture.target();
    }

    inline void setRenderTarget(GLenum renderTarget) {
        this->renderTarget = renderTarget;
        texture.mTarget = renderTarget;
    }

    inline bool isRenderable() const {
        return renderTarget != GL_NONE;
        return texture.target() != GL_NONE;
    }

    void setWrap(GLenum wrap, bool bindTexture = false, bool force = false) {
        texture.setWrap(wrap, bindTexture, force, renderTarget);
        texture.setWrap(wrap, bindTexture, force);
    }

    void setFilter(GLenum filter, bool bindTexture = false, bool force = false) {
        texture.setFilter(filter, bindTexture, force, renderTarget);
        texture.setFilter(filter, bindTexture, force);
    }

    inline SkColorFilter* getColorFilter() const {
@@ -185,11 +186,6 @@ private:
     */
    Texture texture;

    /**
     * Indicates the render target.
     */
    GLenum renderTarget = GL_TEXTURE_2D;

    /**
     * Color filter used to draw this layer. Optional.
     */
Loading