OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "GrFragmentProcessor.h" | 8 #include "GrFragmentProcessor.h" |
9 #include "GrCoordTransform.h" | 9 #include "GrCoordTransform.h" |
10 #include "GrInvariantOutput.h" | 10 #include "GrInvariantOutput.h" |
11 #include "GrProcOptInfo.h" | 11 #include "GrProcOptInfo.h" |
12 #include "glsl/GrGLSLFragmentProcessor.h" | 12 #include "glsl/GrGLSLFragmentProcessor.h" |
13 #include "glsl/GrGLSLFragmentShaderBuilder.h" | 13 #include "glsl/GrGLSLFragmentShaderBuilder.h" |
14 #include "glsl/GrGLSLProgramDataManager.h" | 14 #include "glsl/GrGLSLProgramDataManager.h" |
15 #include "glsl/GrGLSLUniformHandler.h" | 15 #include "glsl/GrGLSLUniformHandler.h" |
16 #include "effects/GrConstColorProcessor.h" | 16 #include "effects/GrConstColorProcessor.h" |
17 #include "effects/GrXfermodeFragmentProcessor.h" | 17 #include "effects/GrXfermodeFragmentProcessor.h" |
18 | 18 |
19 GrFragmentProcessor::~GrFragmentProcessor() { | 19 GrFragmentProcessor::~GrFragmentProcessor() { |
20 // If we got here then our ref count must have reached zero, so we will have
converted refs | 20 // If we got here then our ref count must have reached zero, so we will have
converted refs |
21 // to pending executions for all children. | 21 // to pending executions for all children. |
22 for (int i = 0; i < fChildProcessors.count(); ++i) { | 22 for (int i = 0; i < fChildProcessors.count(); ++i) { |
23 fChildProcessors[i]->completedExecution(); | 23 fChildProcessors[i]->completedExecution(); |
24 } | 24 } |
25 } | 25 } |
26 | 26 |
27 bool GrFragmentProcessor::isEqual(const GrFragmentProcessor& that, | 27 bool GrFragmentProcessor::isEqual(const GrFragmentProcessor& that) const { |
28 bool ignoreCoordTransforms) const { | |
29 if (this->classID() != that.classID() || | 28 if (this->classID() != that.classID() || |
30 !this->hasSameSamplers(that)) { | 29 !this->hasSameSamplers(that)) { |
31 return false; | 30 return false; |
32 } | 31 } |
33 if (ignoreCoordTransforms) { | 32 if (!this->hasSameTransforms(that)) { |
34 if (this->numTransforms() != that.numTransforms()) { | |
35 return false; | |
36 } | |
37 } else if (!this->hasSameTransforms(that)) { | |
38 return false; | 33 return false; |
39 } | 34 } |
40 if (!this->onIsEqual(that)) { | 35 if (!this->onIsEqual(that)) { |
41 return false; | 36 return false; |
42 } | 37 } |
43 if (this->numChildProcessors() != that.numChildProcessors()) { | 38 if (this->numChildProcessors() != that.numChildProcessors()) { |
44 return false; | 39 return false; |
45 } | 40 } |
46 for (int i = 0; i < this->numChildProcessors(); ++i) { | 41 for (int i = 0; i < this->numChildProcessors(); ++i) { |
47 if (!this->childProcessor(i).isEqual(that.childProcessor(i), ignoreCoord
Transforms)) { | 42 if (!this->childProcessor(i).isEqual(that.childProcessor(i))) { |
48 return false; | 43 return false; |
49 } | 44 } |
50 } | 45 } |
51 return true; | 46 return true; |
52 } | 47 } |
53 | 48 |
54 GrGLSLFragmentProcessor* GrFragmentProcessor::createGLSLInstance() const { | 49 GrGLSLFragmentProcessor* GrFragmentProcessor::createGLSLInstance() const { |
55 GrGLSLFragmentProcessor* glFragProc = this->onCreateGLSLInstance(); | 50 GrGLSLFragmentProcessor* glFragProc = this->onCreateGLSLInstance(); |
56 glFragProc->fChildProcessors.push_back_n(fChildProcessors.count()); | 51 glFragProc->fChildProcessors.push_back_n(fChildProcessors.count()); |
57 for (int i = 0; i < fChildProcessors.count(); ++i) { | 52 for (int i = 0; i < fChildProcessors.count(); ++i) { |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 } else { | 401 } else { |
407 series += firstIdx; | 402 series += firstIdx; |
408 cnt -= firstIdx; | 403 cnt -= firstIdx; |
409 } | 404 } |
410 | 405 |
411 if (1 == cnt) { | 406 if (1 == cnt) { |
412 return series[0]; | 407 return series[0]; |
413 } | 408 } |
414 return sk_sp<GrFragmentProcessor>(new SeriesFragmentProcessor(series, cnt)); | 409 return sk_sp<GrFragmentProcessor>(new SeriesFragmentProcessor(series, cnt)); |
415 } | 410 } |
OLD | NEW |