OLD | NEW |
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 "GrGpuGL.h" | 8 #include "GrGpuGL.h" |
9 | 9 |
10 #include "GrEffect.h" | 10 #include "GrEffect.h" |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 SkScalarToFloat(m[SkMatrix::kMPersp2]) | 151 SkScalarToFloat(m[SkMatrix::kMPersp2]) |
152 }; | 152 }; |
153 GL_CALL(MatrixMode(GR_GL_PROJECTION)); | 153 GL_CALL(MatrixMode(GR_GL_PROJECTION)); |
154 GL_CALL(LoadMatrixf(mv)); | 154 GL_CALL(LoadMatrixf(mv)); |
155 fHWPathStencilMatrixState.fViewMatrix = vm; | 155 fHWPathStencilMatrixState.fViewMatrix = vm; |
156 fHWPathStencilMatrixState.fRenderTargetSize = size; | 156 fHWPathStencilMatrixState.fRenderTargetSize = size; |
157 fHWPathStencilMatrixState.fRenderTargetOrigin = rt->origin(); | 157 fHWPathStencilMatrixState.fRenderTargetOrigin = rt->origin(); |
158 } | 158 } |
159 } | 159 } |
160 | 160 |
161 bool GrGpuGL::flushGraphicsState(DrawType type) { | 161 bool GrGpuGL::flushGraphicsState(DrawType type, const GrDeviceCoordTexture* dstC
opy) { |
162 const GrDrawState& drawState = this->getDrawState(); | 162 const GrDrawState& drawState = this->getDrawState(); |
163 | 163 |
164 // GrGpu::setupClipAndFlushState should have already checked this and bailed
if not true. | 164 // GrGpu::setupClipAndFlushState should have already checked this and bailed
if not true. |
165 GrAssert(NULL != drawState.getRenderTarget()); | 165 GrAssert(NULL != drawState.getRenderTarget()); |
166 | 166 |
167 if (kStencilPath_DrawType == type) { | 167 if (kStencilPath_DrawType == type) { |
168 this->flushPathStencilMatrix(); | 168 this->flushPathStencilMatrix(); |
169 } else { | 169 } else { |
170 this->flushMiscFixedFunctionState(); | 170 this->flushMiscFixedFunctionState(); |
171 | 171 |
172 GrBlendCoeff srcCoeff; | 172 GrBlendCoeff srcCoeff; |
173 GrBlendCoeff dstCoeff; | 173 GrBlendCoeff dstCoeff; |
174 GrDrawState::BlendOptFlags blendOpts = drawState.getBlendOpts(false, &sr
cCoeff, &dstCoeff); | 174 GrDrawState::BlendOptFlags blendOpts = drawState.getBlendOpts(false, &sr
cCoeff, &dstCoeff); |
175 if (GrDrawState::kSkipDraw_BlendOptFlag & blendOpts) { | 175 if (GrDrawState::kSkipDraw_BlendOptFlag & blendOpts) { |
176 return false; | 176 return false; |
177 } | 177 } |
178 | 178 |
179 const GrEffectStage* stages[GrDrawState::kNumStages]; | 179 const GrEffectStage* stages[GrDrawState::kNumStages]; |
180 for (int i = 0; i < GrDrawState::kNumStages; ++i) { | 180 for (int i = 0; i < GrDrawState::kNumStages; ++i) { |
181 stages[i] = drawState.isStageEnabled(i) ? &drawState.getStage(i) : N
ULL; | 181 stages[i] = drawState.isStageEnabled(i) ? &drawState.getStage(i) : N
ULL; |
182 } | 182 } |
183 GrGLProgramDesc desc; | 183 GrGLProgramDesc desc; |
184 GrGLProgramDesc::Build(this->getDrawState(), | 184 GrGLProgramDesc::Build(this->getDrawState(), |
185 kDrawPoints_DrawType == type, | 185 kDrawPoints_DrawType == type, |
186 blendOpts, | 186 blendOpts, |
187 srcCoeff, | 187 srcCoeff, |
188 dstCoeff, | 188 dstCoeff, |
189 this, | 189 this, |
| 190 dstCopy, |
190 &desc); | 191 &desc); |
191 | 192 |
192 fCurrentProgram.reset(fProgramCache->getProgram(desc, stages)); | 193 fCurrentProgram.reset(fProgramCache->getProgram(desc, stages)); |
193 if (NULL == fCurrentProgram.get()) { | 194 if (NULL == fCurrentProgram.get()) { |
194 GrAssert(!"Failed to create program!"); | 195 GrAssert(!"Failed to create program!"); |
195 return false; | 196 return false; |
196 } | 197 } |
197 fCurrentProgram.get()->ref(); | 198 fCurrentProgram.get()->ref(); |
198 | 199 |
199 GrGLuint programID = fCurrentProgram->programID(); | 200 GrGLuint programID = fCurrentProgram->programID(); |
(...skipping 10 matching lines...) Expand all Loading... |
210 if (blendOpts & GrDrawState::kEmitTransBlack_BlendOptFlag) { | 211 if (blendOpts & GrDrawState::kEmitTransBlack_BlendOptFlag) { |
211 color = 0; | 212 color = 0; |
212 coverage = 0; | 213 coverage = 0; |
213 } else if (blendOpts & GrDrawState::kEmitCoverage_BlendOptFlag) { | 214 } else if (blendOpts & GrDrawState::kEmitCoverage_BlendOptFlag) { |
214 color = 0xffffffff; | 215 color = 0xffffffff; |
215 coverage = drawState.getCoverage(); | 216 coverage = drawState.getCoverage(); |
216 } else { | 217 } else { |
217 color = drawState.getColor(); | 218 color = drawState.getColor(); |
218 coverage = drawState.getCoverage(); | 219 coverage = drawState.getCoverage(); |
219 } | 220 } |
220 fCurrentProgram->setData(this, color, coverage, &fSharedGLProgramState); | 221 fCurrentProgram->setData(this, color, coverage, dstCopy, &fSharedGLProgr
amState); |
221 } | 222 } |
222 this->flushStencil(type); | 223 this->flushStencil(type); |
223 this->flushScissor(); | 224 this->flushScissor(); |
224 this->flushAAState(type); | 225 this->flushAAState(type); |
225 | 226 |
226 GrIRect* devRect = NULL; | 227 GrIRect* devRect = NULL; |
227 GrIRect devClipBounds; | 228 GrIRect devClipBounds; |
228 if (drawState.isClipState()) { | 229 if (drawState.isClipState()) { |
229 this->getClip()->getConservativeBounds(drawState.getRenderTarget(), &dev
ClipBounds); | 230 this->getClip()->getConservativeBounds(drawState.getRenderTarget(), &dev
ClipBounds); |
230 devRect = &devClipBounds; | 231 devRect = &devClipBounds; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 GrGLAttribTypeToLayout(attribType).fCount, | 306 GrGLAttribTypeToLayout(attribType).fCount, |
306 GrGLAttribTypeToLayout(attribType).fType, | 307 GrGLAttribTypeToLayout(attribType).fType, |
307 GrGLAttribTypeToLayout(attribType).fNormalized, | 308 GrGLAttribTypeToLayout(attribType).fNormalized, |
308 stride, | 309 stride, |
309 reinterpret_cast<GrGLvoid*>( | 310 reinterpret_cast<GrGLvoid*>( |
310 vertexOffsetInBytes + vertexAttrib->fOffset)); | 311 vertexOffsetInBytes + vertexAttrib->fOffset)); |
311 } | 312 } |
312 | 313 |
313 attribState->disableUnusedAttribArrays(this, usedAttribArraysMask); | 314 attribState->disableUnusedAttribArrays(this, usedAttribArraysMask); |
314 } | 315 } |
OLD | NEW |