提交 b4cac638 编写于 作者: X xucheng57@huawei.com

修复gfx_engine_manager

Signed-off-by: Nxucheng57 <xucheng57@huawei.com>
上级 9f168851
/*
* Copyright (c) 2020-2022 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.
*/
* 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/gfx_engine_manager.h"
#include <cstdlib>
#include "draw/clip_utils.h"
#include "draw/draw_arc.h"
#include "draw/draw_curve.h"
......@@ -85,7 +88,7 @@ void BaseGfxEngine::DrawTransform(BufferInfo& dst,
const TransformDataInfo& dataInfo)
{
DrawUtils::GetInstance()->DrawTransform(dst, mask, position, color,
opacity, transMap, dataInfo);
opacity, transMap, dataInfo);
}
void BaseGfxEngine::ClipCircle(const ImageInfo* info, float x, float y, float radius)
......@@ -103,9 +106,8 @@ void BaseGfxEngine::Blit(BufferInfo& dst,
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());
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)
......@@ -115,11 +117,11 @@ void BaseGfxEngine::Fill(BufferInfo& dst, const Rect& fillArea, const ColorType
uint8_t* BaseGfxEngine::AllocBuffer(uint32_t size, uint32_t usage)
{
return static_cast<uint8_t*>(malloc(size));
return static_cast<uint8_t *>(malloc(size));
}
void BaseGfxEngine::FreeBuffer(uint8_t* buffer)
{
free(buffer);
}
} // namespace OHOS
}
/*
* Copyright (c) 2020-2022 Huawei Device Co., Ltd.
* 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
......@@ -23,60 +23,23 @@
#include "gfx_utils/heap_base.h"
#include "gfx_utils/style.h"
#include "gfx_utils/transform.h"
namespace OHOS {
class GfxEngineManager;
namespace OHOS {
class BaseGfxEngine;
enum BlendMode {
/** No mixing */
BLEND_MODE = -1,
/** S */
BLEND_SRC,
/** D */
BLEND_DST,
/** Default. Displays the source image on the target image. */
/** S + (1 - Sa) * D */
BLEND_SRC_OVER,
/** Displays the target image on the source image. */
/** (1 - Da) * S + D */
BLEND_DST_OVER,
/** Displays the source image in the target image. Only the source image part within the target image
* will be displayed, and the target image is transparent. */
/** Da * S */
BLEND_SRC_IN,
/** Displays the target image in the source image. Only the target image part within the source image
* will be displayed, and the source image is transparent. */
/** Sa * D */
BLEND_DST_IN,
/** Displays the source image outside the target image. Only the source image part other than the target
* image will be displayed, and the target image is transparent. */
/** S * (1 - Da) */
BLEND_SRC_OUT,
/** Displays the target image outside the source image. Only the part of the target image other than the
* source image will be displayed, and the source image is transparent. */
/** D * (1 - Sa) */
BLEND_DST_OUT,
/** Displays the source image at the top of the target image. The part of the source image outside the
* target image is invisible. */
BLEND_SRC_ATOP,
/** Displays the target image at the top of the source image. The part of the target image outside the
* source image is invisible. */
BLEND_DST_ATOP,
/** Use the XOR operation to combine the source image with the target image. */
BLEND_XOR,
/** Display source image + target image. */
BLEND_LIGHTEN,
/** Blend transparency */
BLEND_ALPHA,
/** S + D - S * D */
BLEND_SCREEN,
/** S * (1 - Da) + D * (1 - Sa) + S * D */
BLEND_MULTIPLY,
/** S + D */
BLEND_ADDITIVE,
/** D * (1 - S) */
BLEND_SUBTRACT,
/** Displays the source image. Ignore the target image. */
BLEND_COPY = 1000
BLEND_MODE, /* no blending */
BLEND_SRC, /* S */
BLEND_DST, /* D */
BLEND_SRC_OVER, /* S + (1 - Sa) * D */
BLEND_DST_OVER, /* (1 - Da) * S + D */
BLEND_SRC_IN, /* Da * S */
BLEND_DST_IN, /* Sa * D */
BLEND_SRC_OUT, /* S * (1 - Da) */
BLEND_DST_OUT, /* D * (1 - Sa) */
BLEND_SCREEN, /* S + D - S * D */
BLEND_MULTIPLY, /* S * (1 - Da) + D * (1 - Sa) + S * D */
BLEND_ADDITIVE, /* S + D */
BLEND_SUBTRACT, /* D * (1 - S) */
};
#ifndef TRANSFORMOPTION
......@@ -117,7 +80,7 @@ enum BufferInfoUsage {
BUFFER_SNAPSHOT_SURFACE
};
class GfxEngineManager : public HeapBase {
class BaseGfxEngine : public HeapBase {
public:
virtual void DrawArc(BufferInfo& dst, ArcInfo& arcInfo, const Rect& mask,
const Style& style, OpacityType opacity, uint8_t cap);
......@@ -169,8 +132,6 @@ public:
virtual void FreeBuffer(uint8_t* buffer);
virtual void FlushRegion(const Rect& rect, const uint8_t* buffer, ColorMode mode) {}
virtual BufferInfo* GetFBBufferInfo()
{
return nullptr;
......@@ -198,28 +159,26 @@ public:
return screenShape_;
}
static GfxEngineManager* GetInstance()
static BaseGfxEngine* GetInstance()
{
return baseEngine_;
}
static void InitGfxEngine(GfxEngineManager* gfxEngine = nullptr)
static void InitGfxEngine(BaseGfxEngine* gfxEngine = nullptr)
{
if (gfxEngine == nullptr) {
static GfxEngineManager localGfxEngine;
static BaseGfxEngine localGfxEngine;
baseEngine_ = &localGfxEngine;
return;
}
baseEngine_ = gfxEngine;
}
protected:
static GfxEngineManager* baseEngine_;
static BaseGfxEngine* baseEngine_;
uint16_t width_ = HORIZONTAL_RESOLUTION;
uint16_t height_ = VERTICAL_RESOLUTION;
ScreenShape screenShape_ = RECTANGLE;
};
using BaseGfxEngine = GfxEngineManager;
} // namespace OHOS
}
#endif // GRAPHIC_LITE_GFX_ENGINE_MANAGER_H
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册