| OLD | NEW |
| 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 "GrBitmapTextGeoProc.h" | 8 #include "GrBitmapTextGeoProc.h" |
| 9 #include "GrInvariantOutput.h" | 9 #include "GrInvariantOutput.h" |
| 10 #include "GrTexture.h" | 10 #include "GrTexture.h" |
| 11 #include "gl/GrGLProcessor.h" | 11 #include "gl/GrGLProcessor.h" |
| 12 #include "gl/GrGLSL.h" | 12 #include "gl/GrGLSL.h" |
| 13 #include "gl/GrGLTexture.h" | 13 #include "gl/GrGLTexture.h" |
| 14 #include "gl/GrGLGeometryProcessor.h" | 14 #include "gl/GrGLGeometryProcessor.h" |
| 15 #include "gl/builders/GrGLProgramBuilder.h" | 15 #include "gl/builders/GrGLProgramBuilder.h" |
| 16 | 16 |
| 17 struct BitmapTextBatchTracker { | 17 struct BitmapTextBatchTracker { |
| 18 GrGPInput fInputColorType; | 18 GrGPInput fInputColorType; |
| 19 GrColor fColor; | 19 GrColor fColor; |
| 20 bool fUsesLocalCoords; |
| 20 }; | 21 }; |
| 21 | 22 |
| 22 class GrGLBitmapTextGeoProc : public GrGLGeometryProcessor { | 23 class GrGLBitmapTextGeoProc : public GrGLGeometryProcessor { |
| 23 public: | 24 public: |
| 24 GrGLBitmapTextGeoProc(const GrGeometryProcessor&, const GrBatchTracker&) | 25 GrGLBitmapTextGeoProc(const GrGeometryProcessor&, const GrBatchTracker&) |
| 25 : fColor(GrColor_ILLEGAL) {} | 26 : fColor(GrColor_ILLEGAL) {} |
| 26 | 27 |
| 27 virtual void emitCode(const EmitArgs& args) SK_OVERRIDE { | 28 virtual void emitCode(const EmitArgs& args) SK_OVERRIDE { |
| 28 const GrBitmapTextGeoProc& cte = args.fGP.cast<GrBitmapTextGeoProc>(); | 29 const GrBitmapTextGeoProc& cte = args.fGP.cast<GrBitmapTextGeoProc>(); |
| 29 const BitmapTextBatchTracker& local = args.fBT.cast<BitmapTextBatchTrack
er>(); | 30 const BitmapTextBatchTracker& local = args.fBT.cast<BitmapTextBatchTrack
er>(); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 | 128 |
| 128 GrGLGeometryProcessor* | 129 GrGLGeometryProcessor* |
| 129 GrBitmapTextGeoProc::createGLInstance(const GrBatchTracker& bt) const { | 130 GrBitmapTextGeoProc::createGLInstance(const GrBatchTracker& bt) const { |
| 130 return SkNEW_ARGS(GrGLBitmapTextGeoProc, (*this, bt)); | 131 return SkNEW_ARGS(GrGLBitmapTextGeoProc, (*this, bt)); |
| 131 } | 132 } |
| 132 | 133 |
| 133 void GrBitmapTextGeoProc::initBatchTracker(GrBatchTracker* bt, const InitBT& ini
t) const { | 134 void GrBitmapTextGeoProc::initBatchTracker(GrBatchTracker* bt, const InitBT& ini
t) const { |
| 134 BitmapTextBatchTracker* local = bt->cast<BitmapTextBatchTracker>(); | 135 BitmapTextBatchTracker* local = bt->cast<BitmapTextBatchTracker>(); |
| 135 local->fInputColorType = GetColorInputType(&local->fColor, this->color(), in
it, | 136 local->fInputColorType = GetColorInputType(&local->fColor, this->color(), in
it, |
| 136 SkToBool(fInColor)); | 137 SkToBool(fInColor)); |
| 138 local->fUsesLocalCoords = init.fUsesLocalCoords; |
| 137 } | 139 } |
| 138 | 140 |
| 139 bool GrBitmapTextGeoProc::onCanMakeEqual(const GrBatchTracker& m, const GrBatchT
racker& t) const { | 141 bool GrBitmapTextGeoProc::onCanMakeEqual(const GrBatchTracker& m, |
| 142 const GrGeometryProcessor& that, |
| 143 const GrBatchTracker& t) const { |
| 140 const BitmapTextBatchTracker& mine = m.cast<BitmapTextBatchTracker>(); | 144 const BitmapTextBatchTracker& mine = m.cast<BitmapTextBatchTracker>(); |
| 141 const BitmapTextBatchTracker& theirs = t.cast<BitmapTextBatchTracker>(); | 145 const BitmapTextBatchTracker& theirs = t.cast<BitmapTextBatchTracker>(); |
| 142 return CanCombineOutput(mine.fInputColorType, mine.fColor, | 146 return CanCombineLocalMatrices(*this, mine.fUsesLocalCoords, |
| 147 that, theirs.fUsesLocalCoords) && |
| 148 CanCombineOutput(mine.fInputColorType, mine.fColor, |
| 143 theirs.fInputColorType, theirs.fColor); | 149 theirs.fInputColorType, theirs.fColor); |
| 144 } | 150 } |
| 145 | 151 |
| 146 /////////////////////////////////////////////////////////////////////////////// | 152 /////////////////////////////////////////////////////////////////////////////// |
| 147 | 153 |
| 148 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrBitmapTextGeoProc); | 154 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrBitmapTextGeoProc); |
| 149 | 155 |
| 150 GrGeometryProcessor* GrBitmapTextGeoProc::TestCreate(SkRandom* random, | 156 GrGeometryProcessor* GrBitmapTextGeoProc::TestCreate(SkRandom* random, |
| 151 GrContext*, | 157 GrContext*, |
| 152 const GrDrawTargetCaps&, | 158 const GrDrawTargetCaps&, |
| 153 GrTexture* textures[]) { | 159 GrTexture* textures[]) { |
| 154 int texIdx = random->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx : | 160 int texIdx = random->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx : |
| 155 GrProcessorUnitTest::kAlphaTextureIdx; | 161 GrProcessorUnitTest::kAlphaTextureIdx; |
| 156 static const SkShader::TileMode kTileModes[] = { | 162 static const SkShader::TileMode kTileModes[] = { |
| 157 SkShader::kClamp_TileMode, | 163 SkShader::kClamp_TileMode, |
| 158 SkShader::kRepeat_TileMode, | 164 SkShader::kRepeat_TileMode, |
| 159 SkShader::kMirror_TileMode, | 165 SkShader::kMirror_TileMode, |
| 160 }; | 166 }; |
| 161 SkShader::TileMode tileModes[] = { | 167 SkShader::TileMode tileModes[] = { |
| 162 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], | 168 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], |
| 163 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], | 169 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], |
| 164 }; | 170 }; |
| 165 GrTextureParams params(tileModes, random->nextBool() ? GrTextureParams::kBil
erp_FilterMode : | 171 GrTextureParams params(tileModes, random->nextBool() ? GrTextureParams::kBil
erp_FilterMode : |
| 166 GrTextureParams::kNon
e_FilterMode); | 172 GrTextureParams::kNon
e_FilterMode); |
| 167 | 173 |
| 168 return GrBitmapTextGeoProc::Create(GrRandomColor(random), textures[texIdx],
params, | 174 return GrBitmapTextGeoProc::Create(GrRandomColor(random), textures[texIdx],
params, |
| 169 random->nextBool(), random->nextBool()); | 175 random->nextBool(), random->nextBool()); |
| 170 } | 176 } |
| OLD | NEW |