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

Side by Side Diff: src/gpu/GrFragmentProcessor.cpp

Issue 2339203002: Stop flattening GrCoordTransforms in parent GrFragmentProcessors. (Closed)
Patch Set: Fix issue of taking ref to a temporary Created 4 years, 3 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/GrDefaultGeoProcFactory.cpp ('k') | src/gpu/GrOvalRenderer.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 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 "GrPipeline.h"
11 #include "GrProcOptInfo.h" 12 #include "GrProcOptInfo.h"
12 #include "glsl/GrGLSLFragmentProcessor.h" 13 #include "glsl/GrGLSLFragmentProcessor.h"
13 #include "glsl/GrGLSLFragmentShaderBuilder.h" 14 #include "glsl/GrGLSLFragmentShaderBuilder.h"
14 #include "glsl/GrGLSLProgramDataManager.h" 15 #include "glsl/GrGLSLProgramDataManager.h"
15 #include "glsl/GrGLSLUniformHandler.h" 16 #include "glsl/GrGLSLUniformHandler.h"
16 #include "effects/GrConstColorProcessor.h" 17 #include "effects/GrConstColorProcessor.h"
17 #include "effects/GrXfermodeFragmentProcessor.h" 18 #include "effects/GrXfermodeFragmentProcessor.h"
18 19
19 GrFragmentProcessor::~GrFragmentProcessor() { 20 GrFragmentProcessor::~GrFragmentProcessor() {
20 // If we got here then our ref count must have reached zero, so we will have converted refs 21 // If we got here then our ref count must have reached zero, so we will have converted refs
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 } 75 }
75 76
76 void GrFragmentProcessor::addCoordTransform(const GrCoordTransform* transform) { 77 void GrFragmentProcessor::addCoordTransform(const GrCoordTransform* transform) {
77 // Can't add transforms after registering any children since their transform s have already been 78 // Can't add transforms after registering any children since their transform s have already been
78 // bubbled up into our fCoordTransforms array 79 // bubbled up into our fCoordTransforms array
79 SkASSERT(fChildProcessors.empty()); 80 SkASSERT(fChildProcessors.empty());
80 81
81 fCoordTransforms.push_back(transform); 82 fCoordTransforms.push_back(transform);
82 fUsesLocalCoords = fUsesLocalCoords || transform->sourceCoords() == kLocal_G rCoordSet; 83 fUsesLocalCoords = fUsesLocalCoords || transform->sourceCoords() == kLocal_G rCoordSet;
83 SkDEBUGCODE(transform->setInProcessor();) 84 SkDEBUGCODE(transform->setInProcessor();)
84 fNumTransformsExclChildren++;
85 } 85 }
86 86
87 int GrFragmentProcessor::registerChildProcessor(sk_sp<GrFragmentProcessor> child ) { 87 int GrFragmentProcessor::registerChildProcessor(sk_sp<GrFragmentProcessor> child ) {
88 // Append the child's transforms to our transforms array and the child's tex tures array to our 88 // Append the child's textures array to our textures array
89 // textures array
90 if (!child->fCoordTransforms.empty()) {
91 fCoordTransforms.push_back_n(child->fCoordTransforms.count(),
92 child->fCoordTransforms.begin());
93 }
94 if (!child->fTextureAccesses.empty()) { 89 if (!child->fTextureAccesses.empty()) {
95 fTextureAccesses.push_back_n(child->fTextureAccesses.count(), 90 fTextureAccesses.push_back_n(child->fTextureAccesses.count(),
96 child->fTextureAccesses.begin()); 91 child->fTextureAccesses.begin());
97 } 92 }
98 93
99 this->combineRequiredFeatures(*child); 94 this->combineRequiredFeatures(*child);
100 95
101 if (child->usesLocalCoords()) { 96 if (child->usesLocalCoords()) {
102 fUsesLocalCoords = true; 97 fUsesLocalCoords = true;
103 } 98 }
104 if (child->usesDistanceVectorField()) { 99 if (child->usesDistanceVectorField()) {
105 fUsesDistanceVectorField = true; 100 fUsesDistanceVectorField = true;
106 } 101 }
107 102
108 int index = fChildProcessors.count(); 103 int index = fChildProcessors.count();
109 fChildProcessors.push_back(child.release()); 104 fChildProcessors.push_back(child.release());
110 105
111 return index; 106 return index;
112 } 107 }
113 108
114 void GrFragmentProcessor::notifyRefCntIsZero() const { 109 void GrFragmentProcessor::notifyRefCntIsZero() const {
115 // See comment above GrProgramElement for a detailed explanation of why we d o this. 110 // See comment above GrProgramElement for a detailed explanation of why we d o this.
116 for (int i = 0; i < fChildProcessors.count(); ++i) { 111 for (int i = 0; i < fChildProcessors.count(); ++i) {
117 fChildProcessors[i]->addPendingExecution(); 112 fChildProcessors[i]->addPendingExecution();
118 fChildProcessors[i]->unref(); 113 fChildProcessors[i]->unref();
119 } 114 }
120 } 115 }
121 116
122 bool GrFragmentProcessor::hasSameTransforms(const GrFragmentProcessor& that) con st { 117 bool GrFragmentProcessor::hasSameTransforms(const GrFragmentProcessor& that) con st {
123 if (this->numTransforms() != that.numTransforms()) { 118 if (this->numCoordTransforms() != that.numCoordTransforms()) {
124 return false; 119 return false;
125 } 120 }
126 int count = this->numTransforms(); 121 int count = this->numCoordTransforms();
127 for (int i = 0; i < count; ++i) { 122 for (int i = 0; i < count; ++i) {
128 if (this->coordTransform(i) != that.coordTransform(i)) { 123 if (this->coordTransform(i) != that.coordTransform(i)) {
129 return false; 124 return false;
130 } 125 }
131 } 126 }
132 return true; 127 return true;
133 } 128 }
134 129
135 sk_sp<GrFragmentProcessor> GrFragmentProcessor::MulOutputByInputAlpha( 130 sk_sp<GrFragmentProcessor> GrFragmentProcessor::MulOutputByInputAlpha(
136 sk_sp<GrFragmentProcessor> fp) { 131 sk_sp<GrFragmentProcessor> fp) {
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 } else { 396 } else {
402 series += firstIdx; 397 series += firstIdx;
403 cnt -= firstIdx; 398 cnt -= firstIdx;
404 } 399 }
405 400
406 if (1 == cnt) { 401 if (1 == cnt) {
407 return series[0]; 402 return series[0];
408 } 403 }
409 return sk_sp<GrFragmentProcessor>(new SeriesFragmentProcessor(series, cnt)); 404 return sk_sp<GrFragmentProcessor>(new SeriesFragmentProcessor(series, cnt));
410 } 405 }
406
407 //////////////////////////////////////////////////////////////////////////////
408
409 GrFragmentProcessor::Iter::Iter(const GrPipeline& pipeline) {
410 for (int i = pipeline.numFragmentProcessors() - 1; i >= 0; --i) {
411 fFPStack.push_back(&pipeline.getFragmentProcessor(i));
412 }
413 }
414
415 const GrFragmentProcessor* GrFragmentProcessor::Iter::next() {
416 if (fFPStack.empty()) {
417 return nullptr;
418 }
419 const GrFragmentProcessor* back = fFPStack.back();
420 fFPStack.pop_back();
421 for (int i = back->numChildProcessors() - 1; i >= 0; --i) {
422 fFPStack.push_back(&back->childProcessor(i));
423 }
424 return back;
425 }
426
427 //////////////////////////////////////////////////////////////////////////////
428
429 const GrCoordTransform* GrFragmentProcessor::CoordTransformIter::next() {
430 if (!fCurrFP) {
431 return nullptr;
432 }
433 while (fCTIdx == fCurrFP->numCoordTransforms()) {
434 fCTIdx = 0;
435 fCurrFP = fFPIter.next();
436 if (!fCurrFP) {
437 return nullptr;
438 }
439 }
440 return &fCurrFP->coordTransform(fCTIdx++);
441 }
OLDNEW
« no previous file with comments | « src/gpu/GrDefaultGeoProcFactory.cpp ('k') | src/gpu/GrOvalRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698