aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/atlastext
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2018-06-19 13:09:54 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-06-19 19:51:20 +0000
commitc994a93b327235182c6d29a782c409b2c58476ae (patch)
treedba9ab1ff4a414e76da883f47ee90acbf0f27868 /src/atlastext
parent4d75975b70c454288226afc03e512ad9bc2db5ac (diff)
Move op memory storage to GrContext (take 2)
TBR=bsalomon@google.com Change-Id: I4a448694d4114d83cd3a720cfc8bd37de51733d1 Reviewed-on: https://skia-review.googlesource.com/135707 Reviewed-by: Greg Daniel <egdaniel@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/atlastext')
-rw-r--r--src/atlastext/SkAtlasTextTarget.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/atlastext/SkAtlasTextTarget.cpp b/src/atlastext/SkAtlasTextTarget.cpp
index 0fb9a79ee7..f4cda548af 100644
--- a/src/atlastext/SkAtlasTextTarget.cpp
+++ b/src/atlastext/SkAtlasTextTarget.cpp
@@ -83,6 +83,11 @@ public:
void* handle)
: GrTextUtils::Target(width, height, kColorSpaceInfo)
, SkAtlasTextTarget(std::move(context), width, height, handle) {
+ fOpMemoryPool = fContext->internal().grContext()->contextPriv().refOpMemoryPool();
+ }
+
+ ~SkInternalAtlasTextTarget() override {
+ this->deleteOps();
}
/** GrTextUtils::Target overrides */
@@ -110,10 +115,13 @@ public:
void flush() override;
private:
+ void deleteOps();
+
uint32_t fColor;
using SkAtlasTextTarget::fWidth;
using SkAtlasTextTarget::fHeight;
SkTArray<std::unique_ptr<GrAtlasTextOp>, true> fOps;
+ sk_sp<GrOpMemoryPool> fOpMemoryPool;
};
//////////////////////////////////////////////////////////////////////////////
@@ -162,6 +170,7 @@ void SkInternalAtlasTextTarget::addDrawOp(const GrClip& clip, std::unique_ptr<Gr
for (int i = 0; i < n; ++i) {
GrAtlasTextOp* other = fOps.fromBack(i).get();
if (other->combineIfPossible(op.get(), caps)) {
+ fOpMemoryPool->release(std::move(op));
return;
}
if (GrRectsOverlap(op->bounds(), other->bounds())) {
@@ -172,12 +181,21 @@ void SkInternalAtlasTextTarget::addDrawOp(const GrClip& clip, std::unique_ptr<Gr
fOps.emplace_back(std::move(op));
}
+void SkInternalAtlasTextTarget::deleteOps() {
+ for (int i = 0; i < fOps.count(); ++i) {
+ if (fOps[i]) {
+ fOpMemoryPool->release(std::move(fOps[i]));
+ }
+ }
+ fOps.reset();
+}
+
void SkInternalAtlasTextTarget::flush() {
for (int i = 0; i < fOps.count(); ++i) {
fOps[i]->executeForTextTarget(this);
}
this->context()->internal().flush();
- fOps.reset();
+ this->deleteOps();
}
void GrAtlasTextOp::finalizeForTextTarget(uint32_t color, const GrCaps& caps) {