| OLD | NEW |
| 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 "GrNonAAFillRectBatch.h" | 8 #include "GrNonAAFillRectBatch.h" |
| 9 | 9 |
| 10 #include "GrBatchFlushState.h" | 10 #include "GrBatchFlushState.h" |
| 11 #include "GrColor.h" | 11 #include "GrColor.h" |
| 12 #include "GrDefaultGeoProcFactory.h" | 12 #include "GrDefaultGeoProcFactory.h" |
| 13 #include "GrPrimitiveProcessor.h" | 13 #include "GrPrimitiveProcessor.h" |
| 14 #include "GrResourceProvider.h" | 14 #include "GrResourceProvider.h" |
| 15 #include "GrQuad.h" | 15 #include "GrQuad.h" |
| 16 #include "GrVertexBatch.h" | 16 #include "GrVertexBatch.h" |
| 17 | 17 |
| 18 #include "SkMatrixPriv.h" |
| 19 |
| 18 static const int kVertsPerInstance = 4; | 20 static const int kVertsPerInstance = 4; |
| 19 static const int kIndicesPerInstance = 6; | 21 static const int kIndicesPerInstance = 6; |
| 20 | 22 |
| 21 /** We always use per-vertex colors so that rects can be batched across color ch
anges. Sometimes | 23 /** We always use per-vertex colors so that rects can be batched across color ch
anges. Sometimes |
| 22 we have explicit local coords and sometimes not. We *could* always provide
explicit local | 24 we have explicit local coords and sometimes not. We *could* always provide
explicit local |
| 23 coords and just duplicate the positions when the caller hasn't provided a lo
cal coord rect, | 25 coords and just duplicate the positions when the caller hasn't provided a lo
cal coord rect, |
| 24 but we haven't seen a use case which frequently switches between local rect
and no local | 26 but we haven't seen a use case which frequently switches between local rect
and no local |
| 25 rect draws. | 27 rect draws. |
| 26 | 28 |
| 27 The vertex attrib order is always pos, color, [local coords]. | 29 The vertex attrib order is always pos, color, [local coords]. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 40 GrColor color, | 42 GrColor color, |
| 41 const SkMatrix* viewMatrix, | 43 const SkMatrix* viewMatrix, |
| 42 const SkRect& rect, | 44 const SkRect& rect, |
| 43 const GrQuad* localQuad) { | 45 const GrQuad* localQuad) { |
| 44 SkPoint* positions = reinterpret_cast<SkPoint*>(vertices); | 46 SkPoint* positions = reinterpret_cast<SkPoint*>(vertices); |
| 45 | 47 |
| 46 positions->setRectFan(rect.fLeft, rect.fTop, | 48 positions->setRectFan(rect.fLeft, rect.fTop, |
| 47 rect.fRight, rect.fBottom, vertexStride); | 49 rect.fRight, rect.fBottom, vertexStride); |
| 48 | 50 |
| 49 if (viewMatrix) { | 51 if (viewMatrix) { |
| 50 viewMatrix->mapPointsWithStride(positions, vertexStride, kVertsPerInstan
ce); | 52 SkMatrixPriv::MapPointsWithStride(*viewMatrix, positions, vertexStride,
kVertsPerInstance); |
| 51 } | 53 } |
| 52 | 54 |
| 53 // Setup local coords | 55 // Setup local coords |
| 54 // TODO we should only do this if local coords are being read | 56 // TODO we should only do this if local coords are being read |
| 55 if (localQuad) { | 57 if (localQuad) { |
| 56 static const int kLocalOffset = sizeof(SkPoint) + sizeof(GrColor); | 58 static const int kLocalOffset = sizeof(SkPoint) + sizeof(GrColor); |
| 57 for (int i = 0; i < kVertsPerInstance; i++) { | 59 for (int i = 0; i < kVertsPerInstance; i++) { |
| 58 SkPoint* coords = reinterpret_cast<SkPoint*>(vertices + kLocalOffset
+ | 60 SkPoint* coords = reinterpret_cast<SkPoint*>(vertices + kLocalOffset
+ |
| 59 i * vertexStride); | 61 i * vertexStride); |
| 60 *coords = localQuad->point(i); | 62 *coords = localQuad->point(i); |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 SkMatrix localMatrix = GrTest::TestMatrix(random); | 215 SkMatrix localMatrix = GrTest::TestMatrix(random); |
| 214 | 216 |
| 215 bool hasLocalRect = random->nextBool(); | 217 bool hasLocalRect = random->nextBool(); |
| 216 bool hasLocalMatrix = random->nextBool(); | 218 bool hasLocalMatrix = random->nextBool(); |
| 217 return GrNonAAFillRectBatch::Create(color, viewMatrix, rect, | 219 return GrNonAAFillRectBatch::Create(color, viewMatrix, rect, |
| 218 hasLocalRect ? &localRect : nullptr, | 220 hasLocalRect ? &localRect : nullptr, |
| 219 hasLocalMatrix ? &localMatrix : nullptr)
; | 221 hasLocalMatrix ? &localMatrix : nullptr)
; |
| 220 } | 222 } |
| 221 | 223 |
| 222 #endif | 224 #endif |
| OLD | NEW |