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 | 9 |
10 | 10 |
(...skipping 15 matching lines...) Expand all Loading... |
26 fStartVertex = di.fStartVertex; | 26 fStartVertex = di.fStartVertex; |
27 fStartIndex = di.fStartIndex; | 27 fStartIndex = di.fStartIndex; |
28 fVertexCount = di.fVertexCount; | 28 fVertexCount = di.fVertexCount; |
29 fIndexCount = di.fIndexCount; | 29 fIndexCount = di.fIndexCount; |
30 | 30 |
31 fInstanceCount = di.fInstanceCount; | 31 fInstanceCount = di.fInstanceCount; |
32 fVerticesPerInstance = di.fVerticesPerInstance; | 32 fVerticesPerInstance = di.fVerticesPerInstance; |
33 fIndicesPerInstance = di.fIndicesPerInstance; | 33 fIndicesPerInstance = di.fIndicesPerInstance; |
34 | 34 |
35 if (NULL != di.fDevBounds) { | 35 if (NULL != di.fDevBounds) { |
36 GrAssert(di.fDevBounds == &di.fDevBoundsStorage); | 36 SkASSERT(di.fDevBounds == &di.fDevBoundsStorage); |
37 fDevBoundsStorage = di.fDevBoundsStorage; | 37 fDevBoundsStorage = di.fDevBoundsStorage; |
38 fDevBounds = &fDevBoundsStorage; | 38 fDevBounds = &fDevBoundsStorage; |
39 } else { | 39 } else { |
40 fDevBounds = NULL; | 40 fDevBounds = NULL; |
41 } | 41 } |
42 | 42 |
43 fDstCopy = di.fDstCopy; | 43 fDstCopy = di.fDstCopy; |
44 | 44 |
45 return *this; | 45 return *this; |
46 } | 46 } |
47 | 47 |
48 #if GR_DEBUG | 48 #if GR_DEBUG |
49 bool GrDrawTarget::DrawInfo::isInstanced() const { | 49 bool GrDrawTarget::DrawInfo::isInstanced() const { |
50 if (fInstanceCount > 0) { | 50 if (fInstanceCount > 0) { |
51 GrAssert(0 == fIndexCount % fIndicesPerInstance); | 51 SkASSERT(0 == fIndexCount % fIndicesPerInstance); |
52 GrAssert(0 == fVertexCount % fVerticesPerInstance); | 52 SkASSERT(0 == fVertexCount % fVerticesPerInstance); |
53 GrAssert(fIndexCount / fIndicesPerInstance == fInstanceCount); | 53 SkASSERT(fIndexCount / fIndicesPerInstance == fInstanceCount); |
54 GrAssert(fVertexCount / fVerticesPerInstance == fInstanceCount); | 54 SkASSERT(fVertexCount / fVerticesPerInstance == fInstanceCount); |
55 // there is no way to specify a non-zero start index to drawIndexedInsta
nces(). | 55 // there is no way to specify a non-zero start index to drawIndexedInsta
nces(). |
56 GrAssert(0 == fStartIndex); | 56 SkASSERT(0 == fStartIndex); |
57 return true; | 57 return true; |
58 } else { | 58 } else { |
59 GrAssert(!fVerticesPerInstance); | 59 SkASSERT(!fVerticesPerInstance); |
60 GrAssert(!fIndicesPerInstance); | 60 SkASSERT(!fIndicesPerInstance); |
61 return false; | 61 return false; |
62 } | 62 } |
63 } | 63 } |
64 #endif | 64 #endif |
65 | 65 |
66 void GrDrawTarget::DrawInfo::adjustInstanceCount(int instanceOffset) { | 66 void GrDrawTarget::DrawInfo::adjustInstanceCount(int instanceOffset) { |
67 GrAssert(this->isInstanced()); | 67 SkASSERT(this->isInstanced()); |
68 GrAssert(instanceOffset + fInstanceCount >= 0); | 68 SkASSERT(instanceOffset + fInstanceCount >= 0); |
69 fInstanceCount += instanceOffset; | 69 fInstanceCount += instanceOffset; |
70 fVertexCount = fVerticesPerInstance * fInstanceCount; | 70 fVertexCount = fVerticesPerInstance * fInstanceCount; |
71 fIndexCount = fIndicesPerInstance * fInstanceCount; | 71 fIndexCount = fIndicesPerInstance * fInstanceCount; |
72 } | 72 } |
73 | 73 |
74 void GrDrawTarget::DrawInfo::adjustStartVertex(int vertexOffset) { | 74 void GrDrawTarget::DrawInfo::adjustStartVertex(int vertexOffset) { |
75 fStartVertex += vertexOffset; | 75 fStartVertex += vertexOffset; |
76 GrAssert(fStartVertex >= 0); | 76 SkASSERT(fStartVertex >= 0); |
77 } | 77 } |
78 | 78 |
79 void GrDrawTarget::DrawInfo::adjustStartIndex(int indexOffset) { | 79 void GrDrawTarget::DrawInfo::adjustStartIndex(int indexOffset) { |
80 GrAssert(this->isIndexed()); | 80 SkASSERT(this->isIndexed()); |
81 fStartIndex += indexOffset; | 81 fStartIndex += indexOffset; |
82 GrAssert(fStartIndex >= 0); | 82 SkASSERT(fStartIndex >= 0); |
83 } | 83 } |
84 | 84 |
85 //////////////////////////////////////////////////////////////////////////////// | 85 //////////////////////////////////////////////////////////////////////////////// |
86 | 86 |
87 #define DEBUG_INVAL_BUFFER 0xdeadcafe | 87 #define DEBUG_INVAL_BUFFER 0xdeadcafe |
88 #define DEBUG_INVAL_START_IDX -1 | 88 #define DEBUG_INVAL_START_IDX -1 |
89 | 89 |
90 GrDrawTarget::GrDrawTarget(GrContext* context) | 90 GrDrawTarget::GrDrawTarget(GrContext* context) |
91 : fClip(NULL) | 91 : fClip(NULL) |
92 , fContext(context) { | 92 , fContext(context) { |
93 GrAssert(NULL != context); | 93 SkASSERT(NULL != context); |
94 | 94 |
95 fDrawState = &fDefaultDrawState; | 95 fDrawState = &fDefaultDrawState; |
96 // We assume that fDrawState always owns a ref to the object it points at. | 96 // We assume that fDrawState always owns a ref to the object it points at. |
97 fDefaultDrawState.ref(); | 97 fDefaultDrawState.ref(); |
98 GeometrySrcState& geoSrc = fGeoSrcStateStack.push_back(); | 98 GeometrySrcState& geoSrc = fGeoSrcStateStack.push_back(); |
99 #if GR_DEBUG | 99 #if GR_DEBUG |
100 geoSrc.fVertexCount = DEBUG_INVAL_START_IDX; | 100 geoSrc.fVertexCount = DEBUG_INVAL_START_IDX; |
101 geoSrc.fVertexBuffer = (GrVertexBuffer*)DEBUG_INVAL_BUFFER; | 101 geoSrc.fVertexBuffer = (GrVertexBuffer*)DEBUG_INVAL_BUFFER; |
102 geoSrc.fIndexCount = DEBUG_INVAL_START_IDX; | 102 geoSrc.fIndexCount = DEBUG_INVAL_START_IDX; |
103 geoSrc.fIndexBuffer = (GrIndexBuffer*)DEBUG_INVAL_BUFFER; | 103 geoSrc.fIndexBuffer = (GrIndexBuffer*)DEBUG_INVAL_BUFFER; |
104 #endif | 104 #endif |
105 geoSrc.fVertexSrc = kNone_GeometrySrcType; | 105 geoSrc.fVertexSrc = kNone_GeometrySrcType; |
106 geoSrc.fIndexSrc = kNone_GeometrySrcType; | 106 geoSrc.fIndexSrc = kNone_GeometrySrcType; |
107 } | 107 } |
108 | 108 |
109 GrDrawTarget::~GrDrawTarget() { | 109 GrDrawTarget::~GrDrawTarget() { |
110 GrAssert(1 == fGeoSrcStateStack.count()); | 110 SkASSERT(1 == fGeoSrcStateStack.count()); |
111 SkDEBUGCODE(GeometrySrcState& geoSrc = fGeoSrcStateStack.back()); | 111 SkDEBUGCODE(GeometrySrcState& geoSrc = fGeoSrcStateStack.back()); |
112 GrAssert(kNone_GeometrySrcType == geoSrc.fIndexSrc); | 112 SkASSERT(kNone_GeometrySrcType == geoSrc.fIndexSrc); |
113 GrAssert(kNone_GeometrySrcType == geoSrc.fVertexSrc); | 113 SkASSERT(kNone_GeometrySrcType == geoSrc.fVertexSrc); |
114 fDrawState->unref(); | 114 fDrawState->unref(); |
115 } | 115 } |
116 | 116 |
117 void GrDrawTarget::releaseGeometry() { | 117 void GrDrawTarget::releaseGeometry() { |
118 int popCnt = fGeoSrcStateStack.count() - 1; | 118 int popCnt = fGeoSrcStateStack.count() - 1; |
119 while (popCnt) { | 119 while (popCnt) { |
120 this->popGeometrySource(); | 120 this->popGeometrySource(); |
121 --popCnt; | 121 --popCnt; |
122 } | 122 } |
123 this->resetVertexSource(); | 123 this->resetVertexSource(); |
124 this->resetIndexSource(); | 124 this->resetIndexSource(); |
125 } | 125 } |
126 | 126 |
127 void GrDrawTarget::setClip(const GrClipData* clip) { | 127 void GrDrawTarget::setClip(const GrClipData* clip) { |
128 clipWillBeSet(clip); | 128 clipWillBeSet(clip); |
129 fClip = clip; | 129 fClip = clip; |
130 } | 130 } |
131 | 131 |
132 const GrClipData* GrDrawTarget::getClip() const { | 132 const GrClipData* GrDrawTarget::getClip() const { |
133 return fClip; | 133 return fClip; |
134 } | 134 } |
135 | 135 |
136 void GrDrawTarget::setDrawState(GrDrawState* drawState) { | 136 void GrDrawTarget::setDrawState(GrDrawState* drawState) { |
137 GrAssert(NULL != fDrawState); | 137 SkASSERT(NULL != fDrawState); |
138 if (NULL == drawState) { | 138 if (NULL == drawState) { |
139 drawState = &fDefaultDrawState; | 139 drawState = &fDefaultDrawState; |
140 } | 140 } |
141 if (fDrawState != drawState) { | 141 if (fDrawState != drawState) { |
142 fDrawState->unref(); | 142 fDrawState->unref(); |
143 drawState->ref(); | 143 drawState->ref(); |
144 fDrawState = drawState; | 144 fDrawState = drawState; |
145 } | 145 } |
146 } | 146 } |
147 | 147 |
148 bool GrDrawTarget::reserveVertexSpace(size_t vertexSize, | 148 bool GrDrawTarget::reserveVertexSpace(size_t vertexSize, |
149 int vertexCount, | 149 int vertexCount, |
150 void** vertices) { | 150 void** vertices) { |
151 GeometrySrcState& geoSrc = fGeoSrcStateStack.back(); | 151 GeometrySrcState& geoSrc = fGeoSrcStateStack.back(); |
152 bool acquired = false; | 152 bool acquired = false; |
153 if (vertexCount > 0) { | 153 if (vertexCount > 0) { |
154 GrAssert(NULL != vertices); | 154 SkASSERT(NULL != vertices); |
155 this->releasePreviousVertexSource(); | 155 this->releasePreviousVertexSource(); |
156 geoSrc.fVertexSrc = kNone_GeometrySrcType; | 156 geoSrc.fVertexSrc = kNone_GeometrySrcType; |
157 | 157 |
158 acquired = this->onReserveVertexSpace(vertexSize, | 158 acquired = this->onReserveVertexSpace(vertexSize, |
159 vertexCount, | 159 vertexCount, |
160 vertices); | 160 vertices); |
161 } | 161 } |
162 if (acquired) { | 162 if (acquired) { |
163 geoSrc.fVertexSrc = kReserved_GeometrySrcType; | 163 geoSrc.fVertexSrc = kReserved_GeometrySrcType; |
164 geoSrc.fVertexCount = vertexCount; | 164 geoSrc.fVertexCount = vertexCount; |
165 geoSrc.fVertexSize = vertexSize; | 165 geoSrc.fVertexSize = vertexSize; |
166 } else if (NULL != vertices) { | 166 } else if (NULL != vertices) { |
167 *vertices = NULL; | 167 *vertices = NULL; |
168 } | 168 } |
169 return acquired; | 169 return acquired; |
170 } | 170 } |
171 | 171 |
172 bool GrDrawTarget::reserveIndexSpace(int indexCount, | 172 bool GrDrawTarget::reserveIndexSpace(int indexCount, |
173 void** indices) { | 173 void** indices) { |
174 GeometrySrcState& geoSrc = fGeoSrcStateStack.back(); | 174 GeometrySrcState& geoSrc = fGeoSrcStateStack.back(); |
175 bool acquired = false; | 175 bool acquired = false; |
176 if (indexCount > 0) { | 176 if (indexCount > 0) { |
177 GrAssert(NULL != indices); | 177 SkASSERT(NULL != indices); |
178 this->releasePreviousIndexSource(); | 178 this->releasePreviousIndexSource(); |
179 geoSrc.fIndexSrc = kNone_GeometrySrcType; | 179 geoSrc.fIndexSrc = kNone_GeometrySrcType; |
180 | 180 |
181 acquired = this->onReserveIndexSpace(indexCount, indices); | 181 acquired = this->onReserveIndexSpace(indexCount, indices); |
182 } | 182 } |
183 if (acquired) { | 183 if (acquired) { |
184 geoSrc.fIndexSrc = kReserved_GeometrySrcType; | 184 geoSrc.fIndexSrc = kReserved_GeometrySrcType; |
185 geoSrc.fIndexCount = indexCount; | 185 geoSrc.fIndexCount = indexCount; |
186 } else if (NULL != indices) { | 186 } else if (NULL != indices) { |
187 *indices = NULL; | 187 *indices = NULL; |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 #if GR_DEBUG | 328 #if GR_DEBUG |
329 newState.fVertexCount = ~0; | 329 newState.fVertexCount = ~0; |
330 newState.fVertexBuffer = (GrVertexBuffer*)~0; | 330 newState.fVertexBuffer = (GrVertexBuffer*)~0; |
331 newState.fIndexCount = ~0; | 331 newState.fIndexCount = ~0; |
332 newState.fIndexBuffer = (GrIndexBuffer*)~0; | 332 newState.fIndexBuffer = (GrIndexBuffer*)~0; |
333 #endif | 333 #endif |
334 } | 334 } |
335 | 335 |
336 void GrDrawTarget::popGeometrySource() { | 336 void GrDrawTarget::popGeometrySource() { |
337 // if popping last element then pops are unbalanced with pushes | 337 // if popping last element then pops are unbalanced with pushes |
338 GrAssert(fGeoSrcStateStack.count() > 1); | 338 SkASSERT(fGeoSrcStateStack.count() > 1); |
339 | 339 |
340 this->geometrySourceWillPop(fGeoSrcStateStack.fromBack(1)); | 340 this->geometrySourceWillPop(fGeoSrcStateStack.fromBack(1)); |
341 this->releasePreviousVertexSource(); | 341 this->releasePreviousVertexSource(); |
342 this->releasePreviousIndexSource(); | 342 this->releasePreviousIndexSource(); |
343 fGeoSrcStateStack.pop_back(); | 343 fGeoSrcStateStack.pop_back(); |
344 } | 344 } |
345 | 345 |
346 //////////////////////////////////////////////////////////////////////////////// | 346 //////////////////////////////////////////////////////////////////////////////// |
347 | 347 |
348 bool GrDrawTarget::checkDraw(GrPrimitiveType type, int startVertex, | 348 bool GrDrawTarget::checkDraw(GrPrimitiveType type, int startVertex, |
(...skipping 30 matching lines...) Expand all Loading... |
379 break; | 379 break; |
380 case kBuffer_GeometrySrcType: | 380 case kBuffer_GeometrySrcType: |
381 maxValidIndex = geoSrc.fIndexBuffer->sizeInBytes() / sizeof(uint
16_t); | 381 maxValidIndex = geoSrc.fIndexBuffer->sizeInBytes() / sizeof(uint
16_t); |
382 break; | 382 break; |
383 } | 383 } |
384 if (maxIndex > maxValidIndex) { | 384 if (maxIndex > maxValidIndex) { |
385 GrCrash("Index reads outside valid index range."); | 385 GrCrash("Index reads outside valid index range."); |
386 } | 386 } |
387 } | 387 } |
388 | 388 |
389 GrAssert(NULL != drawState.getRenderTarget()); | 389 SkASSERT(NULL != drawState.getRenderTarget()); |
390 | 390 |
391 for (int s = 0; s < drawState.numColorStages(); ++s) { | 391 for (int s = 0; s < drawState.numColorStages(); ++s) { |
392 const GrEffectRef& effect = *drawState.getColorStage(s).getEffect(); | 392 const GrEffectRef& effect = *drawState.getColorStage(s).getEffect(); |
393 int numTextures = effect->numTextures(); | 393 int numTextures = effect->numTextures(); |
394 for (int t = 0; t < numTextures; ++t) { | 394 for (int t = 0; t < numTextures; ++t) { |
395 GrTexture* texture = effect->texture(t); | 395 GrTexture* texture = effect->texture(t); |
396 GrAssert(texture->asRenderTarget() != drawState.getRenderTarget()); | 396 SkASSERT(texture->asRenderTarget() != drawState.getRenderTarget()); |
397 } | 397 } |
398 } | 398 } |
399 for (int s = 0; s < drawState.numCoverageStages(); ++s) { | 399 for (int s = 0; s < drawState.numCoverageStages(); ++s) { |
400 const GrEffectRef& effect = *drawState.getCoverageStage(s).getEffect(); | 400 const GrEffectRef& effect = *drawState.getCoverageStage(s).getEffect(); |
401 int numTextures = effect->numTextures(); | 401 int numTextures = effect->numTextures(); |
402 for (int t = 0; t < numTextures; ++t) { | 402 for (int t = 0; t < numTextures; ++t) { |
403 GrTexture* texture = effect->texture(t); | 403 GrTexture* texture = effect->texture(t); |
404 GrAssert(texture->asRenderTarget() != drawState.getRenderTarget()); | 404 SkASSERT(texture->asRenderTarget() != drawState.getRenderTarget()); |
405 } | 405 } |
406 } | 406 } |
407 | 407 |
408 GrAssert(drawState.validateVertexAttribs()); | 408 SkASSERT(drawState.validateVertexAttribs()); |
409 #endif | 409 #endif |
410 if (NULL == drawState.getRenderTarget()) { | 410 if (NULL == drawState.getRenderTarget()) { |
411 return false; | 411 return false; |
412 } | 412 } |
413 return true; | 413 return true; |
414 } | 414 } |
415 | 415 |
416 bool GrDrawTarget::setupDstReadIfNecessary(DrawInfo* info) { | 416 bool GrDrawTarget::setupDstReadIfNecessary(DrawInfo* info) { |
417 if (this->caps()->dstReadInShaderSupport() || !this->getDrawState().willEffe
ctReadDstColor()) { | 417 if (this->caps()->dstReadInShaderSupport() || !this->getDrawState().willEffe
ctReadDstColor()) { |
418 return true; | 418 return true; |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 // TODO: We should continue with incorrect blending. | 510 // TODO: We should continue with incorrect blending. |
511 if (!this->setupDstReadIfNecessary(&info)) { | 511 if (!this->setupDstReadIfNecessary(&info)) { |
512 return; | 512 return; |
513 } | 513 } |
514 this->onDraw(info); | 514 this->onDraw(info); |
515 } | 515 } |
516 } | 516 } |
517 | 517 |
518 void GrDrawTarget::stencilPath(const GrPath* path, const SkStrokeRec& stroke, Sk
Path::FillType fill) { | 518 void GrDrawTarget::stencilPath(const GrPath* path, const SkStrokeRec& stroke, Sk
Path::FillType fill) { |
519 // TODO: extract portions of checkDraw that are relevant to path stenciling. | 519 // TODO: extract portions of checkDraw that are relevant to path stenciling. |
520 GrAssert(NULL != path); | 520 SkASSERT(NULL != path); |
521 GrAssert(this->caps()->pathStencilingSupport()); | 521 SkASSERT(this->caps()->pathStencilingSupport()); |
522 GrAssert(!stroke.isHairlineStyle()); | 522 SkASSERT(!stroke.isHairlineStyle()); |
523 GrAssert(!SkPath::IsInverseFillType(fill)); | 523 SkASSERT(!SkPath::IsInverseFillType(fill)); |
524 this->onStencilPath(path, stroke, fill); | 524 this->onStencilPath(path, stroke, fill); |
525 } | 525 } |
526 | 526 |
527 //////////////////////////////////////////////////////////////////////////////// | 527 //////////////////////////////////////////////////////////////////////////////// |
528 | 528 |
529 bool GrDrawTarget::willUseHWAALines() const { | 529 bool GrDrawTarget::willUseHWAALines() const { |
530 // There is a conflict between using smooth lines and our use of premultipli
ed alpha. Smooth | 530 // There is a conflict between using smooth lines and our use of premultipli
ed alpha. Smooth |
531 // lines tweak the incoming alpha value but not in a premul-alpha way. So we
only use them when | 531 // lines tweak the incoming alpha value but not in a premul-alpha way. So we
only use them when |
532 // our alpha is 0xff and tweaking the color for partial coverage is OK | 532 // our alpha is 0xff and tweaking the color for partial coverage is OK |
533 if (!this->caps()->hwAALineSupport() || | 533 if (!this->caps()->hwAALineSupport() || |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 } | 671 } |
672 | 672 |
673 GrDrawTarget::AutoStateRestore::~AutoStateRestore() { | 673 GrDrawTarget::AutoStateRestore::~AutoStateRestore() { |
674 if (NULL != fDrawTarget) { | 674 if (NULL != fDrawTarget) { |
675 fDrawTarget->setDrawState(fSavedState); | 675 fDrawTarget->setDrawState(fSavedState); |
676 fSavedState->unref(); | 676 fSavedState->unref(); |
677 } | 677 } |
678 } | 678 } |
679 | 679 |
680 void GrDrawTarget::AutoStateRestore::set(GrDrawTarget* target, ASRInit init, con
st SkMatrix* vm) { | 680 void GrDrawTarget::AutoStateRestore::set(GrDrawTarget* target, ASRInit init, con
st SkMatrix* vm) { |
681 GrAssert(NULL == fDrawTarget); | 681 SkASSERT(NULL == fDrawTarget); |
682 fDrawTarget = target; | 682 fDrawTarget = target; |
683 fSavedState = target->drawState(); | 683 fSavedState = target->drawState(); |
684 GrAssert(fSavedState); | 684 SkASSERT(fSavedState); |
685 fSavedState->ref(); | 685 fSavedState->ref(); |
686 if (kReset_ASRInit == init) { | 686 if (kReset_ASRInit == init) { |
687 if (NULL == vm) { | 687 if (NULL == vm) { |
688 // calls the default cons | 688 // calls the default cons |
689 fTempState.init(); | 689 fTempState.init(); |
690 } else { | 690 } else { |
691 SkNEW_IN_TLAZY(&fTempState, GrDrawState, (*vm)); | 691 SkNEW_IN_TLAZY(&fTempState, GrDrawState, (*vm)); |
692 } | 692 } |
693 } else { | 693 } else { |
694 GrAssert(kPreserve_ASRInit == init); | 694 SkASSERT(kPreserve_ASRInit == init); |
695 if (NULL == vm) { | 695 if (NULL == vm) { |
696 fTempState.set(*fSavedState); | 696 fTempState.set(*fSavedState); |
697 } else { | 697 } else { |
698 SkNEW_IN_TLAZY(&fTempState, GrDrawState, (*fSavedState, *vm)); | 698 SkNEW_IN_TLAZY(&fTempState, GrDrawState, (*fSavedState, *vm)); |
699 } | 699 } |
700 } | 700 } |
701 target->setDrawState(fTempState.get()); | 701 target->setDrawState(fTempState.get()); |
702 } | 702 } |
703 | 703 |
704 bool GrDrawTarget::AutoStateRestore::setIdentity(GrDrawTarget* target, ASRInit i
nit) { | 704 bool GrDrawTarget::AutoStateRestore::setIdentity(GrDrawTarget* target, ASRInit i
nit) { |
705 GrAssert(NULL == fDrawTarget); | 705 SkASSERT(NULL == fDrawTarget); |
706 fDrawTarget = target; | 706 fDrawTarget = target; |
707 fSavedState = target->drawState(); | 707 fSavedState = target->drawState(); |
708 GrAssert(fSavedState); | 708 SkASSERT(fSavedState); |
709 fSavedState->ref(); | 709 fSavedState->ref(); |
710 if (kReset_ASRInit == init) { | 710 if (kReset_ASRInit == init) { |
711 // calls the default cons | 711 // calls the default cons |
712 fTempState.init(); | 712 fTempState.init(); |
713 } else { | 713 } else { |
714 GrAssert(kPreserve_ASRInit == init); | 714 SkASSERT(kPreserve_ASRInit == init); |
715 // calls the copy cons | 715 // calls the copy cons |
716 fTempState.set(*fSavedState); | 716 fTempState.set(*fSavedState); |
717 if (!fTempState.get()->setIdentityViewMatrix()) { | 717 if (!fTempState.get()->setIdentityViewMatrix()) { |
718 // let go of any resources held by the temp | 718 // let go of any resources held by the temp |
719 fTempState.get()->reset(); | 719 fTempState.get()->reset(); |
720 fDrawTarget = NULL; | 720 fDrawTarget = NULL; |
721 fSavedState->unref(); | 721 fSavedState->unref(); |
722 fSavedState = NULL; | 722 fSavedState = NULL; |
723 return false; | 723 return false; |
724 } | 724 } |
(...skipping 30 matching lines...) Expand all Loading... |
755 fTarget = target; | 755 fTarget = target; |
756 success = target->reserveVertexAndIndexSpace(vertexCount, | 756 success = target->reserveVertexAndIndexSpace(vertexCount, |
757 indexCount, | 757 indexCount, |
758 &fVertices, | 758 &fVertices, |
759 &fIndices); | 759 &fIndices); |
760 if (!success) { | 760 if (!success) { |
761 fTarget = NULL; | 761 fTarget = NULL; |
762 this->reset(); | 762 this->reset(); |
763 } | 763 } |
764 } | 764 } |
765 GrAssert(success == (NULL != fTarget)); | 765 SkASSERT(success == (NULL != fTarget)); |
766 return success; | 766 return success; |
767 } | 767 } |
768 | 768 |
769 void GrDrawTarget::AutoReleaseGeometry::reset() { | 769 void GrDrawTarget::AutoReleaseGeometry::reset() { |
770 if (NULL != fTarget) { | 770 if (NULL != fTarget) { |
771 if (NULL != fVertices) { | 771 if (NULL != fVertices) { |
772 fTarget->resetVertexSource(); | 772 fTarget->resetVertexSource(); |
773 } | 773 } |
774 if (NULL != fIndices) { | 774 if (NULL != fIndices) { |
775 fTarget->resetIndexSource(); | 775 fTarget->resetIndexSource(); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
839 // The above clipping steps may have inverted the rect if it didn't intersec
t either the src or | 839 // The above clipping steps may have inverted the rect if it didn't intersec
t either the src or |
840 // dst bounds. | 840 // dst bounds. |
841 return !clippedSrcRect->isEmpty(); | 841 return !clippedSrcRect->isEmpty(); |
842 } | 842 } |
843 } | 843 } |
844 | 844 |
845 bool GrDrawTarget::copySurface(GrSurface* dst, | 845 bool GrDrawTarget::copySurface(GrSurface* dst, |
846 GrSurface* src, | 846 GrSurface* src, |
847 const SkIRect& srcRect, | 847 const SkIRect& srcRect, |
848 const SkIPoint& dstPoint) { | 848 const SkIPoint& dstPoint) { |
849 GrAssert(NULL != dst); | 849 SkASSERT(NULL != dst); |
850 GrAssert(NULL != src); | 850 SkASSERT(NULL != src); |
851 | 851 |
852 SkIRect clippedSrcRect; | 852 SkIRect clippedSrcRect; |
853 SkIPoint clippedDstPoint; | 853 SkIPoint clippedDstPoint; |
854 // If the rect is outside the src or dst then we've already succeeded. | 854 // If the rect is outside the src or dst then we've already succeeded. |
855 if (!clip_srcrect_and_dstpoint(dst, | 855 if (!clip_srcrect_and_dstpoint(dst, |
856 src, | 856 src, |
857 srcRect, | 857 srcRect, |
858 dstPoint, | 858 dstPoint, |
859 &clippedSrcRect, | 859 &clippedSrcRect, |
860 &clippedDstPoint)) { | 860 &clippedDstPoint)) { |
861 GrAssert(this->canCopySurface(dst, src, srcRect, dstPoint)); | 861 SkASSERT(this->canCopySurface(dst, src, srcRect, dstPoint)); |
862 return true; | 862 return true; |
863 } | 863 } |
864 | 864 |
865 bool result = this->onCopySurface(dst, src, clippedSrcRect, clippedDstPoint)
; | 865 bool result = this->onCopySurface(dst, src, clippedSrcRect, clippedDstPoint)
; |
866 GrAssert(result == this->canCopySurface(dst, src, clippedSrcRect, clippedDst
Point)); | 866 SkASSERT(result == this->canCopySurface(dst, src, clippedSrcRect, clippedDst
Point)); |
867 return result; | 867 return result; |
868 } | 868 } |
869 | 869 |
870 bool GrDrawTarget::canCopySurface(GrSurface* dst, | 870 bool GrDrawTarget::canCopySurface(GrSurface* dst, |
871 GrSurface* src, | 871 GrSurface* src, |
872 const SkIRect& srcRect, | 872 const SkIRect& srcRect, |
873 const SkIPoint& dstPoint) { | 873 const SkIPoint& dstPoint) { |
874 GrAssert(NULL != dst); | 874 SkASSERT(NULL != dst); |
875 GrAssert(NULL != src); | 875 SkASSERT(NULL != src); |
876 | 876 |
877 SkIRect clippedSrcRect; | 877 SkIRect clippedSrcRect; |
878 SkIPoint clippedDstPoint; | 878 SkIPoint clippedDstPoint; |
879 // If the rect is outside the src or dst then we're guaranteed success | 879 // If the rect is outside the src or dst then we're guaranteed success |
880 if (!clip_srcrect_and_dstpoint(dst, | 880 if (!clip_srcrect_and_dstpoint(dst, |
881 src, | 881 src, |
882 srcRect, | 882 srcRect, |
883 dstPoint, | 883 dstPoint, |
884 &clippedSrcRect, | 884 &clippedSrcRect, |
885 &clippedDstPoint)) { | 885 &clippedDstPoint)) { |
886 return true; | 886 return true; |
887 } | 887 } |
888 return this->onCanCopySurface(dst, src, clippedSrcRect, clippedDstPoint); | 888 return this->onCanCopySurface(dst, src, clippedSrcRect, clippedDstPoint); |
889 } | 889 } |
890 | 890 |
891 bool GrDrawTarget::onCanCopySurface(GrSurface* dst, | 891 bool GrDrawTarget::onCanCopySurface(GrSurface* dst, |
892 GrSurface* src, | 892 GrSurface* src, |
893 const SkIRect& srcRect, | 893 const SkIRect& srcRect, |
894 const SkIPoint& dstPoint) { | 894 const SkIPoint& dstPoint) { |
895 // Check that the read/write rects are contained within the src/dst bounds. | 895 // Check that the read/write rects are contained within the src/dst bounds. |
896 GrAssert(!srcRect.isEmpty()); | 896 SkASSERT(!srcRect.isEmpty()); |
897 GrAssert(SkIRect::MakeWH(src->width(), src->height()).contains(srcRect)); | 897 SkASSERT(SkIRect::MakeWH(src->width(), src->height()).contains(srcRect)); |
898 GrAssert(dstPoint.fX >= 0 && dstPoint.fY >= 0); | 898 SkASSERT(dstPoint.fX >= 0 && dstPoint.fY >= 0); |
899 GrAssert(dstPoint.fX + srcRect.width() <= dst->width() && | 899 SkASSERT(dstPoint.fX + srcRect.width() <= dst->width() && |
900 dstPoint.fY + srcRect.height() <= dst->height()); | 900 dstPoint.fY + srcRect.height() <= dst->height()); |
901 | 901 |
902 return !dst->isSameAs(src) && NULL != dst->asRenderTarget() && NULL != src->
asTexture(); | 902 return !dst->isSameAs(src) && NULL != dst->asRenderTarget() && NULL != src->
asTexture(); |
903 } | 903 } |
904 | 904 |
905 bool GrDrawTarget::onCopySurface(GrSurface* dst, | 905 bool GrDrawTarget::onCopySurface(GrSurface* dst, |
906 GrSurface* src, | 906 GrSurface* src, |
907 const SkIRect& srcRect, | 907 const SkIRect& srcRect, |
908 const SkIPoint& dstPoint) { | 908 const SkIPoint& dstPoint) { |
909 if (!GrDrawTarget::onCanCopySurface(dst, src, srcRect, dstPoint)) { | 909 if (!GrDrawTarget::onCanCopySurface(dst, src, srcRect, dstPoint)) { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
990 GrPrintf("Geometry Shader Support : %s\n", gNY[fGeometryShaderSupport]); | 990 GrPrintf("Geometry Shader Support : %s\n", gNY[fGeometryShaderSupport]); |
991 GrPrintf("Dual Source Blending Support: %s\n", gNY[fDualSourceBlendingSuppor
t]); | 991 GrPrintf("Dual Source Blending Support: %s\n", gNY[fDualSourceBlendingSuppor
t]); |
992 GrPrintf("Buffer Lock Support : %s\n", gNY[fBufferLockSupport]); | 992 GrPrintf("Buffer Lock Support : %s\n", gNY[fBufferLockSupport]); |
993 GrPrintf("Path Stenciling Support : %s\n", gNY[fPathStencilingSupport]); | 993 GrPrintf("Path Stenciling Support : %s\n", gNY[fPathStencilingSupport]); |
994 GrPrintf("Dst Read In Shader Support : %s\n", gNY[fDstReadInShaderSupport])
; | 994 GrPrintf("Dst Read In Shader Support : %s\n", gNY[fDstReadInShaderSupport])
; |
995 GrPrintf("Reuse Scratch Textures : %s\n", gNY[fReuseScratchTextures]); | 995 GrPrintf("Reuse Scratch Textures : %s\n", gNY[fReuseScratchTextures]); |
996 GrPrintf("Max Texture Size : %d\n", fMaxTextureSize); | 996 GrPrintf("Max Texture Size : %d\n", fMaxTextureSize); |
997 GrPrintf("Max Render Target Size : %d\n", fMaxRenderTargetSize); | 997 GrPrintf("Max Render Target Size : %d\n", fMaxRenderTargetSize); |
998 GrPrintf("Max Sample Count : %d\n", fMaxSampleCount); | 998 GrPrintf("Max Sample Count : %d\n", fMaxSampleCount); |
999 } | 999 } |
OLD | NEW |