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

Side by Side Diff: src/gpu/GrDistanceFieldTextContext.cpp

Issue 761563002: First step to moving vertex attributes to the geometryProcessor (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: adding test to ignore Created 6 years 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 unified diff | Download patch
« no previous file with comments | « src/gpu/GrDefaultPathRenderer.cpp ('k') | src/gpu/GrDrawState.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrDistanceFieldTextContext.h" 8 #include "GrDistanceFieldTextContext.h"
9 #include "GrAtlas.h" 9 #include "GrAtlas.h"
10 #include "GrBitmapTextContext.h" 10 #include "GrBitmapTextContext.h"
(...skipping 20 matching lines...) Expand all
31 31
32 SK_CONF_DECLARE(bool, c_DumpFontCache, "gpu.dumpFontCache", false, 32 SK_CONF_DECLARE(bool, c_DumpFontCache, "gpu.dumpFontCache", false,
33 "Dump the contents of the font cache before every purge."); 33 "Dump the contents of the font cache before every purge.");
34 34
35 static const int kSmallDFFontSize = 32; 35 static const int kSmallDFFontSize = 32;
36 static const int kSmallDFFontLimit = 32; 36 static const int kSmallDFFontLimit = 32;
37 static const int kMediumDFFontSize = 78; 37 static const int kMediumDFFontSize = 78;
38 static const int kMediumDFFontLimit = 78; 38 static const int kMediumDFFontLimit = 78;
39 static const int kLargeDFFontSize = 192; 39 static const int kLargeDFFontSize = 192;
40 40
41 namespace {
42 // position + texture coord
43 extern const GrVertexAttrib gTextVertexAttribs[] = {
44 {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBindin g},
45 {kVec2f_GrVertexAttribType, sizeof(SkPoint) , kGeometryProcessor_GrVertexAtt ribBinding}
46 };
47
48 static const size_t kTextVASize = 2 * sizeof(SkPoint); 41 static const size_t kTextVASize = 2 * sizeof(SkPoint);
49
50 // position + color + texture coord
51 extern const GrVertexAttrib gTextVertexWithColorAttribs[] = {
52 {kVec2f_GrVertexAttribType, 0, kPosition_Gr VertexAttribBinding},
53 {kVec4ub_GrVertexAttribType, sizeof(SkPoint), kColor_GrVer texAttribBinding},
54 {kVec2f_GrVertexAttribType, sizeof(SkPoint) + sizeof(GrColor), kGeometryPro cessor_GrVertexAttribBinding}
55 };
56
57 static const size_t kTextVAColorSize = 2 * sizeof(SkPoint) + sizeof(GrColor); 42 static const size_t kTextVAColorSize = 2 * sizeof(SkPoint) + sizeof(GrColor);
58 43
59 static const int kVerticesPerGlyph = 4; 44 static const int kVerticesPerGlyph = 4;
60 static const int kIndicesPerGlyph = 6; 45 static const int kIndicesPerGlyph = 6;
61 };
62 46
63 GrDistanceFieldTextContext::GrDistanceFieldTextContext(GrContext* context, 47 GrDistanceFieldTextContext::GrDistanceFieldTextContext(GrContext* context,
64 const SkDeviceProperties& properties, 48 const SkDeviceProperties& properties,
65 bool enable) 49 bool enable)
66 : GrTextContext(context, pro perties) { 50 : GrTextContext(context, pro perties) {
67 #if SK_FORCE_DISTANCE_FIELD_TEXT 51 #if SK_FORCE_DISTANCE_FIELD_TEXT
68 fEnableDFRendering = true; 52 fEnableDFRendering = true;
69 #else 53 #else
70 fEnableDFRendering = enable; 54 fEnableDFRendering = enable;
71 #endif 55 #endif
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 flags != fEffectFlags) { 409 flags != fEffectFlags) {
426 if (fUseLCDText) { 410 if (fUseLCDText) {
427 GrColor colorNoPreMul = skcolor_to_grcolor_nopremultiply(filteredCol or); 411 GrColor colorNoPreMul = skcolor_to_grcolor_nopremultiply(filteredCol or);
428 fCachedGeometryProcessor.reset(GrDistanceFieldLCDTextureEffect::Crea te(fCurrTexture, 412 fCachedGeometryProcessor.reset(GrDistanceFieldLCDTextureEffect::Crea te(fCurrTexture,
429 params, 413 params,
430 fGammaTexture, 414 fGammaTexture,
431 gammaParams, 415 gammaParams,
432 colorNoPreMul, 416 colorNoPreMul,
433 flags)); 417 flags));
434 } else { 418 } else {
419 flags |= kColorAttr_DistanceFieldEffectFlag;
435 #ifdef SK_GAMMA_APPLY_TO_A8 420 #ifdef SK_GAMMA_APPLY_TO_A8
436 U8CPU lum = SkColorSpaceLuminance::computeLuminance(fDevicePropertie s.gamma(), 421 U8CPU lum = SkColorSpaceLuminance::computeLuminance(fDevicePropertie s.gamma(),
437 filteredColor); 422 filteredColor);
438 fCachedGeometryProcessor.reset(GrDistanceFieldTextureEffect::Create( fCurrTexture, 423 fCachedGeometryProcessor.reset(GrDistanceFieldTextureEffect::Create( fCurrTexture,
439 params, 424 params,
440 fGammaTexture, 425 fGammaTexture,
441 gammaParams, 426 gammaParams,
442 lum/255.f, 427 lum/255.f,
443 flags)); 428 flags));
444 #else 429 #else
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 *colors = fPaint.getColor(); 596 *colors = fPaint.getColor();
612 colors = reinterpret_cast<GrColor*>(reinterpret_cast<intptr_t>(color s) + vertSize); 597 colors = reinterpret_cast<GrColor*>(reinterpret_cast<intptr_t>(color s) + vertSize);
613 } 598 }
614 } 599 }
615 600
616 fCurrVertex += 4; 601 fCurrVertex += 4;
617 602
618 return true; 603 return true;
619 } 604 }
620 605
621 // We use color vertices if we aren't drawing LCD text
622 static void set_vertex_attributes(GrDrawState* drawState, bool useColorVerts) {
623 // set up attributes
624 if (useColorVerts) {
625 drawState->setVertexAttribs<gTextVertexWithColorAttribs>(
626 SK_ARRAY_COUNT(gTextVertexWithColorAttribs), kTextVAColorSize);
627 } else {
628 drawState->setVertexAttribs<gTextVertexAttribs>(
629 SK_ARRAY_COUNT(gTextVertexAttribs), kTextVAS ize);
630 }
631 }
632
633 void GrDistanceFieldTextContext::flush() { 606 void GrDistanceFieldTextContext::flush() {
634 if (NULL == fDrawTarget) { 607 if (NULL == fDrawTarget) {
635 return; 608 return;
636 } 609 }
637 610
638 if (fCurrVertex > 0) { 611 if (fCurrVertex > 0) {
639 GrDrawState drawState; 612 GrDrawState drawState;
640 drawState.setFromPaint(fPaint, fContext->getMatrix(), fContext->getRende rTarget()); 613 drawState.setFromPaint(fPaint, fContext->getMatrix(), fContext->getRende rTarget());
641 bool useColorVerts = !fUseLCDText;
642 set_vertex_attributes(&drawState, useColorVerts);
643 614
644 // setup our sampler state for our text texture/atlas 615 // setup our sampler state for our text texture/atlas
645 SkASSERT(SkIsAlign4(fCurrVertex)); 616 SkASSERT(SkIsAlign4(fCurrVertex));
646 617
647 // get our current color 618 // get our current color
648 SkColor filteredColor; 619 SkColor filteredColor;
649 SkColorFilter* colorFilter = fSkPaint.getColorFilter(); 620 SkColorFilter* colorFilter = fSkPaint.getColorFilter();
650 if (colorFilter) { 621 if (colorFilter) {
651 filteredColor = colorFilter->filterColor(fSkPaint.getColor()); 622 filteredColor = colorFilter->filterColor(fSkPaint.getColor());
652 } else { 623 } else {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 } 673 }
703 } 674 }
704 675
705 inline void GrDistanceFieldTextContext::finish() { 676 inline void GrDistanceFieldTextContext::finish() {
706 this->flush(); 677 this->flush();
707 fTotalVertexCount = 0; 678 fTotalVertexCount = 0;
708 679
709 GrTextContext::finish(); 680 GrTextContext::finish();
710 } 681 }
711 682
OLDNEW
« no previous file with comments | « src/gpu/GrDefaultPathRenderer.cpp ('k') | src/gpu/GrDrawState.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698