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

Side by Side Diff: src/gpu/effects/GrDistanceFieldGeoProc.cpp

Issue 2041113004: sk_sp for gpu. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Reserve correctly. Created 4 years, 6 months 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/effects/GrDistanceFieldGeoProc.h ('k') | src/gpu/effects/GrDitherEffect.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 "GrDistanceFieldGeoProc.h" 8 #include "GrDistanceFieldGeoProc.h"
9 #include "GrInvariantOutput.h" 9 #include "GrInvariantOutput.h"
10 #include "GrTexture.h" 10 #include "GrTexture.h"
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 } 253 }
254 254
255 GrGLSLPrimitiveProcessor* GrDistanceFieldA8TextGeoProc::createGLSLInstance(const GrGLSLCaps&) const { 255 GrGLSLPrimitiveProcessor* GrDistanceFieldA8TextGeoProc::createGLSLInstance(const GrGLSLCaps&) const {
256 return new GrGLDistanceFieldA8TextGeoProc(); 256 return new GrGLDistanceFieldA8TextGeoProc();
257 } 257 }
258 258
259 /////////////////////////////////////////////////////////////////////////////// 259 ///////////////////////////////////////////////////////////////////////////////
260 260
261 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldA8TextGeoProc); 261 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldA8TextGeoProc);
262 262
263 const GrGeometryProcessor* GrDistanceFieldA8TextGeoProc::TestCreate(GrProcessorT estData* d) { 263 sk_sp<GrGeometryProcessor> GrDistanceFieldA8TextGeoProc::TestCreate(GrProcessorT estData* d) {
264 int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx : 264 int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
265 GrProcessorUnitTest::kAlphaTextureIdx; 265 GrProcessorUnitTest::kAlphaTextureIdx;
266 static const SkShader::TileMode kTileModes[] = { 266 static const SkShader::TileMode kTileModes[] = {
267 SkShader::kClamp_TileMode, 267 SkShader::kClamp_TileMode,
268 SkShader::kRepeat_TileMode, 268 SkShader::kRepeat_TileMode,
269 SkShader::kMirror_TileMode, 269 SkShader::kMirror_TileMode,
270 }; 270 };
271 SkShader::TileMode tileModes[] = { 271 SkShader::TileMode tileModes[] = {
272 kTileModes[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))], 272 kTileModes[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))],
273 kTileModes[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))], 273 kTileModes[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))],
274 }; 274 };
275 GrTextureParams params(tileModes, d->fRandom->nextBool() ? GrTextureParams:: kBilerp_FilterMode : 275 GrTextureParams params(tileModes, d->fRandom->nextBool() ? GrTextureParams:: kBilerp_FilterMode :
276 GrTextureParams::kNon e_FilterMode); 276 GrTextureParams::kNon e_FilterMode);
277 277
278 uint32_t flags = 0; 278 uint32_t flags = 0;
279 flags |= d->fRandom->nextBool() ? kSimilarity_DistanceFieldEffectFlag : 0; 279 flags |= d->fRandom->nextBool() ? kSimilarity_DistanceFieldEffectFlag : 0;
280 if (flags & kSimilarity_DistanceFieldEffectFlag) { 280 if (flags & kSimilarity_DistanceFieldEffectFlag) {
281 flags |= d->fRandom->nextBool() ? kScaleOnly_DistanceFieldEffectFlag : 0 ; 281 flags |= d->fRandom->nextBool() ? kScaleOnly_DistanceFieldEffectFlag : 0 ;
282 } 282 }
283 283
284 return GrDistanceFieldA8TextGeoProc::Create(GrRandomColor(d->fRandom), 284 return GrDistanceFieldA8TextGeoProc::Make(GrRandomColor(d->fRandom),
285 GrTest::TestMatrix(d->fRandom), 285 GrTest::TestMatrix(d->fRandom),
286 d->fTextures[texIdx], params, 286 d->fTextures[texIdx], params,
287 #ifdef SK_GAMMA_APPLY_TO_A8 287 #ifdef SK_GAMMA_APPLY_TO_A8
288 d->fRandom->nextF(), 288 d->fRandom->nextF(),
289 #endif 289 #endif
290 flags, 290 flags,
291 d->fRandom->nextBool()); 291 d->fRandom->nextBool());
292 } 292 }
293 293
294 /////////////////////////////////////////////////////////////////////////////// 294 ///////////////////////////////////////////////////////////////////////////////
295 295
296 class GrGLDistanceFieldPathGeoProc : public GrGLSLGeometryProcessor { 296 class GrGLDistanceFieldPathGeoProc : public GrGLSLGeometryProcessor {
297 public: 297 public:
298 GrGLDistanceFieldPathGeoProc() 298 GrGLDistanceFieldPathGeoProc()
299 : fViewMatrix(SkMatrix::InvalidMatrix()) 299 : fViewMatrix(SkMatrix::InvalidMatrix())
300 , fTextureSize(SkISize::Make(-1, -1)) {} 300 , fTextureSize(SkISize::Make(-1, -1)) {}
301 301
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 } 490 }
491 491
492 GrGLSLPrimitiveProcessor* GrDistanceFieldPathGeoProc::createGLSLInstance(const G rGLSLCaps&) const { 492 GrGLSLPrimitiveProcessor* GrDistanceFieldPathGeoProc::createGLSLInstance(const G rGLSLCaps&) const {
493 return new GrGLDistanceFieldPathGeoProc(); 493 return new GrGLDistanceFieldPathGeoProc();
494 } 494 }
495 495
496 /////////////////////////////////////////////////////////////////////////////// 496 ///////////////////////////////////////////////////////////////////////////////
497 497
498 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldPathGeoProc); 498 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldPathGeoProc);
499 499
500 const GrGeometryProcessor* GrDistanceFieldPathGeoProc::TestCreate(GrProcessorTes tData* d) { 500 sk_sp<GrGeometryProcessor> GrDistanceFieldPathGeoProc::TestCreate(GrProcessorTes tData* d) {
501 int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx 501 int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
502 : GrProcessorUnitTest::kAlphaTextureIdx; 502 : GrProcessorUnitTest::kAlphaTextureIdx;
503 static const SkShader::TileMode kTileModes[] = { 503 static const SkShader::TileMode kTileModes[] = {
504 SkShader::kClamp_TileMode, 504 SkShader::kClamp_TileMode,
505 SkShader::kRepeat_TileMode, 505 SkShader::kRepeat_TileMode,
506 SkShader::kMirror_TileMode, 506 SkShader::kMirror_TileMode,
507 }; 507 };
508 SkShader::TileMode tileModes[] = { 508 SkShader::TileMode tileModes[] = {
509 kTileModes[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))], 509 kTileModes[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))],
510 kTileModes[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))], 510 kTileModes[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))],
511 }; 511 };
512 GrTextureParams params(tileModes, d->fRandom->nextBool() ? GrTextureParams:: kBilerp_FilterMode 512 GrTextureParams params(tileModes, d->fRandom->nextBool() ? GrTextureParams:: kBilerp_FilterMode
513 : GrTextureParams:: kNone_FilterMode); 513 : GrTextureParams:: kNone_FilterMode);
514 514
515 uint32_t flags = 0; 515 uint32_t flags = 0;
516 flags |= d->fRandom->nextBool() ? kSimilarity_DistanceFieldEffectFlag : 0; 516 flags |= d->fRandom->nextBool() ? kSimilarity_DistanceFieldEffectFlag : 0;
517 if (flags & kSimilarity_DistanceFieldEffectFlag) { 517 if (flags & kSimilarity_DistanceFieldEffectFlag) {
518 flags |= d->fRandom->nextBool() ? kScaleOnly_DistanceFieldEffectFlag : 0 ; 518 flags |= d->fRandom->nextBool() ? kScaleOnly_DistanceFieldEffectFlag : 0 ;
519 } 519 }
520 520
521 return GrDistanceFieldPathGeoProc::Create(GrRandomColor(d->fRandom), 521 return GrDistanceFieldPathGeoProc::Make(GrRandomColor(d->fRandom),
522 GrTest::TestMatrix(d->fRandom), 522 GrTest::TestMatrix(d->fRandom),
523 d->fTextures[texIdx], 523 d->fTextures[texIdx],
524 params, 524 params,
525 flags, 525 flags,
526 d->fRandom->nextBool()); 526 d->fRandom->nextBool());
527 } 527 }
528 528
529 /////////////////////////////////////////////////////////////////////////////// 529 ///////////////////////////////////////////////////////////////////////////////
530 530
531 class GrGLDistanceFieldLCDTextGeoProc : public GrGLSLGeometryProcessor { 531 class GrGLDistanceFieldLCDTextGeoProc : public GrGLSLGeometryProcessor {
532 public: 532 public:
533 GrGLDistanceFieldLCDTextGeoProc() 533 GrGLDistanceFieldLCDTextGeoProc()
534 : fViewMatrix(SkMatrix::InvalidMatrix()) { 534 : fViewMatrix(SkMatrix::InvalidMatrix()) {
535 fDistanceAdjust = GrDistanceFieldLCDTextGeoProc::DistanceAdjust::Make(1. 0f, 1.0f, 1.0f); 535 fDistanceAdjust = GrDistanceFieldLCDTextGeoProc::DistanceAdjust::Make(1. 0f, 1.0f, 1.0f);
536 } 536 }
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 } 787 }
788 788
789 GrGLSLPrimitiveProcessor* GrDistanceFieldLCDTextGeoProc::createGLSLInstance(cons t GrGLSLCaps&) const { 789 GrGLSLPrimitiveProcessor* GrDistanceFieldLCDTextGeoProc::createGLSLInstance(cons t GrGLSLCaps&) const {
790 return new GrGLDistanceFieldLCDTextGeoProc(); 790 return new GrGLDistanceFieldLCDTextGeoProc();
791 } 791 }
792 792
793 /////////////////////////////////////////////////////////////////////////////// 793 ///////////////////////////////////////////////////////////////////////////////
794 794
795 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldLCDTextGeoProc); 795 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldLCDTextGeoProc);
796 796
797 const GrGeometryProcessor* GrDistanceFieldLCDTextGeoProc::TestCreate(GrProcessor TestData* d) { 797 sk_sp<GrGeometryProcessor> GrDistanceFieldLCDTextGeoProc::TestCreate(GrProcessor TestData* d) {
798 int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx : 798 int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
799 GrProcessorUnitTest::kAlphaTextureIdx; 799 GrProcessorUnitTest::kAlphaTextureIdx;
800 static const SkShader::TileMode kTileModes[] = { 800 static const SkShader::TileMode kTileModes[] = {
801 SkShader::kClamp_TileMode, 801 SkShader::kClamp_TileMode,
802 SkShader::kRepeat_TileMode, 802 SkShader::kRepeat_TileMode,
803 SkShader::kMirror_TileMode, 803 SkShader::kMirror_TileMode,
804 }; 804 };
805 SkShader::TileMode tileModes[] = { 805 SkShader::TileMode tileModes[] = {
806 kTileModes[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))], 806 kTileModes[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))],
807 kTileModes[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))], 807 kTileModes[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))],
808 }; 808 };
809 GrTextureParams params(tileModes, d->fRandom->nextBool() ? GrTextureParams:: kBilerp_FilterMode : 809 GrTextureParams params(tileModes, d->fRandom->nextBool() ? GrTextureParams:: kBilerp_FilterMode :
810 GrTextureParams::kNone_FilterMode); 810 GrTextureParams::kNone_FilterMode);
811 DistanceAdjust wa = { 0.0f, 0.1f, -0.1f }; 811 DistanceAdjust wa = { 0.0f, 0.1f, -0.1f };
812 uint32_t flags = kUseLCD_DistanceFieldEffectFlag; 812 uint32_t flags = kUseLCD_DistanceFieldEffectFlag;
813 flags |= d->fRandom->nextBool() ? kSimilarity_DistanceFieldEffectFlag : 0; 813 flags |= d->fRandom->nextBool() ? kSimilarity_DistanceFieldEffectFlag : 0;
814 if (flags & kSimilarity_DistanceFieldEffectFlag) { 814 if (flags & kSimilarity_DistanceFieldEffectFlag) {
815 flags |= d->fRandom->nextBool() ? kScaleOnly_DistanceFieldEffectFlag : 0 ; 815 flags |= d->fRandom->nextBool() ? kScaleOnly_DistanceFieldEffectFlag : 0 ;
816 } 816 }
817 flags |= d->fRandom->nextBool() ? kBGR_DistanceFieldEffectFlag : 0; 817 flags |= d->fRandom->nextBool() ? kBGR_DistanceFieldEffectFlag : 0;
818 return GrDistanceFieldLCDTextGeoProc::Create(GrRandomColor(d->fRandom), 818 return GrDistanceFieldLCDTextGeoProc::Make(GrRandomColor(d->fRandom),
819 GrTest::TestMatrix(d->fRandom), 819 GrTest::TestMatrix(d->fRandom),
820 d->fTextures[texIdx], params, 820 d->fTextures[texIdx], params,
821 wa, 821 wa,
822 flags, 822 flags,
823 d->fRandom->nextBool()); 823 d->fRandom->nextBool());
824 } 824 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrDistanceFieldGeoProc.h ('k') | src/gpu/effects/GrDitherEffect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698