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

Side by Side Diff: src/effects/SkPerlinNoiseShader.cpp

Issue 1490283004: Create GLSLUniformHandler class for gpu backend (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: clean up public api of uniformhandler Created 5 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/effects/SkMorphologyImageFilter.cpp ('k') | src/effects/SkTableColorFilter.cpp » ('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 "SkDither.h" 8 #include "SkDither.h"
9 #include "SkPerlinNoiseShader.h" 9 #include "SkPerlinNoiseShader.h"
10 #include "SkColorFilter.h" 10 #include "SkColorFilter.h"
11 #include "SkReadBuffer.h" 11 #include "SkReadBuffer.h"
12 #include "SkWriteBuffer.h" 12 #include "SkWriteBuffer.h"
13 #include "SkShader.h" 13 #include "SkShader.h"
14 #include "SkUnPreMultiply.h" 14 #include "SkUnPreMultiply.h"
15 #include "SkString.h" 15 #include "SkString.h"
16 16
17 #if SK_SUPPORT_GPU 17 #if SK_SUPPORT_GPU
18 #include "GrContext.h" 18 #include "GrContext.h"
19 #include "GrCoordTransform.h" 19 #include "GrCoordTransform.h"
20 #include "GrInvariantOutput.h" 20 #include "GrInvariantOutput.h"
21 #include "SkGr.h" 21 #include "SkGr.h"
22 #include "effects/GrConstColorProcessor.h" 22 #include "effects/GrConstColorProcessor.h"
23 #include "glsl/GrGLSLFragmentProcessor.h" 23 #include "glsl/GrGLSLFragmentProcessor.h"
24 #include "glsl/GrGLSLFragmentShaderBuilder.h" 24 #include "glsl/GrGLSLFragmentShaderBuilder.h"
25 #include "glsl/GrGLSLProgramBuilder.h"
26 #include "glsl/GrGLSLProgramDataManager.h" 25 #include "glsl/GrGLSLProgramDataManager.h"
26 #include "glsl/GrGLSLUniformHandler.h"
27 #endif 27 #endif
28 28
29 static const int kBlockSize = 256; 29 static const int kBlockSize = 256;
30 static const int kBlockMask = kBlockSize - 1; 30 static const int kBlockMask = kBlockSize - 1;
31 static const int kPerlinNoise = 4096; 31 static const int kPerlinNoise = 4096;
32 static const int kRandMaximum = SK_MaxS32; // 2**31 - 1 32 static const int kRandMaximum = SK_MaxS32; // 2**31 - 1
33 33
34 namespace { 34 namespace {
35 35
36 // noiseValue is the color component's value (or color) 36 // noiseValue is the color component's value (or color)
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 } 614 }
615 615
616 GrGLPerlinNoise::GrGLPerlinNoise(const GrProcessor& processor) 616 GrGLPerlinNoise::GrGLPerlinNoise(const GrProcessor& processor)
617 : fType(processor.cast<GrPerlinNoiseEffect>().type()) 617 : fType(processor.cast<GrPerlinNoiseEffect>().type())
618 , fStitchTiles(processor.cast<GrPerlinNoiseEffect>().stitchTiles()) 618 , fStitchTiles(processor.cast<GrPerlinNoiseEffect>().stitchTiles())
619 , fNumOctaves(processor.cast<GrPerlinNoiseEffect>().numOctaves()) { 619 , fNumOctaves(processor.cast<GrPerlinNoiseEffect>().numOctaves()) {
620 } 620 }
621 621
622 void GrGLPerlinNoise::emitCode(EmitArgs& args) { 622 void GrGLPerlinNoise::emitCode(EmitArgs& args) {
623 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; 623 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
624 GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
624 SkString vCoords = fragBuilder->ensureFSCoords2D(args.fCoords, 0); 625 SkString vCoords = fragBuilder->ensureFSCoords2D(args.fCoords, 0);
625 626
626 fBaseFrequencyUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragmen t_Visibility, 627 fBaseFrequencyUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragme nt_Visibility,
627 kVec2f_GrSLType, kDefault_GrSL Precision, 628 kVec2f_GrSLType, kDefault_GrS LPrecision,
628 "baseFrequency"); 629 "baseFrequency");
629 const char* baseFrequencyUni = args.fBuilder->getUniformCStr(fBaseFrequencyU ni); 630 const char* baseFrequencyUni = uniformHandler->getUniformCStr(fBaseFrequency Uni);
630 631
631 const char* stitchDataUni = nullptr; 632 const char* stitchDataUni = nullptr;
632 if (fStitchTiles) { 633 if (fStitchTiles) {
633 fStitchDataUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragme nt_Visibility, 634 fStitchDataUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragm ent_Visibility,
634 kVec2f_GrSLType, kDefault_GrS LPrecision, 635 kVec2f_GrSLType, kDefault_Gr SLPrecision,
635 "stitchData"); 636 "stitchData");
636 stitchDataUni = args.fBuilder->getUniformCStr(fStitchDataUni); 637 stitchDataUni = uniformHandler->getUniformCStr(fStitchDataUni);
637 } 638 }
638 639
639 // There are 4 lines, so the center of each line is 1/8, 3/8, 5/8 and 7/8 640 // There are 4 lines, so the center of each line is 1/8, 3/8, 5/8 and 7/8
640 const char* chanCoordR = "0.125"; 641 const char* chanCoordR = "0.125";
641 const char* chanCoordG = "0.375"; 642 const char* chanCoordG = "0.375";
642 const char* chanCoordB = "0.625"; 643 const char* chanCoordB = "0.625";
643 const char* chanCoordA = "0.875"; 644 const char* chanCoordA = "0.875";
644 const char* chanCoord = "chanCoord"; 645 const char* chanCoord = "chanCoord";
645 const char* stitchData = "stitchData"; 646 const char* stitchData = "stitchData";
646 const char* ratio = "ratio"; 647 const char* ratio = "ratio";
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
995 str->append(" seed: "); 996 str->append(" seed: ");
996 str->appendScalar(fSeed); 997 str->appendScalar(fSeed);
997 str->append(" stitch tiles: "); 998 str->append(" stitch tiles: ");
998 str->append(fStitchTiles ? "true " : "false "); 999 str->append(fStitchTiles ? "true " : "false ");
999 1000
1000 this->INHERITED::toString(str); 1001 this->INHERITED::toString(str);
1001 1002
1002 str->append(")"); 1003 str->append(")");
1003 } 1004 }
1004 #endif 1005 #endif
OLDNEW
« no previous file with comments | « src/effects/SkMorphologyImageFilter.cpp ('k') | src/effects/SkTableColorFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698