OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2010 Google Inc. | 3 * Copyright 2010 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "GrDrawTarget.h" | 9 #include "GrDrawTarget.h" |
10 | 10 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 fStartIndex += indexOffset; | 85 fStartIndex += indexOffset; |
86 SkASSERT(fStartIndex >= 0); | 86 SkASSERT(fStartIndex >= 0); |
87 } | 87 } |
88 | 88 |
89 //////////////////////////////////////////////////////////////////////////////// | 89 //////////////////////////////////////////////////////////////////////////////// |
90 | 90 |
91 #define DEBUG_INVAL_BUFFER 0xdeadcafe | 91 #define DEBUG_INVAL_BUFFER 0xdeadcafe |
92 #define DEBUG_INVAL_START_IDX -1 | 92 #define DEBUG_INVAL_START_IDX -1 |
93 | 93 |
94 GrDrawTarget::GrDrawTarget(GrContext* context) | 94 GrDrawTarget::GrDrawTarget(GrContext* context) |
95 : fClip(NULL) | 95 : fContext(context) |
96 , fContext(context) | |
97 , fGpuTraceMarkerCount(0) { | 96 , fGpuTraceMarkerCount(0) { |
98 SkASSERT(context); | 97 SkASSERT(context); |
99 GeometrySrcState& geoSrc = fGeoSrcStateStack.push_back(); | 98 GeometrySrcState& geoSrc = fGeoSrcStateStack.push_back(); |
100 #ifdef SK_DEBUG | 99 #ifdef SK_DEBUG |
101 geoSrc.fVertexCount = DEBUG_INVAL_START_IDX; | 100 geoSrc.fVertexCount = DEBUG_INVAL_START_IDX; |
102 geoSrc.fVertexBuffer = (GrVertexBuffer*)DEBUG_INVAL_BUFFER; | 101 geoSrc.fVertexBuffer = (GrVertexBuffer*)DEBUG_INVAL_BUFFER; |
103 geoSrc.fIndexCount = DEBUG_INVAL_START_IDX; | 102 geoSrc.fIndexCount = DEBUG_INVAL_START_IDX; |
104 geoSrc.fIndexBuffer = (GrIndexBuffer*)DEBUG_INVAL_BUFFER; | 103 geoSrc.fIndexBuffer = (GrIndexBuffer*)DEBUG_INVAL_BUFFER; |
105 #endif | 104 #endif |
106 geoSrc.fVertexSrc = kNone_GeometrySrcType; | 105 geoSrc.fVertexSrc = kNone_GeometrySrcType; |
(...skipping 10 matching lines...) Expand all Loading... |
117 void GrDrawTarget::releaseGeometry() { | 116 void GrDrawTarget::releaseGeometry() { |
118 int popCnt = fGeoSrcStateStack.count() - 1; | 117 int popCnt = fGeoSrcStateStack.count() - 1; |
119 while (popCnt) { | 118 while (popCnt) { |
120 this->popGeometrySource(); | 119 this->popGeometrySource(); |
121 --popCnt; | 120 --popCnt; |
122 } | 121 } |
123 this->resetVertexSource(); | 122 this->resetVertexSource(); |
124 this->resetIndexSource(); | 123 this->resetIndexSource(); |
125 } | 124 } |
126 | 125 |
127 void GrDrawTarget::setClip(const GrClipData* clip) { | |
128 fClip = clip; | |
129 } | |
130 | |
131 const GrClipData* GrDrawTarget::getClip() const { | |
132 return fClip; | |
133 } | |
134 | |
135 bool GrDrawTarget::reserveVertexSpace(size_t vertexSize, | 126 bool GrDrawTarget::reserveVertexSpace(size_t vertexSize, |
136 int vertexCount, | 127 int vertexCount, |
137 void** vertices) { | 128 void** vertices) { |
138 GeometrySrcState& geoSrc = fGeoSrcStateStack.back(); | 129 GeometrySrcState& geoSrc = fGeoSrcStateStack.back(); |
139 bool acquired = false; | 130 bool acquired = false; |
140 if (vertexCount > 0) { | 131 if (vertexCount > 0) { |
141 SkASSERT(vertices); | 132 SkASSERT(vertices); |
142 this->releasePreviousVertexSource(); | 133 this->releasePreviousVertexSource(); |
143 geoSrc.fVertexSrc = kNone_GeometrySrcType; | 134 geoSrc.fVertexSrc = kNone_GeometrySrcType; |
144 | 135 |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 | 379 |
389 bool GrDrawTarget::setupDstReadIfNecessary(const GrPipelineBuilder& pipelineBuil
der, | 380 bool GrDrawTarget::setupDstReadIfNecessary(const GrPipelineBuilder& pipelineBuil
der, |
390 const GrProcOptInfo& colorPOI, | 381 const GrProcOptInfo& colorPOI, |
391 const GrProcOptInfo& coveragePOI, | 382 const GrProcOptInfo& coveragePOI, |
392 GrDeviceCoordTexture* dstCopy, | 383 GrDeviceCoordTexture* dstCopy, |
393 const SkRect* drawBounds) { | 384 const SkRect* drawBounds) { |
394 if (!pipelineBuilder.willXPNeedDstCopy(*this->caps(), colorPOI, coveragePOI)
) { | 385 if (!pipelineBuilder.willXPNeedDstCopy(*this->caps(), colorPOI, coveragePOI)
) { |
395 return true; | 386 return true; |
396 } | 387 } |
397 SkIRect copyRect; | 388 SkIRect copyRect; |
398 const GrClipData* clip = this->getClip(); | |
399 GrRenderTarget* rt = pipelineBuilder.getRenderTarget(); | 389 GrRenderTarget* rt = pipelineBuilder.getRenderTarget(); |
400 clip->getConservativeBounds(rt, ©Rect); | 390 pipelineBuilder.clip().getConservativeBounds(rt, ©Rect); |
401 | 391 |
402 if (drawBounds) { | 392 if (drawBounds) { |
403 SkIRect drawIBounds; | 393 SkIRect drawIBounds; |
404 drawBounds->roundOut(&drawIBounds); | 394 drawBounds->roundOut(&drawIBounds); |
405 if (!copyRect.intersect(drawIBounds)) { | 395 if (!copyRect.intersect(drawIBounds)) { |
406 #ifdef SK_DEBUG | 396 #ifdef SK_DEBUG |
407 SkDebugf("Missed an early reject. Bailing on draw from setupDstReadI
fNecessary.\n"); | 397 SkDebugf("Missed an early reject. Bailing on draw from setupDstReadI
fNecessary.\n"); |
408 #endif | 398 #endif |
409 return false; | 399 return false; |
410 } | 400 } |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
872 } | 862 } |
873 if (fIndices) { | 863 if (fIndices) { |
874 fTarget->resetIndexSource(); | 864 fTarget->resetIndexSource(); |
875 } | 865 } |
876 fTarget = NULL; | 866 fTarget = NULL; |
877 } | 867 } |
878 fVertices = NULL; | 868 fVertices = NULL; |
879 fIndices = NULL; | 869 fIndices = NULL; |
880 } | 870 } |
881 | 871 |
882 GrDrawTarget::AutoClipRestore::AutoClipRestore(GrDrawTarget* target, const SkIRe
ct& newClip) { | |
883 fTarget = target; | |
884 fClip = fTarget->getClip(); | |
885 fStack.init(); | |
886 fStack.get()->clipDevRect(newClip, SkRegion::kReplace_Op); | |
887 fReplacementClip.fClipStack.reset(SkRef(fStack.get())); | |
888 target->setClip(&fReplacementClip); | |
889 } | |
890 | |
891 namespace { | 872 namespace { |
892 // returns true if the read/written rect intersects the src/dst and false if not
. | 873 // returns true if the read/written rect intersects the src/dst and false if not
. |
893 bool clip_srcrect_and_dstpoint(const GrSurface* dst, | 874 bool clip_srcrect_and_dstpoint(const GrSurface* dst, |
894 const GrSurface* src, | 875 const GrSurface* src, |
895 const SkIRect& srcRect, | 876 const SkIRect& srcRect, |
896 const SkIPoint& dstPoint, | 877 const SkIPoint& dstPoint, |
897 SkIRect* clippedSrcRect, | 878 SkIRect* clippedSrcRect, |
898 SkIPoint* clippedDstPoint) { | 879 SkIPoint* clippedDstPoint) { |
899 *clippedSrcRect = srcRect; | 880 *clippedSrcRect = srcRect; |
900 *clippedDstPoint = dstPoint; | 881 *clippedDstPoint = dstPoint; |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1288 | 1269 |
1289 bool GrClipTarget::setupClip(GrPipelineBuilder* pipelineBuilder, | 1270 bool GrClipTarget::setupClip(GrPipelineBuilder* pipelineBuilder, |
1290 GrPipelineBuilder::AutoRestoreEffects* are, | 1271 GrPipelineBuilder::AutoRestoreEffects* are, |
1291 GrPipelineBuilder::AutoRestoreStencil* ars, | 1272 GrPipelineBuilder::AutoRestoreStencil* ars, |
1292 GrScissorState* scissorState, | 1273 GrScissorState* scissorState, |
1293 const SkRect* devBounds) { | 1274 const SkRect* devBounds) { |
1294 return fClipMaskManager.setupClipping(pipelineBuilder, | 1275 return fClipMaskManager.setupClipping(pipelineBuilder, |
1295 are, | 1276 are, |
1296 ars, | 1277 ars, |
1297 scissorState, | 1278 scissorState, |
1298 this->getClip(), | |
1299 devBounds); | 1279 devBounds); |
1300 } | 1280 } |
OLD | NEW |