aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/text
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2016-12-15 10:58:41 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-12-15 16:58:04 +0000
commit344ec42f60fd9d10f14d4ffaf8e7b7916bb20bcc (patch)
tree23effeb876372f752159f876ce9d9a26abfaf7a2 /src/gpu/text
parent09e019eafdc01d7d33e2b9d469a3f5afe2808e38 (diff)
Rename GrAtlasTextBatch->GrAtlasTextOp and sk_sp
Change-Id: I409048988cccb68daaeb66828e2772fcb6a0cb06 Reviewed-on: https://skia-review.googlesource.com/6104 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu/text')
-rw-r--r--src/gpu/text/GrAtlasTextBlob.cpp52
-rw-r--r--src/gpu/text/GrAtlasTextBlob.h36
-rw-r--r--src/gpu/text/GrAtlasTextBlob_regenInBatch.cpp63
-rw-r--r--src/gpu/text/GrAtlasTextContext.cpp7
4 files changed, 82 insertions, 76 deletions
diff --git a/src/gpu/text/GrAtlasTextBlob.cpp b/src/gpu/text/GrAtlasTextBlob.cpp
index e3c23d69ed..f2f031238b 100644
--- a/src/gpu/text/GrAtlasTextBlob.cpp
+++ b/src/gpu/text/GrAtlasTextBlob.cpp
@@ -9,8 +9,8 @@
#include "GrBlurUtils.h"
#include "GrContext.h"
-#include "GrRenderTargetContext.h"
#include "GrPipelineBuilder.h"
+#include "GrRenderTargetContext.h"
#include "GrTextUtils.h"
#include "SkColorFilter.h"
#include "SkDrawFilter.h"
@@ -254,14 +254,11 @@ bool GrAtlasTextBlob::mustRegenerate(const SkPaint& paint,
return false;
}
-inline GrDrawOp* GrAtlasTextBlob::createBatch(const Run::SubRunInfo& info,
- int glyphCount, int run, int subRun,
- const SkMatrix& viewMatrix, SkScalar x, SkScalar y,
- GrColor color,
- const SkPaint& skPaint, const SkSurfaceProps& props,
- const GrDistanceFieldAdjustTable* distanceAdjustTable,
- bool useGammaCorrectDistanceTable,
- GrBatchFontCache* cache) {
+inline sk_sp<GrDrawOp> GrAtlasTextBlob::makeOp(
+ const Run::SubRunInfo& info, int glyphCount, int run, int subRun,
+ const SkMatrix& viewMatrix, SkScalar x, SkScalar y, GrColor color, const SkPaint& skPaint,
+ const SkSurfaceProps& props, const GrDistanceFieldAdjustTable* distanceAdjustTable,
+ bool useGammaCorrectDistanceTable, GrBatchFontCache* cache) {
GrMaskFormat format = info.maskFormat();
GrColor subRunColor;
if (kARGB_GrMaskFormat == format) {
@@ -271,7 +268,7 @@ inline GrDrawOp* GrAtlasTextBlob::createBatch(const Run::SubRunInfo& info,
subRunColor = color;
}
- GrAtlasTextBatch* batch;
+ sk_sp<GrAtlasTextOp> batch;
if (info.drawAsDistanceFields()) {
SkColor filteredColor;
SkColorFilter* colorFilter = skPaint.getColorFilter();
@@ -281,14 +278,13 @@ inline GrDrawOp* GrAtlasTextBlob::createBatch(const Run::SubRunInfo& info,
filteredColor = skPaint.getColor();
}
bool useBGR = SkPixelGeometryIsBGR(props.pixelGeometry());
- batch = GrAtlasTextBatch::CreateDistanceField(glyphCount, cache,
- distanceAdjustTable,
- useGammaCorrectDistanceTable,
- filteredColor, info.hasUseLCDText(), useBGR);
+ batch = GrAtlasTextOp::MakeDistanceField(glyphCount, cache, distanceAdjustTable,
+ useGammaCorrectDistanceTable, filteredColor,
+ info.hasUseLCDText(), useBGR);
} else {
- batch = GrAtlasTextBatch::CreateBitmap(format, glyphCount, cache);
+ batch = GrAtlasTextOp::MakeBitmap(format, glyphCount, cache);
}
- GrAtlasTextBatch::Geometry& geometry = batch->geometry();
+ GrAtlasTextOp::Geometry& geometry = batch->geometry();
geometry.fViewMatrix = viewMatrix;
geometry.fBlob = SkRef(this);
geometry.fRun = run;
@@ -298,7 +294,7 @@ inline GrDrawOp* GrAtlasTextBlob::createBatch(const Run::SubRunInfo& info,
geometry.fY = y;
batch->init();
- return batch;
+ return std::move(batch);
}
inline
@@ -317,9 +313,9 @@ void GrAtlasTextBlob::flushRun(GrRenderTargetContext* rtc, const GrPaint& grPain
GrColor color = grPaint.getColor();
- sk_sp<GrDrawOp> op(this->createBatch(info, glyphCount, run, subRun, viewMatrix, x, y, color,
- skPaint, props, distanceAdjustTable,
- rtc->isGammaCorrect(), cache));
+ sk_sp<GrDrawOp> op(this->makeOp(info, glyphCount, run, subRun, viewMatrix, x, y, color,
+ skPaint, props, distanceAdjustTable, rtc->isGammaCorrect(),
+ cache));
GrPipelineBuilder pipelineBuilder(grPaint, GrAAType::kNone);
rtc->addDrawOp(pipelineBuilder, clip, std::move(op));
@@ -455,15 +451,15 @@ void GrAtlasTextBlob::flushThrowaway(GrContext* context,
this->flushBigGlyphs(context, rtc, clip, skPaint, viewMatrix, x, y, clipBounds);
}
-GrDrawOp* GrAtlasTextBlob::test_createBatch(int glyphCount, int run, int subRun,
- const SkMatrix& viewMatrix, SkScalar x, SkScalar y,
- GrColor color,
- const SkPaint& skPaint, const SkSurfaceProps& props,
- const GrDistanceFieldAdjustTable* distanceAdjustTable,
- GrBatchFontCache* cache) {
+sk_sp<GrDrawOp> GrAtlasTextBlob::test_makeOp(int glyphCount, int run, int subRun,
+ const SkMatrix& viewMatrix, SkScalar x, SkScalar y,
+ GrColor color, const SkPaint& skPaint,
+ const SkSurfaceProps& props,
+ const GrDistanceFieldAdjustTable* distanceAdjustTable,
+ GrBatchFontCache* cache) {
const GrAtlasTextBlob::Run::SubRunInfo& info = fRuns[run].fSubRunInfo[subRun];
- return this->createBatch(info, glyphCount, run, subRun, viewMatrix, x, y, color, skPaint,
- props, distanceAdjustTable, false, cache);
+ return this->makeOp(info, glyphCount, run, subRun, viewMatrix, x, y, color, skPaint, props,
+ distanceAdjustTable, false, cache);
}
void GrAtlasTextBlob::AssertEqual(const GrAtlasTextBlob& l, const GrAtlasTextBlob& r) {
diff --git a/src/gpu/text/GrAtlasTextBlob.h b/src/gpu/text/GrAtlasTextBlob.h
index 1801e25210..9d19a705aa 100644
--- a/src/gpu/text/GrAtlasTextBlob.h
+++ b/src/gpu/text/GrAtlasTextBlob.h
@@ -279,11 +279,11 @@ public:
////////////////////////////////////////////////////////////////////////////////////////////////
// Internal test methods
- GrDrawOp* test_createBatch(int glyphCount, int run, int subRun,
- const SkMatrix& viewMatrix, SkScalar x, SkScalar y, GrColor color,
- const SkPaint& skPaint, const SkSurfaceProps& props,
- const GrDistanceFieldAdjustTable* distanceAdjustTable,
- GrBatchFontCache* cache);
+ sk_sp<GrDrawOp> test_makeOp(int glyphCount, int run, int subRun, const SkMatrix& viewMatrix,
+ SkScalar x, SkScalar y, GrColor color, const SkPaint& skPaint,
+ const SkSurfaceProps& props,
+ const GrDistanceFieldAdjustTable* distanceAdjustTable,
+ GrBatchFontCache* cache);
private:
GrAtlasTextBlob()
@@ -496,23 +496,15 @@ private:
};
template <bool regenPos, bool regenCol, bool regenTexCoords, bool regenGlyphs>
- void regenInBatch(GrDrawOp::Target* target,
- GrBatchFontCache* fontCache,
- GrBlobRegenHelper* helper,
- Run* run, Run::SubRunInfo* info,
- SkAutoGlyphCache*, int glyphCount,
- size_t vertexStride,
- GrColor color, SkScalar transX,
- SkScalar transY) const;
-
- inline GrDrawOp* createBatch(const Run::SubRunInfo& info,
- int glyphCount, int run, int subRun,
- const SkMatrix& viewMatrix, SkScalar x, SkScalar y,
- GrColor color,
- const SkPaint& skPaint, const SkSurfaceProps& props,
- const GrDistanceFieldAdjustTable* distanceAdjustTable,
- bool useGammaCorrectDistanceTable,
- GrBatchFontCache* cache);
+ void regenInOp(GrDrawOp::Target* target, GrBatchFontCache* fontCache, GrBlobRegenHelper* helper,
+ Run* run, Run::SubRunInfo* info, SkAutoGlyphCache*, int glyphCount,
+ size_t vertexStride, GrColor color, SkScalar transX, SkScalar transY) const;
+
+ inline sk_sp<GrDrawOp> makeOp(const Run::SubRunInfo& info, int glyphCount, int run, int subRun,
+ const SkMatrix& viewMatrix, SkScalar x, SkScalar y, GrColor color,
+ const SkPaint& skPaint, const SkSurfaceProps& props,
+ const GrDistanceFieldAdjustTable* distanceAdjustTable,
+ bool useGammaCorrectDistanceTable, GrBatchFontCache* cache);
struct BigGlyph {
BigGlyph(const SkPath& path, SkScalar vx, SkScalar vy, SkScalar scale, bool treatAsBMP)
diff --git a/src/gpu/text/GrAtlasTextBlob_regenInBatch.cpp b/src/gpu/text/GrAtlasTextBlob_regenInBatch.cpp
index 1b541464f0..d1c47367d4 100644
--- a/src/gpu/text/GrAtlasTextBlob_regenInBatch.cpp
+++ b/src/gpu/text/GrAtlasTextBlob_regenInBatch.cpp
@@ -138,15 +138,10 @@ inline void regen_vertices(intptr_t vertex, const GrGlyph* glyph, size_t vertexS
}
template <bool regenPos, bool regenCol, bool regenTexCoords, bool regenGlyphs>
-void GrAtlasTextBlob::regenInBatch(GrDrawOp::Target* target,
- GrBatchFontCache* fontCache,
- GrBlobRegenHelper *helper,
- Run* run,
- Run::SubRunInfo* info,
- SkAutoGlyphCache* lazyCache,
- int glyphCount, size_t vertexStride,
- GrColor color, SkScalar transX,
- SkScalar transY) const {
+void GrAtlasTextBlob::regenInOp(GrDrawOp::Target* target, GrBatchFontCache* fontCache,
+ GrBlobRegenHelper* helper, Run* run, Run::SubRunInfo* info,
+ SkAutoGlyphCache* lazyCache, int glyphCount, size_t vertexStride,
+ GrColor color, SkScalar transX, SkScalar transY) const {
SkASSERT(lazyCache);
static_assert(!regenGlyphs || regenTexCoords, "must regenTexCoords along regenGlyphs");
GrBatchTextStrike* strike = nullptr;
@@ -208,7 +203,7 @@ void GrAtlasTextBlob::regenInBatch(GrDrawOp::Target* target,
intptr_t vertex = reinterpret_cast<intptr_t>(fVertices);
vertex += info->vertexStartIndex();
- vertex += vertexStride * glyphIdx * GrAtlasTextBatch::kVerticesPerGlyph;
+ vertex += vertexStride * glyphIdx * GrAtlasTextOp::kVerticesPerGlyph;
regen_vertices<regenPos, regenCol, regenTexCoords>(vertex, glyph, vertexStride,
info->drawAsDistanceFields(), transX,
transY, log2Width, log2Height, color);
@@ -286,19 +281,41 @@ void GrAtlasTextBlob::regenInBatch(GrDrawOp::Target* target,
RegenMask regenMask = (RegenMask)regenMaskBits;
switch (regenMask) {
- case kRegenPos: this->regenInBatch<true, false, false, false>(REGEN_ARGS); break;
- case kRegenCol: this->regenInBatch<false, true, false, false>(REGEN_ARGS); break;
- case kRegenTex: this->regenInBatch<false, false, true, false>(REGEN_ARGS); break;
- case kRegenGlyph: this->regenInBatch<false, false, true, true>(REGEN_ARGS); break;
-
- // combinations
- case kRegenPosCol: this->regenInBatch<true, true, false, false>(REGEN_ARGS); break;
- case kRegenPosTex: this->regenInBatch<true, false, true, false>(REGEN_ARGS); break;
- case kRegenPosTexGlyph: this->regenInBatch<true, false, true, true>(REGEN_ARGS); break;
- case kRegenPosColTex: this->regenInBatch<true, true, true, false>(REGEN_ARGS); break;
- case kRegenPosColTexGlyph: this->regenInBatch<true, true, true, true>(REGEN_ARGS); break;
- case kRegenColTex: this->regenInBatch<false, true, true, false>(REGEN_ARGS); break;
- case kRegenColTexGlyph: this->regenInBatch<false, true, true, true>(REGEN_ARGS); break;
+ case kRegenPos:
+ this->regenInOp<true, false, false, false>(REGEN_ARGS);
+ break;
+ case kRegenCol:
+ this->regenInOp<false, true, false, false>(REGEN_ARGS);
+ break;
+ case kRegenTex:
+ this->regenInOp<false, false, true, false>(REGEN_ARGS);
+ break;
+ case kRegenGlyph:
+ this->regenInOp<false, false, true, true>(REGEN_ARGS);
+ break;
+
+ // combinations
+ case kRegenPosCol:
+ this->regenInOp<true, true, false, false>(REGEN_ARGS);
+ break;
+ case kRegenPosTex:
+ this->regenInOp<true, false, true, false>(REGEN_ARGS);
+ break;
+ case kRegenPosTexGlyph:
+ this->regenInOp<true, false, true, true>(REGEN_ARGS);
+ break;
+ case kRegenPosColTex:
+ this->regenInOp<true, true, true, false>(REGEN_ARGS);
+ break;
+ case kRegenPosColTexGlyph:
+ this->regenInOp<true, true, true, true>(REGEN_ARGS);
+ break;
+ case kRegenColTex:
+ this->regenInOp<false, true, true, false>(REGEN_ARGS);
+ break;
+ case kRegenColTexGlyph:
+ this->regenInOp<false, true, true, true>(REGEN_ARGS);
+ break;
case kNoRegen:
helper->incGlyphCount(*glyphCount);
diff --git a/src/gpu/text/GrAtlasTextContext.cpp b/src/gpu/text/GrAtlasTextContext.cpp
index 76bdfc83cb..2e2cf40939 100644
--- a/src/gpu/text/GrAtlasTextContext.cpp
+++ b/src/gpu/text/GrAtlasTextContext.cpp
@@ -428,9 +428,10 @@ DRAW_BATCH_TEST_DEFINE(TextBlobBatch) {
gSurfaceProps, text,
static_cast<size_t>(textLen), x, y));
- return blob->test_createBatch(textLen, 0, 0, viewMatrix, x, y, color, skPaint,
- gSurfaceProps, gTextContext->dfAdjustTable(),
- context->getBatchFontCache());
+ return blob
+ ->test_makeOp(textLen, 0, 0, viewMatrix, x, y, color, skPaint, gSurfaceProps,
+ gTextContext->dfAdjustTable(), context->getBatchFontCache())
+ .release();
}
#endif