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 "GrBatchTest.h" | 8 #include "GrBatchTest.h" |
9 #include "GrColor.h" | 9 #include "GrColor.h" |
10 #include "GrDrawContext.h" | 10 #include "GrDrawContext.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 #include "effects/GrRRectEffect.h" | 31 #include "effects/GrRRectEffect.h" |
32 | 32 |
33 #include "instanced/InstancedRendering.h" | 33 #include "instanced/InstancedRendering.h" |
34 | 34 |
35 #include "text/GrAtlasTextContext.h" | 35 #include "text/GrAtlasTextContext.h" |
36 #include "text/GrStencilAndCoverTextContext.h" | 36 #include "text/GrStencilAndCoverTextContext.h" |
37 | 37 |
38 #include "../private/GrAuditTrail.h" | 38 #include "../private/GrAuditTrail.h" |
39 | 39 |
| 40 #include "SkGr.h" |
40 #include "SkLatticeIter.h" | 41 #include "SkLatticeIter.h" |
41 #include "SkMatrixPriv.h" | 42 #include "SkMatrixPriv.h" |
42 | 43 |
43 #define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == fDrawingM
anager->getContext()) | 44 #define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == fDrawingM
anager->getContext()) |
44 #define ASSERT_SINGLE_OWNER \ | 45 #define ASSERT_SINGLE_OWNER \ |
45 SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(fSingleOwner);) | 46 SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(fSingleOwner);) |
46 #define ASSERT_SINGLE_OWNER_PRIV \ | 47 #define ASSERT_SINGLE_OWNER_PRIV \ |
47 SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(fDrawContext->fSing
leOwner);) | 48 SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(fDrawContext->fSing
leOwner);) |
48 #define RETURN_IF_ABANDONED if (fDrawingManager->wasAbandoned()) { return
; } | 49 #define RETURN_IF_ABANDONED if (fDrawingManager->wasAbandoned()) { return
; } |
49 #define RETURN_IF_ABANDONED_PRIV if (fDrawContext->fDrawingManager->wasAbandon
ed()) { return; } | 50 #define RETURN_IF_ABANDONED_PRIV if (fDrawContext->fDrawingManager->wasAbandon
ed()) { return; } |
(...skipping 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1118 SkAutoTUnref<GrDrawBatch> batch( | 1119 SkAutoTUnref<GrDrawBatch> batch( |
1119 GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewMatrix, re
ct, localRect, | 1120 GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewMatrix, re
ct, localRect, |
1120 localMatrix)); | 1121 localMatrix)); |
1121 GrPipelineBuilder pipelineBuilder(paint, useHWAA); | 1122 GrPipelineBuilder pipelineBuilder(paint, useHWAA); |
1122 if (ss) { | 1123 if (ss) { |
1123 pipelineBuilder.setUserStencil(ss); | 1124 pipelineBuilder.setUserStencil(ss); |
1124 } | 1125 } |
1125 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); | 1126 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); |
1126 } | 1127 } |
1127 | 1128 |
| 1129 bool GrDrawContext::readPixels(const SkImageInfo& dstInfo, void* dstBuffer, size
_t dstRowBytes, |
| 1130 int x, int y) { |
| 1131 // TODO: teach fRenderTarget to take ImageInfo directly to specify the src p
ixels |
| 1132 GrPixelConfig config = SkImageInfo2GrPixelConfig(dstInfo, *fContext->caps())
; |
| 1133 if (kUnknown_GrPixelConfig == config) { |
| 1134 return false; |
| 1135 } |
| 1136 |
| 1137 uint32_t flags = 0; |
| 1138 if (kUnpremul_SkAlphaType == dstInfo.alphaType()) { |
| 1139 flags = GrContext::kUnpremul_PixelOpsFlag; |
| 1140 } |
| 1141 |
| 1142 return fRenderTarget->readPixels(x, y, dstInfo.width(), dstInfo.height(), |
| 1143 config, dstBuffer, dstRowBytes, flags); |
| 1144 } |
| 1145 |
| 1146 bool GrDrawContext::writePixels(const SkImageInfo& srcInfo, const void* srcBuffe
r, |
| 1147 size_t srcRowBytes, int x, int y) { |
| 1148 // TODO: teach fRenderTarget to take ImageInfo directly to specify the src p
ixels |
| 1149 GrPixelConfig config = SkImageInfo2GrPixelConfig(srcInfo, *fContext->caps())
; |
| 1150 if (kUnknown_GrPixelConfig == config) { |
| 1151 return false; |
| 1152 } |
| 1153 uint32_t flags = 0; |
| 1154 if (kUnpremul_SkAlphaType == srcInfo.alphaType()) { |
| 1155 flags = GrContext::kUnpremul_PixelOpsFlag; |
| 1156 } |
| 1157 |
| 1158 return fRenderTarget->writePixels(x, y, srcInfo.width(), srcInfo.height(), |
| 1159 config, srcBuffer, srcRowBytes, flags); |
| 1160 } |
| 1161 |
1128 // Can 'path' be drawn as a pair of filled nested rectangles? | 1162 // Can 'path' be drawn as a pair of filled nested rectangles? |
1129 static bool fills_as_nested_rects(const SkMatrix& viewMatrix, const SkPath& path
, SkRect rects[2]) { | 1163 static bool fills_as_nested_rects(const SkMatrix& viewMatrix, const SkPath& path
, SkRect rects[2]) { |
1130 | 1164 |
1131 if (path.isInverseFillType()) { | 1165 if (path.isInverseFillType()) { |
1132 return false; | 1166 return false; |
1133 } | 1167 } |
1134 | 1168 |
1135 // TODO: this restriction could be lifted if we were willing to apply | 1169 // TODO: this restriction could be lifted if we were willing to apply |
1136 // the matrix to all the points individually rather than just to the rect | 1170 // the matrix to all the points individually rather than just to the rect |
1137 if (!viewMatrix.rectStaysRect()) { | 1171 if (!viewMatrix.rectStaysRect()) { |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1383 | 1417 |
1384 void GrDrawContext::drawBatch(const GrPipelineBuilder& pipelineBuilder, const Gr
Clip& clip, | 1418 void GrDrawContext::drawBatch(const GrPipelineBuilder& pipelineBuilder, const Gr
Clip& clip, |
1385 GrDrawBatch* batch) { | 1419 GrDrawBatch* batch) { |
1386 ASSERT_SINGLE_OWNER | 1420 ASSERT_SINGLE_OWNER |
1387 RETURN_IF_ABANDONED | 1421 RETURN_IF_ABANDONED |
1388 SkDEBUGCODE(this->validate();) | 1422 SkDEBUGCODE(this->validate();) |
1389 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch"); | 1423 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch"); |
1390 | 1424 |
1391 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); | 1425 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); |
1392 } | 1426 } |
OLD | NEW |