mirror of
https://gitee.com/openharmony/graphic_graphic_2d
synced 2025-02-25 15:01:30 +00:00
!16150 支持计算文字及文字阴影绘制区域
Merge pull request !16150 from liumingxiang/text_paint_region
This commit is contained in:
commit
e063e5fd76
@ -462,6 +462,18 @@ void Typography::UpdateColor(size_t from, size_t to, const Drawing::Color& color
|
||||
}
|
||||
paragraph_->UpdateColor(from, to, color);
|
||||
}
|
||||
|
||||
Drawing::RectI Typography::GeneratePaintRegion(double x, double y) const
|
||||
{
|
||||
std::unique_lock<std::shared_mutex> writeLock(mutex_);
|
||||
if (!paragraph_) {
|
||||
double left = std::floor(x);
|
||||
double top = std::floor(y);
|
||||
return Drawing::RectI(left, top, left, top);
|
||||
}
|
||||
|
||||
return paragraph_->GeneratePaintRegion(x, y);
|
||||
}
|
||||
} // namespace AdapterTxt
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
@ -76,6 +76,7 @@ public:
|
||||
std::unique_ptr<OHOS::Rosen::Typography> CloneSelf() override;
|
||||
void UpdateColor(size_t from, size_t to, const Drawing::Color& color) override;
|
||||
void* GetParagraph() override { return reinterpret_cast<void*>(paragraph_.get()); }
|
||||
Drawing::RectI GeneratePaintRegion(double x, double y) const override;
|
||||
private:
|
||||
std::unique_ptr<SPText::Paragraph> paragraph_ = nullptr;
|
||||
std::vector<TextStyle> lineMetricsStyles_;
|
||||
|
@ -163,6 +163,7 @@ public:
|
||||
virtual void UpdateColor(size_t from, size_t to, const Drawing::Color& color) = 0;
|
||||
virtual double GetLongestLineWithIndent() const = 0;
|
||||
virtual void* GetParagraph() = 0;
|
||||
virtual Drawing::RectI GeneratePaintRegion(double x, double y) const = 0;
|
||||
};
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
@ -416,6 +416,19 @@ void ParagraphImpl::RecordDifferentPthreadCall(const char* caller) const
|
||||
threadId_ = currenetThreadId;
|
||||
}
|
||||
}
|
||||
|
||||
Drawing::RectI ParagraphImpl::GeneratePaintRegion(double x, double y)
|
||||
{
|
||||
RecordDifferentPthreadCall("GeneratePaintRegion");
|
||||
if (!paragraph_) {
|
||||
double left = std::floor(x);
|
||||
double top = std::floor(y);
|
||||
return Drawing::RectI(left, top, left, top);
|
||||
}
|
||||
|
||||
SkIRect skIRect = paragraph_->generatePaintRegion(SkDoubleToScalar(x), SkDoubleToScalar(y));
|
||||
return Drawing::RectI(skIRect.left(), skIRect.top(), skIRect.right(), skIRect.bottom());
|
||||
}
|
||||
} // namespace SPText
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
@ -120,6 +120,7 @@ public:
|
||||
std::unique_ptr<Paragraph> CloneSelf() override;
|
||||
TextStyle SkStyleToTextStyle(const skia::textlayout::TextStyle& skStyle) override;
|
||||
void UpdateColor(size_t from, size_t to, const RSColor& color) override;
|
||||
Drawing::RectI GeneratePaintRegion(double x, double y) override;
|
||||
|
||||
private:
|
||||
void RecordDifferentPthreadCall(const char* caller) const;
|
||||
|
@ -197,6 +197,7 @@ public:
|
||||
virtual TextStyle SkStyleToTextStyle(const skia::textlayout::TextStyle& skStyle) = 0;
|
||||
virtual void UpdateColor(size_t from, size_t to, const RSColor& color) = 0;
|
||||
virtual Range<size_t> GetEllipsisTextRange() = 0;
|
||||
virtual OHOS::Rosen::Drawing::RectI GeneratePaintRegion(double x, double y) = 0;
|
||||
};
|
||||
} // namespace SPText
|
||||
} // namespace Rosen
|
||||
|
Loading…
x
Reference in New Issue
Block a user