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

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

Issue 815643005: Move program descriptor and primitive processor off of optstate (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: small cleanup Created 5 years, 11 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
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 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 "GrGeometryProcessor.h" 8 #include "GrGeometryProcessor.h"
9 9
10 #include "GrCoordTransform.h" 10 #include "GrCoordTransform.h"
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 } else { 224 } else {
225 vb->codeAppendf("%s = %s * vec3(%s, 1);", v.vsOut(), uniName , localCoords); 225 vb->codeAppendf("%s = %s * vec3(%s, 1);", v.vsOut(), uniName , localCoords);
226 } 226 }
227 } 227 }
228 } 228 }
229 } 229 }
230 } 230 }
231 231
232 232
233 void 233 void
234 GrGLGeometryProcessor::setTransformData(const GrPrimitiveProcessor* primProc, 234 GrGLGeometryProcessor::setTransformData(const GrPrimitiveProcessor& primProc,
235 const GrGLProgramDataManager& pdman, 235 const GrGLProgramDataManager& pdman,
236 int index, 236 int index,
237 const SkTArray<const GrCoordTransform*, true>& transforms) { 237 const SkTArray<const GrCoordTransform*, true>& transforms) {
238 SkSTArray<2, Transform, true>& procTransforms = fInstalledTransforms[index]; 238 SkSTArray<2, Transform, true>& procTransforms = fInstalledTransforms[index];
239 int numTransforms = transforms.count(); 239 int numTransforms = transforms.count();
240 for (int t = 0; t < numTransforms; ++t) { 240 for (int t = 0; t < numTransforms; ++t) {
241 SkASSERT(procTransforms[t].fHandle.isValid()); 241 SkASSERT(procTransforms[t].fHandle.isValid());
242 const SkMatrix& transform = GetTransformMatrix(primProc->localMatrix(), *transforms[t]); 242 const SkMatrix& transform = GetTransformMatrix(primProc.localMatrix(), * transforms[t]);
243 if (!procTransforms[t].fCurrentValue.cheapEqualTo(transform)) { 243 if (!procTransforms[t].fCurrentValue.cheapEqualTo(transform)) {
244 pdman.setSkMatrix(procTransforms[t].fHandle.convertToUniformHandle() , transform); 244 pdman.setSkMatrix(procTransforms[t].fHandle.convertToUniformHandle() , transform);
245 procTransforms[t].fCurrentValue = transform; 245 procTransforms[t].fCurrentValue = transform;
246 } 246 }
247 } 247 }
248 } 248 }
249 249
250 //////////////////////////////////////////////////////////////////////////////// /////////////////// 250 //////////////////////////////////////////////////////////////////////////////// ///////////////////
251 251
252 #include "gl/GrGLGpu.h" 252 #include "gl/GrGLGpu.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 for (int t = 0; t < coordTransforms.count(); ++t) { 338 for (int t = 0; t < coordTransforms.count(); ++t) {
339 GrSLType type = coordTransforms[t]->getMatrix().hasPerspective() ? kVec3f_GrSLType : 339 GrSLType type = coordTransforms[t]->getMatrix().hasPerspective() ? kVec3f_GrSLType :
340 kVec2f_GrSLType; 340 kVec2f_GrSLType;
341 341
342 name.printf("%s(gl_TexCoord[%i])", GrGLSLTypeString(type), texCo ordIndex++); 342 name.printf("%s(gl_TexCoord[%i])", GrGLSLTypeString(type), texCo ordIndex++);
343 SkNEW_APPEND_TO_TARRAY(&(*tout)[i], GrGLProcessor::TransformedCo ords, (name, type)); 343 SkNEW_APPEND_TO_TARRAY(&(*tout)[i], GrGLProcessor::TransformedCo ords, (name, type));
344 } 344 }
345 } 345 }
346 } 346 }
347 347
348 void setTransformData(const GrPrimitiveProcessor* primProc, 348 void setTransformData(const GrPrimitiveProcessor& primProc,
349 int index, 349 int index,
350 const SkTArray<const GrCoordTransform*, true>& transfo rms, 350 const SkTArray<const GrCoordTransform*, true>& transfo rms,
351 GrGLPathRendering* glpr, 351 GrGLPathRendering* glpr,
352 GrGLuint) SK_OVERRIDE { 352 GrGLuint) SK_OVERRIDE {
353 // We've hidden the texcoord index in the first entry of the transforms array for each 353 // We've hidden the texcoord index in the first entry of the transforms array for each
354 // effect 354 // effect
355 int texCoordIndex = fInstalledTransforms[index][0].fHandle.handle(); 355 int texCoordIndex = fInstalledTransforms[index][0].fHandle.handle();
356 for (int t = 0; t < transforms.count(); ++t) { 356 for (int t = 0; t < transforms.count(); ++t) {
357 const SkMatrix& transform = GetTransformMatrix(primProc->localMatrix (), *transforms[t]); 357 const SkMatrix& transform = GetTransformMatrix(primProc.localMatrix( ), *transforms[t]);
358 GrGLPathRendering::PathTexGenComponents components = 358 GrGLPathRendering::PathTexGenComponents components =
359 GrGLPathRendering::kST_PathTexGenComponents; 359 GrGLPathRendering::kST_PathTexGenComponents;
360 if (transform.hasPerspective()) { 360 if (transform.hasPerspective()) {
361 components = GrGLPathRendering::kSTR_PathTexGenComponents; 361 components = GrGLPathRendering::kSTR_PathTexGenComponents;
362 } 362 }
363 glpr->enablePathTexGen(texCoordIndex++, components, transform); 363 glpr->enablePathTexGen(texCoordIndex++, components, transform);
364 } 364 }
365 } 365 }
366 366
367 void didSetData(GrGLPathRendering* glpr) SK_OVERRIDE { 367 void didSetData(GrGLPathRendering* glpr) SK_OVERRIDE {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 GrGLint location; 416 GrGLint location;
417 GR_GL_CALL_RET(gpu->glInterface(), 417 GR_GL_CALL_RET(gpu->glInterface(),
418 location, 418 location,
419 GetProgramResourceLocation(programId, 419 GetProgramResourceLocation(programId,
420 GR_GL_FRAGMENT_INPUT, 420 GR_GL_FRAGMENT_INPUT,
421 fSeparableVaryingInfos[i]. fVariable.c_str())); 421 fSeparableVaryingInfos[i]. fVariable.c_str()));
422 fSeparableVaryingInfos[i].fLocation = location; 422 fSeparableVaryingInfos[i].fLocation = location;
423 } 423 }
424 } 424 }
425 425
426 void setTransformData(const GrPrimitiveProcessor* primProc, 426 void setTransformData(const GrPrimitiveProcessor& primProc,
427 int index, 427 int index,
428 const SkTArray<const GrCoordTransform*, true>& coordTr ansforms, 428 const SkTArray<const GrCoordTransform*, true>& coordTr ansforms,
429 GrGLPathRendering* glpr, 429 GrGLPathRendering* glpr,
430 GrGLuint programID) SK_OVERRIDE { 430 GrGLuint programID) SK_OVERRIDE {
431 SkSTArray<2, Transform, true>& transforms = fInstalledTransforms[index]; 431 SkSTArray<2, Transform, true>& transforms = fInstalledTransforms[index];
432 int numTransforms = transforms.count(); 432 int numTransforms = transforms.count();
433 for (int t = 0; t < numTransforms; ++t) { 433 for (int t = 0; t < numTransforms; ++t) {
434 SkASSERT(transforms[t].fHandle.isValid()); 434 SkASSERT(transforms[t].fHandle.isValid());
435 const SkMatrix& transform = GetTransformMatrix(primProc->localMatrix (), 435 const SkMatrix& transform = GetTransformMatrix(primProc.localMatrix( ),
436 *coordTransforms[t]); 436 *coordTransforms[t]);
437 if (transforms[t].fCurrentValue.cheapEqualTo(transform)) { 437 if (transforms[t].fCurrentValue.cheapEqualTo(transform)) {
438 continue; 438 continue;
439 } 439 }
440 transforms[t].fCurrentValue = transform; 440 transforms[t].fCurrentValue = transform;
441 const SeparableVaryingInfo& fragmentInput = 441 const SeparableVaryingInfo& fragmentInput =
442 fSeparableVaryingInfos[transforms[t].fHandle.handle()]; 442 fSeparableVaryingInfos[transforms[t].fHandle.handle()];
443 SkASSERT(transforms[t].fType == kVec2f_GrSLType || 443 SkASSERT(transforms[t].fType == kVec2f_GrSLType ||
444 transforms[t].fType == kVec3f_GrSLType); 444 transforms[t].fType == kVec3f_GrSLType);
445 unsigned components = transforms[t].fType == kVec2f_GrSLType ? 2 : 3 ; 445 unsigned components = transforms[t].fType == kVec2f_GrSLType ? 2 : 3 ;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 const GrGLCaps& caps) const { 528 const GrGLCaps& caps) const {
529 SkASSERT(caps.nvprSupport() != GrGLCaps::kNone_NvprSupport); 529 SkASSERT(caps.nvprSupport() != GrGLCaps::kNone_NvprSupport);
530 if (caps.nvprSupport() == GrGLCaps::kLegacy_NvprSupport) { 530 if (caps.nvprSupport() == GrGLCaps::kLegacy_NvprSupport) {
531 return SkNEW_ARGS(GrGLLegacyPathProcessor, (*this, bt, 531 return SkNEW_ARGS(GrGLLegacyPathProcessor, (*this, bt,
532 caps.maxFixedFunctionTexture Coords())); 532 caps.maxFixedFunctionTexture Coords()));
533 } else { 533 } else {
534 return SkNEW_ARGS(GrGLNormalPathProcessor, (*this, bt)); 534 return SkNEW_ARGS(GrGLNormalPathProcessor, (*this, bt));
535 } 535 }
536 } 536 }
537 537
OLDNEW
« no previous file with comments | « src/gpu/GrGeometryProcessor.h ('k') | src/gpu/GrGpu.h » ('j') | src/gpu/GrGpu.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698