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

Side by Side Diff: src/gpu/gl/GrGLProgram.cpp

Issue 885923002: Move DstCopy on gpu into the GrXferProcessor. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Back to bool Created 5 years, 10 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/gl/GrGLGpu.cpp ('k') | src/gpu/gl/GrGLProgramDesc.h » ('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 2011 Google Inc. 2 * Copyright 2011 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 "GrGLProgram.h" 8 #include "GrGLProgram.h"
9 9
10 #include "GrAllocator.h" 10 #include "GrAllocator.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 } 54 }
55 } 55 }
56 56
57 void GrGLProgram::abandon() { 57 void GrGLProgram::abandon() {
58 fProgramID = 0; 58 fProgramID = 0;
59 } 59 }
60 60
61 void GrGLProgram::initSamplerUniforms() { 61 void GrGLProgram::initSamplerUniforms() {
62 GL_CALL(UseProgram(fProgramID)); 62 GL_CALL(UseProgram(fProgramID));
63 GrGLint texUnitIdx = 0; 63 GrGLint texUnitIdx = 0;
64 if (fBuiltinUniformHandles.fDstCopySamplerUni.isValid()) {
65 fProgramDataManager.setSampler(fBuiltinUniformHandles.fDstCopySamplerUni , texUnitIdx);
66 fDstCopyTexUnit = texUnitIdx++;
67 }
68 this->initSamplers(fGeometryProcessor.get(), &texUnitIdx); 64 this->initSamplers(fGeometryProcessor.get(), &texUnitIdx);
69 if (fXferProcessor.get()) { 65 if (fXferProcessor.get()) {
70 this->initSamplers(fXferProcessor.get(), &texUnitIdx); 66 this->initSamplers(fXferProcessor.get(), &texUnitIdx);
71 } 67 }
72 int numProcs = fFragmentProcessors->fProcs.count(); 68 int numProcs = fFragmentProcessors->fProcs.count();
73 for (int i = 0; i < numProcs; i++) { 69 for (int i = 0; i < numProcs; i++) {
74 this->initSamplers(fFragmentProcessors->fProcs[i], &texUnitIdx); 70 this->initSamplers(fFragmentProcessors->fProcs[i], &texUnitIdx);
75 } 71 }
76 } 72 }
77 73
(...skipping 22 matching lines...) Expand all
100 } 96 }
101 } 97 }
102 98
103 99
104 /////////////////////////////////////////////////////////////////////////////// 100 ///////////////////////////////////////////////////////////////////////////////
105 101
106 void GrGLProgram::setData(const GrPrimitiveProcessor& primProc, const GrPipeline & pipeline, 102 void GrGLProgram::setData(const GrPrimitiveProcessor& primProc, const GrPipeline & pipeline,
107 const GrBatchTracker& batchTracker) { 103 const GrBatchTracker& batchTracker) {
108 this->setRenderTargetState(primProc, pipeline); 104 this->setRenderTargetState(primProc, pipeline);
109 105
110 const GrDeviceCoordTexture* dstCopy = pipeline.getDstCopy();
111 if (dstCopy) {
112 if (fBuiltinUniformHandles.fDstCopyTopLeftUni.isValid()) {
113 fProgramDataManager.set2f(fBuiltinUniformHandles.fDstCopyTopLeftUni,
114 static_cast<GrGLfloat>(dstCopy->offset(). fX),
115 static_cast<GrGLfloat>(dstCopy->offset(). fY));
116 fProgramDataManager.set2f(fBuiltinUniformHandles.fDstCopyScaleUni,
117 1.f / dstCopy->texture()->width(),
118 1.f / dstCopy->texture()->height());
119 GrGLTexture* texture = static_cast<GrGLTexture*>(dstCopy->texture()) ;
120 static GrTextureParams kParams; // the default is clamp, nearest fil tering.
121 fGpu->bindTexture(fDstCopyTexUnit, kParams, texture);
122 } else {
123 SkASSERT(!fBuiltinUniformHandles.fDstCopyScaleUni.isValid());
124 SkASSERT(!fBuiltinUniformHandles.fDstCopySamplerUni.isValid());
125 }
126 } else {
127 SkASSERT(!fBuiltinUniformHandles.fDstCopyTopLeftUni.isValid());
128 SkASSERT(!fBuiltinUniformHandles.fDstCopyScaleUni.isValid());
129 SkASSERT(!fBuiltinUniformHandles.fDstCopySamplerUni.isValid());
130 }
131
132 // we set the textures, and uniforms for installed processors in a generic w ay, but subclasses 106 // we set the textures, and uniforms for installed processors in a generic w ay, but subclasses
133 // of GLProgram determine how to set coord transforms 107 // of GLProgram determine how to set coord transforms
134 fGeometryProcessor->fGLProc->setData(fProgramDataManager, primProc, batchTra cker); 108 fGeometryProcessor->fGLProc->setData(fProgramDataManager, primProc, batchTra cker);
135 this->bindTextures(fGeometryProcessor.get(), primProc); 109 this->bindTextures(fGeometryProcessor.get(), primProc);
136 110
137 if (fXferProcessor.get()) { 111 const GrXferProcessor& xp = *pipeline.getXferProcessor();
138 const GrXferProcessor& xp = *pipeline.getXferProcessor(); 112 fXferProcessor->fGLProc->setData(fProgramDataManager, xp);
139 fXferProcessor->fGLProc->setData(fProgramDataManager, xp); 113 this->bindTextures(fXferProcessor.get(), xp);
140 this->bindTextures(fXferProcessor.get(), xp); 114
141 }
142 this->setFragmentData(primProc, pipeline); 115 this->setFragmentData(primProc, pipeline);
143 116
144 // Some of GrGLProgram subclasses need to update state here 117 // Some of GrGLProgram subclasses need to update state here
145 this->didSetData(); 118 this->didSetData();
146 } 119 }
147 120
148 void GrGLProgram::setFragmentData(const GrPrimitiveProcessor& primProc, 121 void GrGLProgram::setFragmentData(const GrPrimitiveProcessor& primProc,
149 const GrPipeline& pipeline) { 122 const GrPipeline& pipeline) {
150 int numProcessors = fFragmentProcessors->fProcs.count(); 123 int numProcessors = fFragmentProcessors->fProcs.count();
151 for (int e = 0; e < numProcessors; ++e) { 124 for (int e = 0; e < numProcessors; ++e) {
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 202
230 void GrGLNvprProgram::onSetRenderTargetState(const GrPrimitiveProcessor& primPro c, 203 void GrGLNvprProgram::onSetRenderTargetState(const GrPrimitiveProcessor& primPro c,
231 const GrPipeline& pipeline) { 204 const GrPipeline& pipeline) {
232 SkASSERT(!primProc.willUseGeoShader() && primProc.numAttribs() == 0); 205 SkASSERT(!primProc.willUseGeoShader() && primProc.numAttribs() == 0);
233 const GrRenderTarget* rt = pipeline.getRenderTarget(); 206 const GrRenderTarget* rt = pipeline.getRenderTarget();
234 SkISize size; 207 SkISize size;
235 size.set(rt->width(), rt->height()); 208 size.set(rt->width(), rt->height());
236 fGpu->glPathRendering()->setProjectionMatrix(primProc.viewMatrix(), 209 fGpu->glPathRendering()->setProjectionMatrix(primProc.viewMatrix(),
237 size, rt->origin()); 210 size, rt->origin());
238 } 211 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLGpu.cpp ('k') | src/gpu/gl/GrGLProgramDesc.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698