168b58c95384dd6c2fd389a5b4bbf8fc468819454bsalomon@google.com/* 268b58c95384dd6c2fd389a5b4bbf8fc468819454bsalomon@google.com * Copyright 2013 Google Inc. 368b58c95384dd6c2fd389a5b4bbf8fc468819454bsalomon@google.com * 468b58c95384dd6c2fd389a5b4bbf8fc468819454bsalomon@google.com * Use of this source code is governed by a BSD-style license that can be 568b58c95384dd6c2fd389a5b4bbf8fc468819454bsalomon@google.com * found in the LICENSE file. 668b58c95384dd6c2fd389a5b4bbf8fc468819454bsalomon@google.com */ 768b58c95384dd6c2fd389a5b4bbf8fc468819454bsalomon@google.com 868b58c95384dd6c2fd389a5b4bbf8fc468819454bsalomon@google.com#ifndef GrSimpleTextureEffect_DEFINED 968b58c95384dd6c2fd389a5b4bbf8fc468819454bsalomon@google.com#define GrSimpleTextureEffect_DEFINED 1068b58c95384dd6c2fd389a5b4bbf8fc468819454bsalomon@google.com 1168b58c95384dd6c2fd389a5b4bbf8fc468819454bsalomon@google.com#include "GrSingleTextureEffect.h" 1268b58c95384dd6c2fd389a5b4bbf8fc468819454bsalomon@google.com 13605dd0fbce9dbb2a0d3313e13e161f2bd54870d7egdanielclass GrInvariantOutput; 1468b58c95384dd6c2fd389a5b4bbf8fc468819454bsalomon@google.com 1568b58c95384dd6c2fd389a5b4bbf8fc468819454bsalomon@google.com/** 1668b58c95384dd6c2fd389a5b4bbf8fc468819454bsalomon@google.com * The output color of this effect is a modulation of the input color and a sample from a texture. 17c78188896e28a4ae49e406a7422b345ae177dafebsalomon@google.com * It allows explicit specification of the filtering and wrap modes (GrTextureParams). It can use 18ae4738f677c70f4ec7687422e1510ee3d80d810ebsalomon * local coords or device space coords as input texture coords. The input coords may be transformed 19ae4738f677c70f4ec7687422e1510ee3d80d810ebsalomon * by a matrix. 2068b58c95384dd6c2fd389a5b4bbf8fc468819454bsalomon@google.com */ 2168b58c95384dd6c2fd389a5b4bbf8fc468819454bsalomon@google.comclass GrSimpleTextureEffect : public GrSingleTextureEffect { 2268b58c95384dd6c2fd389a5b4bbf8fc468819454bsalomon@google.compublic: 2368b58c95384dd6c2fd389a5b4bbf8fc468819454bsalomon@google.com /* unfiltered, clamp mode */ 244a339529612a43871d021877e58698e067d6c4cdbsalomon static const GrFragmentProcessor* Create(GrTexture* tex, 25ae4738f677c70f4ec7687422e1510ee3d80d810ebsalomon const SkMatrix& matrix, 26ae4738f677c70f4ec7687422e1510ee3d80d810ebsalomon GrCoordSet coordSet = kLocal_GrCoordSet) { 274a339529612a43871d021877e58698e067d6c4cdbsalomon return new GrSimpleTextureEffect(tex, matrix, GrTextureParams::kNone_FilterMode, coordSet); 2868b58c95384dd6c2fd389a5b4bbf8fc468819454bsalomon@google.com } 2968b58c95384dd6c2fd389a5b4bbf8fc468819454bsalomon@google.com 3068b58c95384dd6c2fd389a5b4bbf8fc468819454bsalomon@google.com /* clamp mode */ 314a339529612a43871d021877e58698e067d6c4cdbsalomon static GrFragmentProcessor* Create(GrTexture* tex, 32b0a8a377f832c59cee939ad721e1f87d378b7142joshualitt const SkMatrix& matrix, 33b0a8a377f832c59cee939ad721e1f87d378b7142joshualitt GrTextureParams::FilterMode filterMode, 34b0a8a377f832c59cee939ad721e1f87d378b7142joshualitt GrCoordSet coordSet = kLocal_GrCoordSet) { 354a339529612a43871d021877e58698e067d6c4cdbsalomon return new GrSimpleTextureEffect(tex, matrix, filterMode, coordSet); 3668b58c95384dd6c2fd389a5b4bbf8fc468819454bsalomon@google.com } 3768b58c95384dd6c2fd389a5b4bbf8fc468819454bsalomon@google.com 384a339529612a43871d021877e58698e067d6c4cdbsalomon static GrFragmentProcessor* Create(GrTexture* tex, 39b0a8a377f832c59cee939ad721e1f87d378b7142joshualitt const SkMatrix& matrix, 40b0a8a377f832c59cee939ad721e1f87d378b7142joshualitt const GrTextureParams& p, 41b0a8a377f832c59cee939ad721e1f87d378b7142joshualitt GrCoordSet coordSet = kLocal_GrCoordSet) { 424a339529612a43871d021877e58698e067d6c4cdbsalomon return new GrSimpleTextureEffect(tex, matrix, p, coordSet); 43c78188896e28a4ae49e406a7422b345ae177dafebsalomon@google.com } 44c78188896e28a4ae49e406a7422b345ae177dafebsalomon@google.com 4568b58c95384dd6c2fd389a5b4bbf8fc468819454bsalomon@google.com virtual ~GrSimpleTextureEffect() {} 4668b58c95384dd6c2fd389a5b4bbf8fc468819454bsalomon@google.com 4736352bf5e38f45a70ee4f4fc132a38048d38206dmtklein const char* name() const override { return "SimpleTexture"; } 4868b58c95384dd6c2fd389a5b4bbf8fc468819454bsalomon@google.com 4968b58c95384dd6c2fd389a5b4bbf8fc468819454bsalomon@google.comprivate: 504a339529612a43871d021877e58698e067d6c4cdbsalomon GrSimpleTextureEffect(GrTexture* texture, 51c78188896e28a4ae49e406a7422b345ae177dafebsalomon@google.com const SkMatrix& matrix, 52b86add1ad37776818e1f730359ec587c9fdbff5fhumper@google.com GrTextureParams::FilterMode filterMode, 5377af6805e5faea1e2a5c0220098aec9082f3a6e5bsalomon@google.com GrCoordSet coordSet) 544a339529612a43871d021877e58698e067d6c4cdbsalomon : GrSingleTextureEffect(texture, matrix, filterMode, coordSet) { 55eb2a6761654307e8aeeeaabdd63c6bf9ab0411e9joshualitt this->initClassID<GrSimpleTextureEffect>(); 56c78188896e28a4ae49e406a7422b345ae177dafebsalomon@google.com } 57c78188896e28a4ae49e406a7422b345ae177dafebsalomon@google.com 584a339529612a43871d021877e58698e067d6c4cdbsalomon GrSimpleTextureEffect(GrTexture* texture, 59c78188896e28a4ae49e406a7422b345ae177dafebsalomon@google.com const SkMatrix& matrix, 60c78188896e28a4ae49e406a7422b345ae177dafebsalomon@google.com const GrTextureParams& params, 6177af6805e5faea1e2a5c0220098aec9082f3a6e5bsalomon@google.com GrCoordSet coordSet) 624a339529612a43871d021877e58698e067d6c4cdbsalomon : GrSingleTextureEffect(texture, matrix, params, coordSet) { 63eb2a6761654307e8aeeeaabdd63c6bf9ab0411e9joshualitt this->initClassID<GrSimpleTextureEffect>(); 64c78188896e28a4ae49e406a7422b345ae177dafebsalomon@google.com } 6568b58c95384dd6c2fd389a5b4bbf8fc468819454bsalomon@google.com 6657d3b039c635945e1dc2fcbac3462ed8bfedb068egdaniel GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; 67b1daa86732fe70aa4630c89d75ff0fd619d77c77wangyix 6857d3b039c635945e1dc2fcbac3462ed8bfedb068egdaniel void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const override; 694b3050b410254d0cb38df9a30ae2e209124fa1a2wangyix 7036352bf5e38f45a70ee4f4fc132a38048d38206dmtklein bool onIsEqual(const GrFragmentProcessor& other) const override { return true; } 7168b58c95384dd6c2fd389a5b4bbf8fc468819454bsalomon@google.com 7236352bf5e38f45a70ee4f4fc132a38048d38206dmtklein void onComputeInvariantOutput(GrInvariantOutput* inout) const override; 731a8ecdfb73a15de600d5779b75d7c4b61863c50begdaniel 74b0a8a377f832c59cee939ad721e1f87d378b7142joshualitt GR_DECLARE_FRAGMENT_PROCESSOR_TEST; 7568b58c95384dd6c2fd389a5b4bbf8fc468819454bsalomon@google.com 7668b58c95384dd6c2fd389a5b4bbf8fc468819454bsalomon@google.com typedef GrSingleTextureEffect INHERITED; 7768b58c95384dd6c2fd389a5b4bbf8fc468819454bsalomon@google.com}; 7868b58c95384dd6c2fd389a5b4bbf8fc468819454bsalomon@google.com 7968b58c95384dd6c2fd389a5b4bbf8fc468819454bsalomon@google.com#endif 80