Example #1
0
        void _drawImageRect(Image image, uiRect?src, uiRect dst, uiPaint paint)
        {
            D.assert(image != null && image.valid);

            if (image == null || !image.valid)
            {
                return;
            }

            if (src == null)
            {
                src = uiRectHelper.one;
            }
            else
            {
                src = uiRectHelper.scale(src.Value, 1f / image.width, 1f / image.height);
            }

            var layer = this._currentLayer;
            var state = layer.currentState;
            var mesh  = ImageMeshGenerator.imageMesh(state.matrix, src.Value, dst);

            if (!this._applyClip(mesh.bounds))
            {
                ObjectPool <uiMeshMesh> .release(mesh);

                return;
            }

            layer.draws.Add(CanvasShader.tex(layer, paint, mesh, image));
        }
Example #2
0
        void _drawTextDrawMeshCallback(uiPaint p, uiMeshMesh fillMesh, uiMeshMesh strokeMesh, bool convex, float alpha,
                                       float strokeMult, Texture tex,
                                       uiRect textBlobBounds, TextBlobMesh textMesh, bool notEmoji)
        {
            if (!this._applyClip(textBlobBounds))
            {
                ObjectPool <TextBlobMesh> .release(textMesh);

                return;
            }

            var layer = this._currentLayer;

            if (notEmoji)
            {
                layer.draws.Add(CanvasShader.texAlpha(layer, p, textMesh, tex));
            }
            else
            {
                uiPaint paintWithWhite = new uiPaint(p);
                paintWithWhite.color = uiColor.white;
                if (EmojiUtils.image == null)
                {
                    ObjectPool <TextBlobMesh> .release(textMesh);

                    return;
                }

                var raw_mesh = textMesh.resolveMesh();
                var meshmesh = raw_mesh.duplicate();
                ObjectPool <TextBlobMesh> .release(textMesh);

                layer.draws.Add(CanvasShader.tex(layer, paintWithWhite, meshmesh, EmojiUtils.image));
            }
        }
Example #3
0
        void _drawImageNine(Image image, Rect src, Rect center, Rect dst, Paint paint)
        {
            D.assert(image != null);
            D.assert(center != null);
            D.assert(dst != null);
            D.assert(paint != null);

            var scaleX = 1f / image.width;
            var scaleY = 1f / image.height;

            if (src == null)
            {
                src = Rect.one;
            }
            else
            {
                src = src.scale(scaleX, scaleY);
            }

            center = center.scale(scaleX, scaleY);

            var layer = this._currentLayer;
            var state = layer.currentState;

            var mesh = ImageMeshGenerator.imageNineMesh(state.matrix, src, center, image.width, image.height, dst);

            if (!this._applyClip(mesh.bounds))
            {
                return;
            }

            layer.draws.Add(CanvasShader.tex(layer, paint, mesh, image));
        }
Example #4
0
        void _drawImageNine(Image image, uiRect?src, uiRect center, uiRect dst, uiPaint paint)
        {
            D.assert(image != null);

            var scaleX = 1f / image.width;
            var scaleY = 1f / image.height;

            if (src == null)
            {
                src = uiRectHelper.one;
            }
            else
            {
                src = uiRectHelper.scale(src.Value, scaleX, scaleY);
            }

            center = uiRectHelper.scale(center, scaleX, scaleY);

            var layer = this._currentLayer;
            var state = layer.currentState;

            var mesh = ImageMeshGenerator.imageNineMesh(state.matrix, src.Value, center, image.width, image.height,
                                                        dst);

            if (!this._applyClip(mesh.bounds))
            {
                ObjectPool <uiMeshMesh> .release(mesh);

                return;
            }

            layer.draws.Add(CanvasShader.tex(layer, paint, mesh, image));
        }
Example #5
0
        public void drawImageRect(Image image, Rect src, Rect dst, Paint paint)
        {
            D.assert(image != null);
            D.assert(dst != null);
            D.assert(paint != null);

            if (src == null)
            {
                src = Rect.one;
            }
            else
            {
                src = src.scale(1f / image.width, 1f / image.height);
            }

            var state = this._getState();
            var mesh  = ImageMeshGenerator.imageMesh(state.matrix, src, dst);

            if (!this._applyClip(mesh.bounds))
            {
                return;
            }

            var layer = this._getLayer();

            layer.draws.Add(CanvasShader.tex(layer, paint, mesh, image));
        }