1a3e0fd82Sopenharmony_ci/* 2a3e0fd82Sopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd. 3a3e0fd82Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4a3e0fd82Sopenharmony_ci * you may not use this file except in compliance with the License. 5a3e0fd82Sopenharmony_ci * You may obtain a copy of the License at 6a3e0fd82Sopenharmony_ci * 7a3e0fd82Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8a3e0fd82Sopenharmony_ci * 9a3e0fd82Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10a3e0fd82Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11a3e0fd82Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12a3e0fd82Sopenharmony_ci * See the License for the specific language governing permissions and 13a3e0fd82Sopenharmony_ci * limitations under the License. 14a3e0fd82Sopenharmony_ci */ 15a3e0fd82Sopenharmony_ci 16a3e0fd82Sopenharmony_ci/** 17a3e0fd82Sopenharmony_ci* @file render_scanline.h 18a3e0fd82Sopenharmony_ci* @brief Defines scanline renderer 19a3e0fd82Sopenharmony_ci* @since 1.0 20a3e0fd82Sopenharmony_ci* @version 1.0 21a3e0fd82Sopenharmony_ci*/ 22a3e0fd82Sopenharmony_ci 23a3e0fd82Sopenharmony_ci#ifndef GRAPHIC_LITE_RENDER_SCANLINE_H 24a3e0fd82Sopenharmony_ci#define GRAPHIC_LITE_RENDER_SCANLINE_H 25a3e0fd82Sopenharmony_ci 26a3e0fd82Sopenharmony_ci#include <cstdlib> 27a3e0fd82Sopenharmony_ci#include <cstring> 28a3e0fd82Sopenharmony_ci#include <limits> 29a3e0fd82Sopenharmony_ci#include "gfx_utils/color.h" 30a3e0fd82Sopenharmony_ci#include "gfx_utils/diagram/spancolorfill/fill_base.h" 31a3e0fd82Sopenharmony_ci#include "gfx_utils/diagram/scanline/geometry_scanline.h" 32a3e0fd82Sopenharmony_ci#include "gfx_utils/diagram/rasterizer/rasterizer_scanline_antialias.h" 33a3e0fd82Sopenharmony_ci#include "render/render_base.h" 34a3e0fd82Sopenharmony_ci 35a3e0fd82Sopenharmony_cinamespace OHOS { 36a3e0fd82Sopenharmony_ci/** 37a3e0fd82Sopenharmony_ci * @brief Anti aliasing scanline for rendering solid lines. 38a3e0fd82Sopenharmony_ci * Via scanline Begin gets the first span, and + + span gets the next span. 39a3e0fd82Sopenharmony_ci * The corresponding function is called by renbase to draw the color to the 40a3e0fd82Sopenharmony_ci * canvas where the corresponding span is located. 41a3e0fd82Sopenharmony_ci * @param raster grating 42a3e0fd82Sopenharmony_ci * @param scanline Scan line 43a3e0fd82Sopenharmony_ci * @param renBase Renderer 44a3e0fd82Sopenharmony_ci * @param color colour 45a3e0fd82Sopenharmony_ci */ 46a3e0fd82Sopenharmony_civoid RenderScanlinesAntiAliasSolid(RasterizerScanlineAntialias& raster, GeometryScanline& scanline, 47a3e0fd82Sopenharmony_ci RenderBase& renBase, const Rgba8T& color); 48a3e0fd82Sopenharmony_ci 49a3e0fd82Sopenharmony_ci/** 50a3e0fd82Sopenharmony_ci * @brief Rendering anti aliased scanlines. 51a3e0fd82Sopenharmony_ci * Via scanline Begin gets the first span, and + + span gets the next span. 52a3e0fd82Sopenharmony_ci * Via allocat_ - > Resize (spanlen) allocates a color_type with the same length as span. 53a3e0fd82Sopenharmony_ci * Through segment generator spangenerate_ - > Generate(colors, x, y, len); Fill the color 54a3e0fd82Sopenharmony_ci * array to get the color array with values corresponding to the scan line span. 55a3e0fd82Sopenharmony_ci * Finally, through renbase_ Call the corresponding function to draw the color array 56a3e0fd82Sopenharmony_ci * to the canvas position of the corresponding span. 57a3e0fd82Sopenharmony_ci * @param raster grating 58a3e0fd82Sopenharmony_ci * @param scanline Scan line 59a3e0fd82Sopenharmony_ci * @param renBase Renderer 60a3e0fd82Sopenharmony_ci * @param alloc distributor 61a3e0fd82Sopenharmony_ci * @param spanGen Segment generator 62a3e0fd82Sopenharmony_ci */ 63a3e0fd82Sopenharmony_civoid RenderScanlinesAntiAlias(RasterizerScanlineAntialias& raster, GeometryScanline& scanline, 64a3e0fd82Sopenharmony_ci RenderBase& renBase, FillBase& alloc, SpanBase& spanGen); 65a3e0fd82Sopenharmony_ci 66a3e0fd82Sopenharmony_civoid BlendScanLine(GlobalCompositeOperation op, RasterizerScanlineAntialias& raster1, 67a3e0fd82Sopenharmony_ci RasterizerScanlineAntialias& raster2, GeometryScanline& sl1, GeometryScanline& sl2, 68a3e0fd82Sopenharmony_ci RenderBase& renBase, FillBase& alloc, SpanBase& spanGen1, SpanBase& spanGen2); 69a3e0fd82Sopenharmony_ci 70a3e0fd82Sopenharmony_civoid CalcinterScanline(GeometryScanline& scanline3, int32_t x1, int32_t x2, 71a3e0fd82Sopenharmony_ci GeometryScanline::ConstIterator span1, GeometryScanline::ConstIterator span2); 72a3e0fd82Sopenharmony_ci 73a3e0fd82Sopenharmony_civoid CalcOutScanlineRight(GeometryScanline& scanline, int32_t x1, int32_t x2, 74a3e0fd82Sopenharmony_ci GeometryScanline::ConstIterator span1, GeometryScanline::ConstIterator span2); 75a3e0fd82Sopenharmony_ci 76a3e0fd82Sopenharmony_civoid CalcOutScanlineLeft(GeometryScanline& scanline, int32_t x1, int32_t x2, 77a3e0fd82Sopenharmony_ci GeometryScanline::ConstIterator span1, GeometryScanline::ConstIterator span2); 78a3e0fd82Sopenharmony_ci 79a3e0fd82Sopenharmony_civoid CalcOutScanlineAll(GeometryScanline& scanline, int32_t x1, int32_t x2, 80a3e0fd82Sopenharmony_ci GeometryScanline::ConstIterator span1, GeometryScanline::ConstIterator span2); 81a3e0fd82Sopenharmony_ci 82a3e0fd82Sopenharmony_civoid BlendSourceAtop(RasterizerScanlineAntialias& raster1, RasterizerScanlineAntialias& raster2, 83a3e0fd82Sopenharmony_ci GeometryScanline& scanline1, GeometryScanline& scanline2, RenderBase& renBase, 84a3e0fd82Sopenharmony_ci FillBase& alloc, SpanBase& spanGen1, SpanBase& spanGen2); 85a3e0fd82Sopenharmony_ci 86a3e0fd82Sopenharmony_ci 87a3e0fd82Sopenharmony_civoid BlendSourceIn(RasterizerScanlineAntialias& raster1, RasterizerScanlineAntialias& raster2, 88a3e0fd82Sopenharmony_ci GeometryScanline& scanline1, GeometryScanline& scanline2, RenderBase& renBase, 89a3e0fd82Sopenharmony_ci FillBase& alloc, SpanBase& spanGen1); 90a3e0fd82Sopenharmony_ci 91a3e0fd82Sopenharmony_civoid BlendSourceInLoop(RasterizerScanlineAntialias& raster1, GeometryScanline& scanline1, GeometryScanline& scanline2, 92a3e0fd82Sopenharmony_ci SpanBase& spanGen1, RenderBase& renBase, FillBase& alloc, int32_t& y1); 93a3e0fd82Sopenharmony_ci 94a3e0fd82Sopenharmony_civoid BlendSourceOut(RasterizerScanlineAntialias& raster1, RasterizerScanlineAntialias& raster2, 95a3e0fd82Sopenharmony_ci GeometryScanline& scanline1, GeometryScanline& scanline2, 96a3e0fd82Sopenharmony_ci RenderBase& renBase, FillBase& alloc, SpanBase& spanGen1); 97a3e0fd82Sopenharmony_ci 98a3e0fd82Sopenharmony_civoid BlendSourceOutWhile(int32_t y1, GeometryScanline& scanline1, RenderBase& renBase, 99a3e0fd82Sopenharmony_ci FillBase& alloc, SpanBase& spanGen1); 100a3e0fd82Sopenharmony_ci 101a3e0fd82Sopenharmony_civoid BlendSourceOutDrawResetRaster(RasterizerScanlineAntialias& raster1, GeometryScanline& scanline1, 102a3e0fd82Sopenharmony_ci RenderBase& renBase, FillBase& alloc, SpanBase& spanGen1); 103a3e0fd82Sopenharmony_ci 104a3e0fd82Sopenharmony_civoid BlendSourceOver(RasterizerScanlineAntialias& raster1, RasterizerScanlineAntialias& raster2, 105a3e0fd82Sopenharmony_ci GeometryScanline& scanline1, GeometryScanline& scanline2, 106a3e0fd82Sopenharmony_ci RenderBase& renBase, FillBase& alloc, SpanBase& spanGen1, SpanBase& spanGen2); 107a3e0fd82Sopenharmony_ci 108a3e0fd82Sopenharmony_ci 109a3e0fd82Sopenharmony_civoid BlendXOR(RasterizerScanlineAntialias& raster1, RasterizerScanlineAntialias& raster2, 110a3e0fd82Sopenharmony_ci GeometryScanline& scanline1, GeometryScanline& scanline2, 111a3e0fd82Sopenharmony_ci RenderBase& renBase, FillBase& alloc, SpanBase& spanGen1, SpanBase& spanGen2); 112a3e0fd82Sopenharmony_ci 113a3e0fd82Sopenharmony_civoid BlendXORDrawResetRaster(RasterizerScanlineAntialias& raster1, GeometryScanline& scanline1, 114a3e0fd82Sopenharmony_ci RenderBase& renBase, FillBase& alloc, SpanBase& spanGen1); 115a3e0fd82Sopenharmony_ci 116a3e0fd82Sopenharmony_civoid BlendXORColorHspan(int32_t& y1, RasterizerScanlineAntialias& raster1, RasterizerScanlineAntialias& raster2, 117a3e0fd82Sopenharmony_ci GeometryScanline& scanline1, RenderBase& renBase, FillBase& alloc, SpanBase& spanGen1); 118a3e0fd82Sopenharmony_ci 119a3e0fd82Sopenharmony_ci 120a3e0fd82Sopenharmony_civoid BlendLIGHTER(RasterizerScanlineAntialias& raster1, RasterizerScanlineAntialias& raster2, 121a3e0fd82Sopenharmony_ci GeometryScanline& scanline1, GeometryScanline& scanline2, 122a3e0fd82Sopenharmony_ci RenderBase& renBase, FillBase& alloc, SpanBase& spanGen1, SpanBase& spanGen2); 123a3e0fd82Sopenharmony_ci} // namespace OHOS 124a3e0fd82Sopenharmony_ci#endif 125