Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(271)

Unified Diff: src/gpu/GrTest.cpp

Issue 1410663005: Add text animation sample; tweak DrawShip sample (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Correct fix for CrOS Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « samplecode/SampleShip.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrTest.cpp
diff --git a/src/gpu/GrTest.cpp b/src/gpu/GrTest.cpp
index 4adc3f7b7b770585a34e92729b3efe509c4c60e9..7a44942a16216f253a65154e072c92b1dfbb1037 100644
--- a/src/gpu/GrTest.cpp
+++ b/src/gpu/GrTest.cpp
@@ -11,10 +11,12 @@
#include "GrBatchAtlas.h"
#include "GrBatchFontCache.h"
#include "GrContextOptions.h"
+#include "GrDrawContext.h"
#include "GrDrawingManager.h"
#include "GrGpuResourceCacheAccess.h"
#include "GrResourceCache.h"
#include "GrTextBlobCache.h"
+#include "SkGrPriv.h"
#include "SkString.h"
namespace GrTest {
@@ -97,6 +99,35 @@ void GrContext::printGpuStats() const {
SkDebugf("%s", out.c_str());
}
+void GrContext::drawFontCache(const SkRect& rect, GrMaskFormat format, const SkPaint& paint,
+ GrRenderTarget* target) {
+ GrBatchFontCache* cache = this->getBatchFontCache();
+
+ GrTexture* atlas = cache->getTexture(format);
+
+ SkAutoTUnref<GrDrawContext> drawContext(this->drawContext(target));
+ // TODO: add drawContext method to encapsulate this.
+
+ GrPaint grPaint;
+ SkMatrix mat;
+ mat.reset();
+ if (!SkPaintToGrPaint(this, paint, mat, &grPaint)) {
+ return;
+ }
+ SkMatrix textureMat;
+ textureMat.reset();
+ // TODO: use setScaleTranslate()
+ textureMat[SkMatrix::kMScaleX] = 1.0f/rect.width();
+ textureMat[SkMatrix::kMScaleY] = 1.0f/rect.height();
+ textureMat[SkMatrix::kMTransX] = -rect.fLeft/rect.width();
+ textureMat[SkMatrix::kMTransY] = -rect.fTop/rect.height();
+
+ grPaint.addColorTextureProcessor(atlas, textureMat);
+
+ GrClip clip;
+ drawContext->drawRect(clip, grPaint, mat, rect);
+}
+
#if GR_GPU_STATS
void GrGpu::Stats::dump(SkString* out) {
out->appendf("Render Target Binds: %d\n", fRenderTargetBinds);
« no previous file with comments | « samplecode/SampleShip.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698