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

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

Issue 920863002: A simple change to move a bunch of stuff out of Gr*Geometry.h (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: clang fix 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/GrPrimitiveProcessor.h ('k') | src/gpu/gl/GrGLGeometryProcessor.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2014 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "GrPrimitiveProcessor.h"
9
10 #include "GrCoordTransform.h"
11
12 /**
13 * The key for an individual coord transform is made up of a matrix type, a prec ision, and a bit
14 * that indicates the source of the input coords.
15 */
16 enum {
17 kMatrixTypeKeyBits = 1,
18 kMatrixTypeKeyMask = (1 << kMatrixTypeKeyBits) - 1,
19
20 kPrecisionBits = 2,
21 kPrecisionShift = kMatrixTypeKeyBits,
22
23 kPositionCoords_Flag = (1 << (kPrecisionShift + kPrecisionBits)),
24 kDeviceCoords_Flag = kPositionCoords_Flag + kPositionCoords_Flag,
25
26 kTransformKeyBits = kMatrixTypeKeyBits + kPrecisionBits + 2,
27 };
28
29 GR_STATIC_ASSERT(kHigh_GrSLPrecision < (1 << kPrecisionBits));
30
31 /**
32 * We specialize the vertex code for each of these matrix types.
33 */
34 enum MatrixType {
35 kNoPersp_MatrixType = 0,
36 kGeneral_MatrixType = 1,
37 };
38
39 uint32_t
40 GrPrimitiveProcessor::getTransformKey(const SkTArray<const GrCoordTransform*, tr ue>& coords) const {
41 uint32_t totalKey = 0;
42 for (int t = 0; t < coords.count(); ++t) {
43 uint32_t key = 0;
44 const GrCoordTransform* coordTransform = coords[t];
45 if (coordTransform->getMatrix().hasPerspective()) {
46 key |= kGeneral_MatrixType;
47 } else {
48 key |= kNoPersp_MatrixType;
49 }
50
51 if (kLocal_GrCoordSet == coordTransform->sourceCoords() &&
52 !this->hasExplicitLocalCoords()) {
53 key |= kPositionCoords_Flag;
54 } else if (kDevice_GrCoordSet == coordTransform->sourceCoords()) {
55 key |= kDeviceCoords_Flag;
56 }
57
58 GR_STATIC_ASSERT(kGrSLPrecisionCount <= (1 << kPrecisionBits));
59 key |= (coordTransform->precision() << kPrecisionShift);
60
61 key <<= kTransformKeyBits * t;
62
63 SkASSERT(0 == (totalKey & key)); // keys for each transform ought not to overlap
64 totalKey |= key;
65 }
66 return totalKey;
67 }
OLDNEW
« no previous file with comments | « src/gpu/GrPrimitiveProcessor.h ('k') | src/gpu/gl/GrGLGeometryProcessor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698