| 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 "GrNinePatch.h" | 8 #include "GrNinePatch.h" |
| 9 | 9 |
| 10 #include "GrBatchFlushState.h" | 10 #include "GrBatchFlushState.h" |
| 11 #include "GrDefaultGeoProcFactory.h" | 11 #include "GrDefaultGeoProcFactory.h" |
| 12 #include "GrResourceProvider.h" | 12 #include "GrResourceProvider.h" |
| 13 #include "GrVertexBatch.h" | 13 #include "GrVertexBatch.h" |
| 14 #include "SkBitmap.h" | 14 #include "SkBitmap.h" |
| 15 #include "SkNinePatchIter.h" | 15 #include "SkLatticeIter.h" |
| 16 #include "SkRect.h" | 16 #include "SkRect.h" |
| 17 | 17 |
| 18 static sk_sp<GrGeometryProcessor> create_gp(bool readsCoverage) { | 18 static sk_sp<GrGeometryProcessor> create_gp(bool readsCoverage) { |
| 19 using namespace GrDefaultGeoProcFactory; | 19 using namespace GrDefaultGeoProcFactory; |
| 20 Color color(Color::kAttribute_Type); | 20 Color color(Color::kAttribute_Type); |
| 21 Coverage coverage(readsCoverage ? Coverage::kSolid_Type : Coverage::kNone_Ty
pe); | 21 Coverage coverage(readsCoverage ? Coverage::kSolid_Type : Coverage::kNone_Ty
pe); |
| 22 LocalCoords localCoords(LocalCoords::kHasExplicit_Type); | 22 LocalCoords localCoords(LocalCoords::kHasExplicit_Type); |
| 23 return GrDefaultGeoProcFactory::Make(color, coverage, localCoords, SkMatrix:
:I()); | 23 return GrDefaultGeoProcFactory::Make(color, coverage, localCoords, SkMatrix:
:I()); |
| 24 } | 24 } |
| 25 | 25 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 if (!vertices || !indexBuffer) { | 94 if (!vertices || !indexBuffer) { |
| 95 SkDebugf("Could not allocate vertices\n"); | 95 SkDebugf("Could not allocate vertices\n"); |
| 96 return; | 96 return; |
| 97 } | 97 } |
| 98 | 98 |
| 99 for (int i = 0; i < patchCnt; i++) { | 99 for (int i = 0; i < patchCnt; i++) { |
| 100 intptr_t verts = reinterpret_cast<intptr_t>(vertices) + | 100 intptr_t verts = reinterpret_cast<intptr_t>(vertices) + |
| 101 i * kRectsPerInstance * kVertsPerRect * vertexStrid
e; | 101 i * kRectsPerInstance * kVertsPerRect * vertexStrid
e; |
| 102 | 102 |
| 103 const Patch& patch = fPatches[i]; | 103 const Patch& patch = fPatches[i]; |
| 104 SkNinePatchIter iter(fImageWidth, fImageHeight, patch.fCenter, patch
.fDst); | 104 SkLatticeIter iter(fImageWidth, fImageHeight, patch.fCenter, patch.f
Dst); |
| 105 | 105 |
| 106 SkRect srcR, dstR; | 106 SkRect srcR, dstR; |
| 107 while (iter.next(&srcR, &dstR)) { | 107 while (iter.next(&srcR, &dstR)) { |
| 108 SkPoint* positions = reinterpret_cast<SkPoint*>(verts); | 108 SkPoint* positions = reinterpret_cast<SkPoint*>(verts); |
| 109 | 109 |
| 110 positions->setRectFan(dstR.fLeft, dstR.fTop, | 110 positions->setRectFan(dstR.fLeft, dstR.fTop, |
| 111 dstR.fRight, dstR.fBottom, vertexStride); | 111 dstR.fRight, dstR.fBottom, vertexStride); |
| 112 | 112 |
| 113 SkASSERT(!patch.fViewMatrix.hasPerspective()); | 113 SkASSERT(!patch.fViewMatrix.hasPerspective()); |
| 114 patch.fViewMatrix.mapPointsWithStride(positions, vertexStride, k
VertsPerRect); | 114 patch.fViewMatrix.mapPointsWithStride(positions, vertexStride, k
VertsPerRect); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 | 170 |
| 171 typedef GrVertexBatch INHERITED; | 171 typedef GrVertexBatch INHERITED; |
| 172 }; | 172 }; |
| 173 | 173 |
| 174 namespace GrNinePatch { | 174 namespace GrNinePatch { |
| 175 GrDrawBatch* CreateNonAA(GrColor color, const SkMatrix& viewMatrix, int imageWid
th, int imageHeight, | 175 GrDrawBatch* CreateNonAA(GrColor color, const SkMatrix& viewMatrix, int imageWid
th, int imageHeight, |
| 176 const SkIRect& center, const SkRect& dst) { | 176 const SkIRect& center, const SkRect& dst) { |
| 177 return new GrNonAANinePatchBatch(color, viewMatrix, imageWidth, imageHeight,
center, dst); | 177 return new GrNonAANinePatchBatch(color, viewMatrix, imageWidth, imageHeight,
center, dst); |
| 178 } | 178 } |
| 179 }; | 179 }; |
| OLD | NEW |