mirror of
https://gitee.com/openharmony/graphic_graphic_2d
synced 2025-01-05 14:20:05 +00:00
lib2d_graphic csec
Signed-off-by: zhangjie345@huawei.com <zhangjie345@huawei.com> Change-Id: Ie27386e0b017f60f58433ee6f55d2b2d56a9e5b6
This commit is contained in:
parent
8573d2134c
commit
9df1a35604
rosen/modules/2d_graphics
@ -35,12 +35,12 @@ public:
|
||||
int GetHeight();
|
||||
void* GetPixels();
|
||||
void SetPixels(void* pixel);
|
||||
void CopyPixels(Bitmap& dst, int srcLeft, int srcTop, int width, int height);
|
||||
void ClearWithColor(const ColorQuad& color);
|
||||
bool IsValid();
|
||||
ColorQuad GetColor(int x, int y);
|
||||
void CopyPixels(Bitmap& dst, int srcLeft, int srcTop, int width, int height) const;
|
||||
void ClearWithColor(const ColorQuad& color) const;
|
||||
bool IsValid() const;
|
||||
ColorQuad GetColor(int x, int y) const;
|
||||
void Free();
|
||||
BitmapFormat GetFormat();
|
||||
BitmapFormat GetFormat() const;
|
||||
template<typename T>
|
||||
const std::shared_ptr<T> GetImpl() const
|
||||
{
|
||||
|
@ -35,7 +35,7 @@ public:
|
||||
bool operator==(const Matrix& other);
|
||||
void SetMatrix(scalar scaleX, scalar skewX, scalar transX, scalar skewY, scalar scaleY, scalar transY,
|
||||
scalar persp0, scalar persp1, scalar persp2);
|
||||
scalar Get(int index);
|
||||
scalar Get(int index) const;
|
||||
template<typename T>
|
||||
const std::shared_ptr<T> GetImpl() const
|
||||
{
|
||||
|
@ -20,7 +20,6 @@
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
namespace Drawing {
|
||||
|
||||
using EngineImplFactory = SkiaImplFactory;
|
||||
|
||||
std::unique_ptr<CoreCanvasImpl> ImplFactory::CreateCoreCanvasImpl()
|
||||
|
@ -39,11 +39,11 @@ public:
|
||||
virtual int GetHeight() = 0;
|
||||
virtual void* GetPixels() = 0;
|
||||
virtual void SetPixels(void* pixel) = 0;
|
||||
virtual void CopyPixels(Bitmap& dst, int srcLeft, int srcTop, int width, int height) = 0;
|
||||
virtual void ClearWithColor(const ColorQuad& color) = 0;
|
||||
virtual ColorQuad GetColor(int x, int y) = 0;
|
||||
virtual void CopyPixels(Bitmap& dst, int srcLeft, int srcTop, int width, int height) const = 0;
|
||||
virtual void ClearWithColor(const ColorQuad& color) const = 0;
|
||||
virtual ColorQuad GetColor(int x, int y) const = 0;
|
||||
virtual void Free() = 0;
|
||||
virtual bool IsValid() = 0;
|
||||
virtual bool IsValid() const = 0;
|
||||
};
|
||||
} // namespace Drawing
|
||||
} // namespace Rosen
|
||||
|
@ -37,7 +37,7 @@ public:
|
||||
}
|
||||
|
||||
virtual void InitWithBlendMode(ColorQuad c, BlendMode mode) = 0;
|
||||
virtual void InitWithColorMatrix(ColorMatrix& m) = 0;
|
||||
virtual void InitWithColorMatrix(const ColorMatrix& m) = 0;
|
||||
virtual void InitWithLinearToSrgbGamma() = 0;
|
||||
virtual void InitWithSrgbGammaToLinear() = 0;
|
||||
virtual void InitWithCompose(const ColorFilter& f1, const ColorFilter& f2) = 0;
|
||||
|
@ -38,10 +38,10 @@ public:
|
||||
virtual void Translate(scalar dx, scalar dy) = 0;
|
||||
virtual void Scale(scalar sx, scalar sy, scalar px, scalar py) = 0;
|
||||
virtual void Multiply(const Matrix& a, const Matrix& b) = 0;
|
||||
virtual bool Equals(const Matrix& a, const Matrix& b) = 0;
|
||||
virtual bool Equals(const Matrix& a, const Matrix& b) const = 0;
|
||||
virtual void SetMatrix(scalar scaleX, scalar skewX, scalar transX, scalar skewY, scalar scaleY, scalar transY,
|
||||
scalar persp0, scalar persp1, scalar persp2) = 0;
|
||||
virtual scalar Get(int index) = 0;
|
||||
virtual scalar Get(int index) const = 0;
|
||||
};
|
||||
} // namespace Drawing
|
||||
} // namespace Rosen
|
||||
|
@ -99,7 +99,7 @@ const SkBitmap& SkiaBitmap::ExportSkiaBitmap() const
|
||||
return skiaBitmap_;
|
||||
}
|
||||
|
||||
void SkiaBitmap::CopyPixels(Bitmap& dst, int srcLeft, int srcTop, int width, int height)
|
||||
void SkiaBitmap::CopyPixels(Bitmap& dst, int srcLeft, int srcTop, int width, int height) const
|
||||
{
|
||||
int w = dst.GetWidth();
|
||||
int h = dst.GetHeight();
|
||||
@ -114,13 +114,13 @@ void SkiaBitmap::CopyPixels(Bitmap& dst, int srcLeft, int srcTop, int width, int
|
||||
skiaBitmap_.readPixels(imageInfo, dstPixels, dstRowBytes, srcX, srcY);
|
||||
}
|
||||
|
||||
void SkiaBitmap::ClearWithColor(const ColorQuad& color)
|
||||
void SkiaBitmap::ClearWithColor(const ColorQuad& color) const
|
||||
{
|
||||
SkColor skColor = static_cast<SkColor>(color);
|
||||
skiaBitmap_.eraseColor(skColor);
|
||||
}
|
||||
|
||||
ColorQuad SkiaBitmap::GetColor(int x, int y)
|
||||
ColorQuad SkiaBitmap::GetColor(int x, int y) const
|
||||
{
|
||||
SkColor color;
|
||||
color = skiaBitmap_.getColor(x, y);
|
||||
@ -132,7 +132,7 @@ void SkiaBitmap::Free()
|
||||
skiaBitmap_.reset();
|
||||
}
|
||||
|
||||
bool SkiaBitmap::IsValid()
|
||||
bool SkiaBitmap::IsValid() const
|
||||
{
|
||||
return skiaBitmap_.drawsNothing();
|
||||
}
|
||||
|
@ -39,11 +39,11 @@ public:
|
||||
void* GetPixels() override;
|
||||
void SetPixels(void* pixels) override;
|
||||
const SkBitmap& ExportSkiaBitmap() const;
|
||||
void CopyPixels(Bitmap& dst, int srcLeft, int srcTop, int width, int height) override;
|
||||
void ClearWithColor(const ColorQuad& color) override;
|
||||
ColorQuad GetColor(int x, int y) override;
|
||||
void CopyPixels(Bitmap& dst, int srcLeft, int srcTop, int width, int height) const override;
|
||||
void ClearWithColor(const ColorQuad& color) const override;
|
||||
ColorQuad GetColor(int x, int y) const override;
|
||||
void Free() override;
|
||||
bool IsValid() override;
|
||||
bool IsValid() const override;
|
||||
|
||||
private:
|
||||
SkBitmap skiaBitmap_;
|
||||
|
@ -442,7 +442,7 @@ void SkiaCanvas::DetachBrush()
|
||||
skiaPaint_.DisableFill();
|
||||
}
|
||||
|
||||
void SkiaCanvas::RoundRectCastToSkRRect(const RoundRect& roundRect, SkRRect& skRRect)
|
||||
void SkiaCanvas::RoundRectCastToSkRRect(const RoundRect& roundRect, SkRRect& skRRect) const
|
||||
{
|
||||
Rect rect = roundRect.GetRect();
|
||||
SkRect outer = SkRect::MakeLTRB(rect.GetLeft(), rect.GetTop(), rect.GetRight(), rect.GetBottom());
|
||||
|
@ -103,7 +103,7 @@ public:
|
||||
const std::shared_ptr<SkCanvas> ExportSkiaCanvas() const;
|
||||
|
||||
private:
|
||||
void RoundRectCastToSkRRect(const RoundRect& roundRect, SkRRect& skRRect);
|
||||
void RoundRectCastToSkRRect(const RoundRect& roundRect, SkRRect& skRRect) const;
|
||||
std::shared_ptr<SkCanvas> skiaCanvas_;
|
||||
SkiaPaint skiaPaint_;
|
||||
};
|
||||
|
@ -27,7 +27,7 @@ void SkiaColorFilter::InitWithBlendMode(ColorQuad c, BlendMode mode)
|
||||
filter_ = SkColorFilters::Blend(static_cast<SkColor>(c), static_cast<SkBlendMode>(mode));
|
||||
}
|
||||
|
||||
void SkiaColorFilter::InitWithColorMatrix(ColorMatrix& m)
|
||||
void SkiaColorFilter::InitWithColorMatrix(const ColorMatrix& m)
|
||||
{
|
||||
scalar dst[20];
|
||||
m.GetArray(dst);
|
||||
|
@ -34,7 +34,7 @@ public:
|
||||
}
|
||||
|
||||
void InitWithBlendMode(ColorQuad c, BlendMode mode) override;
|
||||
void InitWithColorMatrix(ColorMatrix& m) override;
|
||||
void InitWithColorMatrix(const ColorMatrix& m) override;
|
||||
void InitWithLinearToSrgbGamma() override;
|
||||
void InitWithSrgbGammaToLinear() override;
|
||||
void InitWithCompose(const ColorFilter& f1, const ColorFilter& f2) override;
|
||||
|
@ -22,7 +22,7 @@
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
namespace Drawing {
|
||||
SkiaColorSpace::SkiaColorSpace() noexcept : colorSpace_() {}
|
||||
SkiaColorSpace::SkiaColorSpace() noexcept : colorSpace_(nullptr) {}
|
||||
|
||||
void SkiaColorSpace::InitWithSRGB()
|
||||
{
|
||||
|
@ -51,7 +51,7 @@ void SkiaMatrix::Multiply(const Matrix& a, const Matrix& b)
|
||||
}
|
||||
}
|
||||
|
||||
bool SkiaMatrix::Equals(const Matrix& a, const Matrix& b)
|
||||
bool SkiaMatrix::Equals(const Matrix& a, const Matrix& b) const
|
||||
{
|
||||
auto m1 = a.GetImpl<SkiaMatrix>();
|
||||
auto m2 = b.GetImpl<SkiaMatrix>();
|
||||
@ -67,7 +67,7 @@ void SkiaMatrix::SetMatrix(scalar scaleX, scalar skewX, scalar transX, scalar sk
|
||||
skMatrix_.setAll(scaleX, skewX, transX, skewY, scaleY, transY, persp0, persp1, persp2);
|
||||
}
|
||||
|
||||
scalar SkiaMatrix::Get(int index)
|
||||
scalar SkiaMatrix::Get(int index) const
|
||||
{
|
||||
return skMatrix_.get(index);
|
||||
}
|
||||
|
@ -40,10 +40,10 @@ public:
|
||||
void Scale(scalar sx, scalar sy, scalar px, scalar py) override;
|
||||
const SkMatrix& ExportSkiaMatrix() const;
|
||||
void Multiply(const Matrix& a, const Matrix& b) override;
|
||||
bool Equals(const Matrix& a, const Matrix& b) override;
|
||||
bool Equals(const Matrix& a, const Matrix& b) const override;
|
||||
void SetMatrix(scalar scaleX, scalar skewX, scalar transX, scalar skewY, scalar scaleY, scalar transY,
|
||||
scalar persp0, scalar persp1, scalar persp2) override;
|
||||
scalar Get(int index) override;
|
||||
scalar Get(int index) const override;
|
||||
|
||||
private:
|
||||
SkMatrix skMatrix_;
|
||||
|
@ -44,7 +44,7 @@ void SkiaPaint::ApplyPenToStroke(const Pen& pen)
|
||||
PenToSkPaint(pen, stroke_->paint);
|
||||
}
|
||||
|
||||
void SkiaPaint::BrushToSkPaint(const Brush& brush, SkPaint& paint)
|
||||
void SkiaPaint::BrushToSkPaint(const Brush& brush, SkPaint& paint) const
|
||||
{
|
||||
paint.setColor(brush.GetColor().CastToColorQuad());
|
||||
|
||||
@ -72,7 +72,7 @@ void SkiaPaint::BrushToSkPaint(const Brush& brush, SkPaint& paint)
|
||||
paint.setStyle(SkPaint::kFill_Style);
|
||||
}
|
||||
|
||||
void SkiaPaint::PenToSkPaint(const Pen& pen, SkPaint& paint)
|
||||
void SkiaPaint::PenToSkPaint(const Pen& pen, SkPaint& paint) const
|
||||
{
|
||||
paint.setColor(pen.GetColor().CastToColorQuad());
|
||||
|
||||
@ -149,7 +149,7 @@ void SkiaPaint::DisableFill()
|
||||
fill_->isEnabled = false;
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<PaintData>> SkiaPaint::GetSortedPaints()
|
||||
std::vector<std::shared_ptr<PaintData>> SkiaPaint::GetSortedPaints() const
|
||||
{
|
||||
std::vector<std::shared_ptr<PaintData>> paints;
|
||||
if (IsStrokeFirst() && stroke_->isEnabled && fill_->isEnabled) {
|
||||
@ -172,12 +172,12 @@ void SkiaPaint::SetStrokeFirst(bool isStrokeFirst)
|
||||
isStrokeFirst_ = isStrokeFirst;
|
||||
}
|
||||
|
||||
bool SkiaPaint::IsStrokeFirst()
|
||||
bool SkiaPaint::IsStrokeFirst() const
|
||||
{
|
||||
return isStrokeFirst_;
|
||||
}
|
||||
|
||||
void SkiaPaint::ApplyFilter(SkPaint& paint, const Filter& filter)
|
||||
void SkiaPaint::ApplyFilter(SkPaint& paint, const Filter& filter) const
|
||||
{
|
||||
#if !defined(USE_CANVASKIT0310_SKIA)
|
||||
switch (filter.GetFilterQuality()) {
|
||||
|
@ -40,18 +40,18 @@ public:
|
||||
void ApplyBrushToFill(const Brush& brush);
|
||||
void ApplyPenToStroke(const Pen& pen);
|
||||
|
||||
void BrushToSkPaint(const Brush& brush, SkPaint& paint);
|
||||
void PenToSkPaint(const Pen& pen, SkPaint& paint);
|
||||
void BrushToSkPaint(const Brush& brush, SkPaint& paint) const;
|
||||
void PenToSkPaint(const Pen& pen, SkPaint& paint) const;
|
||||
|
||||
void DisableStroke();
|
||||
void DisableFill();
|
||||
|
||||
std::vector<std::shared_ptr<PaintData>> GetSortedPaints();
|
||||
std::vector<std::shared_ptr<PaintData>> GetSortedPaints() const;
|
||||
void SetStrokeFirst(bool isStrokeFirst);
|
||||
bool IsStrokeFirst();
|
||||
bool IsStrokeFirst() const;
|
||||
|
||||
private:
|
||||
void ApplyFilter(SkPaint& paint, const Filter& filter);
|
||||
void ApplyFilter(SkPaint& paint, const Filter& filter) const;
|
||||
|
||||
std::shared_ptr<PaintData> stroke_;
|
||||
std::shared_ptr<PaintData> fill_;
|
||||
|
@ -59,22 +59,22 @@ void* Bitmap::GetPixels()
|
||||
return pixels_;
|
||||
}
|
||||
|
||||
void Bitmap::CopyPixels(Bitmap& dst, int srcLeft, int srcTop, int width, int height)
|
||||
void Bitmap::CopyPixels(Bitmap& dst, int srcLeft, int srcTop, int width, int height) const
|
||||
{
|
||||
bmpImplPtr->CopyPixels(dst, srcLeft, srcTop, width, height);
|
||||
}
|
||||
|
||||
void Bitmap::ClearWithColor(const ColorQuad& color)
|
||||
void Bitmap::ClearWithColor(const ColorQuad& color) const
|
||||
{
|
||||
bmpImplPtr->ClearWithColor(color);
|
||||
}
|
||||
|
||||
bool Bitmap::IsValid()
|
||||
bool Bitmap::IsValid() const
|
||||
{
|
||||
return bmpImplPtr->IsValid();
|
||||
}
|
||||
|
||||
ColorQuad Bitmap::GetColor(int x, int y)
|
||||
ColorQuad Bitmap::GetColor(int x, int y) const
|
||||
{
|
||||
return bmpImplPtr->GetColor(x, y);
|
||||
}
|
||||
@ -84,7 +84,7 @@ void Bitmap::Free()
|
||||
bmpImplPtr->Free();
|
||||
}
|
||||
|
||||
BitmapFormat Bitmap::GetFormat()
|
||||
BitmapFormat Bitmap::GetFormat() const
|
||||
{
|
||||
return format_;
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ void Matrix::SetMatrix(scalar scaleX, scalar skewX, scalar transX, scalar skewY,
|
||||
matrixImplPtr->SetMatrix(scaleX, skewX, transX, skewY, scaleY, transY, persp0, persp1, persp2);
|
||||
}
|
||||
|
||||
scalar Matrix::Get(int index)
|
||||
scalar Matrix::Get(int index) const
|
||||
{
|
||||
return matrixImplPtr->Get(index);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user