提交 53d51077 编写于 作者: Z Zhouyj_zju 提交者: Zhouyj

fixed de9ca06a from https://gitee.com/Zhouyj_zju/graphic_ui/pulls/835

Description: add softEngineDraw
IssueNo: https://gitee.com/openharmony/graphic_ui/issues/I61ZAD
Feature or Bugfix: Bugfix
Binary Source:No
Signed-off-by: Nzhouyj <zhouyuanjie1@huawei.com>
上级 8a2cee5c
......@@ -185,6 +185,7 @@ lite_library("ui") {
"frameworks/draw/draw_utils.cpp",
"frameworks/engines/gfx/gfx_engine_manager.cpp",
"frameworks/engines/gfx/hi3516/hi3516_engine.cpp",
"frameworks/engines/gfx/soft_engine.cpp",
"frameworks/events/event.cpp",
"frameworks/font/base_font.cpp",
"frameworks/font/font_ram_allocator.cpp",
......
......@@ -15,135 +15,6 @@
#include "engines/gfx/gfx_engine_manager.h"
#include <cstdlib>
#include "draw/clip_utils.h"
#include "draw/draw_arc.h"
#include "draw/draw_canvas.h"
#include "draw/draw_curve.h"
#include "draw/draw_line.h"
#include "draw/draw_rect.h"
namespace OHOS {
BaseGfxEngine* BaseGfxEngine::baseEngine_ = nullptr;
void BaseGfxEngine::DrawArc(BufferInfo& dst,
ArcInfo& arcInfo,
const Rect& mask,
const Style& style,
OpacityType opacity,
uint8_t cap)
{
DrawArc::GetInstance()->Draw(dst, arcInfo, mask, style, opacity, cap);
}
void BaseGfxEngine::DrawLine(BufferInfo& dst,
const Point& start,
const Point& end,
const Rect& mask,
int16_t width,
ColorType color,
OpacityType opacity)
{
DrawLine::Draw(dst, start, end, mask, width, color, opacity);
}
void BaseGfxEngine::DrawLetter(BufferInfo& gfxDstBuffer,
const uint8_t* fontMap,
const Rect& fontRect,
const Rect& subRect,
const uint8_t fontWeight,
const ColorType& color,
const OpacityType opa)
{
DrawUtils::GetInstance()->DrawLetter(gfxDstBuffer, fontMap, fontRect, subRect, fontWeight, color, opa);
}
void BaseGfxEngine::DrawCubicBezier(BufferInfo& dst,
const Point& start,
const Point& control1,
const Point& control2,
const Point& end,
const Rect& mask,
int16_t width,
ColorType color,
OpacityType opacity)
{
DrawCurve::DrawCubicBezier(dst, start, control1, control2, end, mask, width, color, opacity);
}
void BaseGfxEngine::DrawRect(BufferInfo& dst,
const Rect& rect,
const Rect& dirtyRect,
const Style& style,
OpacityType opacity)
{
DrawRect::Draw(dst, rect, dirtyRect, style, opacity);
}
void BaseGfxEngine::DrawTransform(BufferInfo& dst,
const Rect& mask,
const Point& position,
ColorType color,
OpacityType opacity,
const TransformMap& transMap,
const TransformDataInfo& dataInfo)
{
DrawUtils::GetInstance()->DrawTransform(dst, mask, position, color,
opacity, transMap, dataInfo);
}
void BaseGfxEngine::ClipCircle(const ImageInfo* info, float x, float y, float radius)
{
ClipPath path;
path.Circle(PointF(x, y), radius);
ClipUtils clip;
clip.PerformScan(path, info);
}
void BaseGfxEngine::Blit(BufferInfo& dst,
const Point& dstPos,
const BufferInfo& src,
const Rect& subRect,
const BlendOption& blendOption)
{
DrawUtils::GetInstance()->BlendWithSoftWare(static_cast<uint8_t*>(src.virAddr), src.rect, src.stride,
src.rect.GetHeight(), src.mode, src.color, blendOption.opacity, static_cast<uint8_t*>(dst.virAddr),
dst.stride, dst.mode, subRect.GetX(), subRect.GetY());
}
void BaseGfxEngine::Fill(BufferInfo& dst, const Rect& fillArea, const ColorType color, const OpacityType opacity)
{
DrawUtils::GetInstance()->FillAreaWithSoftWare(dst, fillArea, color, opacity);
}
void BaseGfxEngine::DrawPath(BufferInfo& dst,
void* param,
const Paint& paint,
const Rect& rect,
const Rect& invalidatedArea,
const Style& style)
{
DrawCanvas::DoRender(dst, param, paint, rect, invalidatedArea, style, true);
}
void BaseGfxEngine::FillPath(BufferInfo& dst,
void* param,
const Paint& paint,
const Rect& rect,
const Rect& invalidatedArea,
const Style& style)
{
DrawCanvas::DoRender(dst, param, paint, rect, invalidatedArea, style, false);
}
uint8_t* BaseGfxEngine::AllocBuffer(uint32_t size, uint32_t usage)
{
return static_cast<uint8_t *>(malloc(size));
}
void BaseGfxEngine::FreeBuffer(uint8_t* buffer, uint32_t usage)
{
free(buffer);
}
}
......@@ -44,6 +44,6 @@ void Hi3516GfxEngine::Fill(BufferInfo& dst,
}
}
#endif
BaseGfxEngine::Fill(dst, fillArea, color, opacity);
SoftEngine::Fill(dst, fillArea, color, opacity);
}
}
......@@ -16,10 +16,10 @@
#ifndef GRAPHIC_LITE_HI3516_ENGINE_H
#define GRAPHIC_LITE_HI3516_ENGINE_H
#include "engines/gfx/gfx_engine_manager.h"
#include "engines/gfx/soft_engine.h"
namespace OHOS {
class Hi3516GfxEngine : public BaseGfxEngine {
class Hi3516GfxEngine : public SoftEngine {
public:
void Fill(BufferInfo& dst,
const Rect& fillArea,
......
/*
* Copyright (c) 2020-2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "engines/gfx/soft_engine.h"
#include <cstdlib>
#include "draw/clip_utils.h"
#include "draw/draw_arc.h"
#include "draw/draw_canvas.h"
#include "draw/draw_curve.h"
#include "draw/draw_line.h"
#include "draw/draw_rect.h"
namespace OHOS {
void SoftEngine::DrawArc(BufferInfo& dst,
ArcInfo& arcInfo,
const Rect& mask,
const Style& style,
OpacityType opacity,
uint8_t cap)
{
DrawArc::GetInstance()->Draw(dst, arcInfo, mask, style, opacity, cap);
}
void SoftEngine::DrawLine(BufferInfo& dst,
const Point& start,
const Point& end,
const Rect& mask,
int16_t width,
ColorType color,
OpacityType opacity)
{
DrawLine::Draw(dst, start, end, mask, width, color, opacity);
}
void SoftEngine::DrawLetter(BufferInfo& gfxDstBuffer,
const uint8_t* fontMap,
const Rect& fontRect,
const Rect& subRect,
const uint8_t fontWeight,
const ColorType& color,
const OpacityType opa)
{
DrawUtils::GetInstance()->DrawLetter(gfxDstBuffer, fontMap, fontRect, subRect, fontWeight, color, opa);
}
void SoftEngine::DrawCubicBezier(BufferInfo& dst,
const Point& start,
const Point& control1,
const Point& control2,
const Point& end,
const Rect& mask,
int16_t width,
ColorType color,
OpacityType opacity)
{
DrawCurve::DrawCubicBezier(dst, start, control1, control2, end, mask, width, color, opacity);
}
void SoftEngine::DrawRect(BufferInfo& dst,
const Rect& rect,
const Rect& dirtyRect,
const Style& style,
OpacityType opacity)
{
DrawRect::Draw(dst, rect, dirtyRect, style, opacity);
}
void SoftEngine::DrawTransform(BufferInfo& dst,
const Rect& mask,
const Point& position,
ColorType color,
OpacityType opacity,
const TransformMap& transMap,
const TransformDataInfo& dataInfo)
{
DrawUtils::GetInstance()->DrawTransform(dst, mask, position, color, opacity, transMap, dataInfo);
}
void SoftEngine::ClipCircle(const ImageInfo* info, float x, float y, float radius)
{
ClipPath path;
path.Circle(PointF(x, y), radius);
ClipUtils clip;
clip.PerformScan(path, info);
}
void SoftEngine::Blit(BufferInfo& dst,
const Point& dstPos,
const BufferInfo& src,
const Rect& subRect,
const BlendOption& blendOption)
{
DrawUtils::GetInstance()->BlendWithSoftWare(
static_cast<uint8_t*>(src.virAddr), src.rect, src.stride, src.rect.GetHeight(), src.mode, src.color,
blendOption.opacity, static_cast<uint8_t*>(dst.virAddr), dst.stride, dst.mode, subRect.GetX(), subRect.GetY());
}
void SoftEngine::Fill(BufferInfo& dst, const Rect& fillArea, const ColorType color, const OpacityType opacity)
{
DrawUtils::GetInstance()->FillAreaWithSoftWare(dst, fillArea, color, opacity);
}
void SoftEngine::DrawPath(BufferInfo& dst,
void* param,
const Paint& paint,
const Rect& rect,
const Rect& invalidatedArea,
const Style& style)
{
DrawCanvas::DoRender(dst, param, paint, rect, invalidatedArea, style, true);
}
void SoftEngine::FillPath(BufferInfo& dst,
void* param,
const Paint& paint,
const Rect& rect,
const Rect& invalidatedArea,
const Style& style)
{
DrawCanvas::DoRender(dst, param, paint, rect, invalidatedArea, style, false);
}
uint8_t* SoftEngine::AllocBuffer(uint32_t size, uint32_t usage)
{
return static_cast<uint8_t*>(malloc(size));
}
void SoftEngine::FreeBuffer(uint8_t* buffer, uint32_t usage)
{
free(buffer);
}
} // namespace OHOS
......@@ -16,12 +16,11 @@
#ifndef GRAPHIC_LITE_GFX_ENGINE_MANAGER_H
#define GRAPHIC_LITE_GFX_ENGINE_MANAGER_H
#include "gfx_utils/color.h"
#include "gfx_utils/diagram/common/paint.h"
#include "gfx_utils/geometry2d.h"
#include "gfx_utils/graphic_buffer.h"
#include "gfx_utils/graphic_math.h"
#include "gfx_utils/graphic_types.h"
#include "gfx_utils/heap_base.h"
#include "gfx_utils/image_info.h"
#include "gfx_utils/style.h"
#include "gfx_utils/transform.h"
......@@ -84,8 +83,8 @@ public:
const Rect& mask,
const Style& style,
OpacityType opacity,
uint8_t cap);
uint8_t cap) = 0;
virtual void MemoryBarrier() {}
virtual void DrawLine(BufferInfo& dst,
......@@ -94,7 +93,7 @@ public:
const Rect& mask,
int16_t width,
ColorType color,
OpacityType opacity);
OpacityType opacity) = 0;
virtual void DrawLetter(BufferInfo& gfxDstBuffer,
const uint8_t* fontMap,
......@@ -102,7 +101,7 @@ public:
const Rect& subRect,
const uint8_t fontWeight,
const ColorType& color,
const OpacityType opa);
const OpacityType opa) = 0;
virtual void DrawCubicBezier(BufferInfo& dst,
const Point& start,
......@@ -112,10 +111,10 @@ public:
const Rect& mask,
int16_t width,
ColorType color,
OpacityType opacity);
OpacityType opacity) = 0;
virtual void
DrawRect(BufferInfo& dst, const Rect& rect, const Rect& dirtyRect, const Style& style, OpacityType opacity);
DrawRect(BufferInfo& dst, const Rect& rect, const Rect& dirtyRect, const Style& style, OpacityType opacity) = 0;
virtual void DrawTransform(BufferInfo& dst,
const Rect& mask,
......@@ -123,36 +122,36 @@ public:
ColorType color,
OpacityType opacity,
const TransformMap& transMap,
const TransformDataInfo& dataInfo);
const TransformDataInfo& dataInfo) = 0;
// x/y: center of a circle
virtual void ClipCircle(const ImageInfo* info, float x, float y, float radius);
virtual void ClipCircle(const ImageInfo* info, float x, float y, float radius) = 0;
virtual void Blit(BufferInfo& dst,
const Point& dstPos,
const BufferInfo& src,
const Rect& subRect,
const BlendOption& blendOption);
const BlendOption& blendOption) = 0;
virtual void Fill(BufferInfo& dst, const Rect& fillArea, const ColorType color, const OpacityType opacity);
virtual void Fill(BufferInfo& dst, const Rect& fillArea, const ColorType color, const OpacityType opacity) = 0;
virtual void DrawPath(BufferInfo& dst,
void* param,
const Paint& paint,
const Rect& rect,
const Rect& invalidatedArea,
const Style& style);
const Style& style) = 0;
virtual void FillPath(BufferInfo& dst,
void* param,
const Paint& paint,
const Rect& rect,
const Rect& invalidatedArea,
const Style& style);
const Style& style) = 0;
virtual uint8_t* AllocBuffer(uint32_t size, uint32_t usage);
virtual uint8_t* AllocBuffer(uint32_t size, uint32_t usage) = 0;
virtual void FreeBuffer(uint8_t* buffer, uint32_t usage);
virtual void FreeBuffer(uint8_t* buffer, uint32_t usage) = 0;
virtual BufferInfo* GetFBBufferInfo()
{
......@@ -188,13 +187,8 @@ public:
return baseEngine_;
}
static void InitGfxEngine(BaseGfxEngine* gfxEngine = nullptr)
static void InitGfxEngine(BaseGfxEngine* gfxEngine)
{
if (gfxEngine == nullptr) {
static BaseGfxEngine localGfxEngine;
baseEngine_ = &localGfxEngine;
return;
}
baseEngine_ = gfxEngine;
}
......
/*
* Copyright (c) 2020-2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef GRAPHIC_LITE_SOFT_ENGINE_H
#define GRAPHIC_LITE_SOFT_ENGINE_H
#include "engines/gfx/gfx_engine_manager.h"
namespace OHOS {
class SoftEngine : public BaseGfxEngine {
public:
void DrawArc(BufferInfo& dst,
ArcInfo& arcInfo,
const Rect& mask,
const Style& style,
OpacityType opacity,
uint8_t cap) override;
void DrawLine(BufferInfo& dst,
const Point& start,
const Point& end,
const Rect& mask,
int16_t width,
ColorType color,
OpacityType opacity) override;
void DrawLetter(BufferInfo& gfxDstBuffer,
const uint8_t* fontMap,
const Rect& fontRect,
const Rect& subRect,
const uint8_t fontWeight,
const ColorType& color,
const OpacityType opa) override;
void DrawCubicBezier(BufferInfo& dst,
const Point& start,
const Point& control1,
const Point& control2,
const Point& end,
const Rect& mask,
int16_t width,
ColorType color,
OpacityType opacity) override;
void DrawRect(BufferInfo& dst,
const Rect& rect,
const Rect& dirtyRect,
const Style& style,
OpacityType opacity) override;
void DrawTransform(BufferInfo& dst,
const Rect& mask,
const Point& position,
ColorType color,
OpacityType opacity,
const TransformMap& transMap,
const TransformDataInfo& dataInfo) override;
// x/y: center of a circle
void ClipCircle(const ImageInfo* info, float x, float y, float radius) override;
void Blit(BufferInfo& dst,
const Point& dstPos,
const BufferInfo& src,
const Rect& subRect,
const BlendOption& blendOption) override;
void Fill(BufferInfo& dst, const Rect& fillArea, const ColorType color, const OpacityType opacity) override;
void DrawPath(BufferInfo& dst,
void* param,
const Paint& paint,
const Rect& rect,
const Rect& invalidatedArea,
const Style& style) override;
void FillPath(BufferInfo& dst,
void* param,
const Paint& paint,
const Rect& rect,
const Rect& invalidatedArea,
const Style& style) override;
uint8_t* AllocBuffer(uint32_t size, uint32_t usage) override;
void FreeBuffer(uint8_t* buffer, uint32_t usage) override;
};
} // namespace OHOS
#endif
......@@ -18,11 +18,11 @@
#include <QtCore/qobject.h>
#include "engines/gfx/gfx_engine_manager.h"
#include "engines/gfx/soft_engine.h"
#include "font/ui_font_header.h"
namespace OHOS {
class Monitor : public QObject, public BaseGfxEngine {
class Monitor : public QObject, public SoftEngine {
Q_OBJECT
public:
......
......@@ -125,6 +125,7 @@ SOURCES += \
../../../../frameworks/dock/vibrator_manager.cpp \
../../../../frameworks/dock/virtual_input_device.cpp \
../../../../frameworks/engines/gfx/gfx_engine_manager.cpp \
../../../../frameworks/engines/gfx/soft_engine.cpp \
../../../../frameworks/draw/clip_utils.cpp \
../../../../frameworks/draw/draw_arc.cpp \
../../../../frameworks/draw/draw_canvas.cpp \
......@@ -252,6 +253,7 @@ HEADERS += \
../../../../interfaces/innerkits/dock/vibrator_manager.h \
../../../../interfaces/innerkits/font/ui_font_builder.h \
../../../../interfaces/innerkits/engines/gfx/gfx_engine_manager.h \
../../../../interfaces/innerkits/engines/gfx/soft_engine.h \
../../../../interfaces/kits/animator/animator.h \
../../../../interfaces/kits/animator/easing_equation.h \
../../../../interfaces/kits/animator/interpolation.h \
......
......@@ -98,6 +98,7 @@ graphic_ui_sources = [
"$GRAPHIC_UI_PATH/frameworks/draw/draw_triangle.cpp",
"$GRAPHIC_UI_PATH/frameworks/draw/draw_utils.cpp",
"$GRAPHIC_UI_PATH/frameworks/engines/gfx/gfx_engine_manager.cpp",
"$GRAPHIC_UI_PATH/frameworks/engines/gfx/soft_engine.cpp",
"$GRAPHIC_UI_PATH/frameworks/events/event.cpp",
"$GRAPHIC_UI_PATH/frameworks/font/base_font.cpp",
"$GRAPHIC_UI_PATH/frameworks/font/font_ram_allocator.cpp",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册