OLD | NEW |
---|---|
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 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 #include "GrContext.h" | 10 #include "GrContext.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
61 static const int DRAW_BUFFER_VBPOOL_PREALLOC_BUFFERS = 4; | 61 static const int DRAW_BUFFER_VBPOOL_PREALLOC_BUFFERS = 4; |
62 | 62 |
63 static const size_t DRAW_BUFFER_IBPOOL_BUFFER_SIZE = 1 << 11; | 63 static const size_t DRAW_BUFFER_IBPOOL_BUFFER_SIZE = 1 << 11; |
64 static const int DRAW_BUFFER_IBPOOL_PREALLOC_BUFFERS = 4; | 64 static const int DRAW_BUFFER_IBPOOL_PREALLOC_BUFFERS = 4; |
65 | 65 |
66 #define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == this) | 66 #define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == this) |
67 | 67 |
68 // Glorified typedef to avoid including GrDrawState.h in GrContext.h | 68 // Glorified typedef to avoid including GrDrawState.h in GrContext.h |
69 class GrContext::AutoRestoreEffects : public GrDrawState::AutoRestoreEffects {}; | 69 class GrContext::AutoRestoreEffects : public GrDrawState::AutoRestoreEffects {}; |
70 | 70 |
71 class GrContext::AutoCheckFlush { | |
72 public: | |
robertphillips
2013/10/04 15:28:12
What do you think about requiring the context in t
| |
73 AutoCheckFlush() : fContext(NULL) {} | |
74 | |
75 ~AutoCheckFlush() { | |
76 if (NULL != fContext && fContext->fFlushToReduceCacheSize) { | |
77 fContext->flush(); | |
78 } | |
79 } | |
80 | |
81 void set(GrContext* context) { fContext = context; } | |
82 | |
83 private: | |
84 GrContext* fContext; | |
85 }; | |
86 | |
71 GrContext* GrContext::Create(GrBackend backend, GrBackendContext backendContext) { | 87 GrContext* GrContext::Create(GrBackend backend, GrBackendContext backendContext) { |
72 GrContext* context = SkNEW(GrContext); | 88 GrContext* context = SkNEW(GrContext); |
73 if (context->init(backend, backendContext)) { | 89 if (context->init(backend, backendContext)) { |
74 return context; | 90 return context; |
75 } else { | 91 } else { |
76 context->unref(); | 92 context->unref(); |
77 return NULL; | 93 return NULL; |
78 } | 94 } |
79 } | 95 } |
80 | 96 |
(...skipping 13 matching lines...) Expand all Loading... | |
94 fDrawState = NULL; | 110 fDrawState = NULL; |
95 fGpu = NULL; | 111 fGpu = NULL; |
96 fClip = NULL; | 112 fClip = NULL; |
97 fPathRendererChain = NULL; | 113 fPathRendererChain = NULL; |
98 fSoftwarePathRenderer = NULL; | 114 fSoftwarePathRenderer = NULL; |
99 fTextureCache = NULL; | 115 fTextureCache = NULL; |
100 fFontCache = NULL; | 116 fFontCache = NULL; |
101 fDrawBuffer = NULL; | 117 fDrawBuffer = NULL; |
102 fDrawBufferVBAllocPool = NULL; | 118 fDrawBufferVBAllocPool = NULL; |
103 fDrawBufferIBAllocPool = NULL; | 119 fDrawBufferIBAllocPool = NULL; |
120 fFlushToReduceCacheSize = false; | |
104 fAARectRenderer = NULL; | 121 fAARectRenderer = NULL; |
105 fOvalRenderer = NULL; | 122 fOvalRenderer = NULL; |
106 fViewMatrix.reset(); | 123 fViewMatrix.reset(); |
107 fMaxTextureSizeOverride = 1 << 20; | 124 fMaxTextureSizeOverride = 1 << 20; |
108 } | 125 } |
109 | 126 |
110 bool GrContext::init(GrBackend backend, GrBackendContext backendContext) { | 127 bool GrContext::init(GrBackend backend, GrBackendContext backendContext) { |
111 SkASSERT(NULL == fGpu); | 128 SkASSERT(NULL == fGpu); |
112 | 129 |
113 fGpu = GrGpu::Create(backend, backendContext, this); | 130 fGpu = GrGpu::Create(backend, backendContext, this); |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
526 fTextureCache->purgeAsNeeded(); | 543 fTextureCache->purgeAsNeeded(); |
527 } | 544 } |
528 } | 545 } |
529 | 546 |
530 bool GrContext::OverbudgetCB(void* data) { | 547 bool GrContext::OverbudgetCB(void* data) { |
531 SkASSERT(NULL != data); | 548 SkASSERT(NULL != data); |
532 | 549 |
533 GrContext* context = reinterpret_cast<GrContext*>(data); | 550 GrContext* context = reinterpret_cast<GrContext*>(data); |
534 | 551 |
535 // Flush the InOrderDrawBuffer to possibly free up some textures | 552 // Flush the InOrderDrawBuffer to possibly free up some textures |
536 context->flush(); | 553 context->fFlushToReduceCacheSize = true; |
537 | 554 |
538 // TODO: actually track flush's behavior rather than always just | |
539 // returning true. | |
540 return true; | 555 return true; |
541 } | 556 } |
542 | 557 |
543 | 558 |
544 GrTexture* GrContext::createUncachedTexture(const GrTextureDesc& descIn, | 559 GrTexture* GrContext::createUncachedTexture(const GrTextureDesc& descIn, |
545 void* srcData, | 560 void* srcData, |
546 size_t rowBytes) { | 561 size_t rowBytes) { |
547 GrTextureDesc descCopy = descIn; | 562 GrTextureDesc descCopy = descIn; |
548 return fGpu->createTexture(descCopy, srcData, rowBytes); | 563 return fGpu->createTexture(descCopy, srcData, rowBytes); |
549 } | 564 } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
599 return true; | 614 return true; |
600 } | 615 } |
601 | 616 |
602 | 617 |
603 //////////////////////////////////////////////////////////////////////////////// | 618 //////////////////////////////////////////////////////////////////////////////// |
604 | 619 |
605 void GrContext::clear(const SkIRect* rect, | 620 void GrContext::clear(const SkIRect* rect, |
606 const GrColor color, | 621 const GrColor color, |
607 GrRenderTarget* target) { | 622 GrRenderTarget* target) { |
608 AutoRestoreEffects are; | 623 AutoRestoreEffects are; |
609 this->prepareToDraw(NULL, BUFFERED_DRAW, &are)->clear(rect, color, target); | 624 AutoCheckFlush acf; |
625 this->prepareToDraw(NULL, BUFFERED_DRAW, &are, &acf)->clear(rect, color, tar get); | |
610 } | 626 } |
611 | 627 |
612 void GrContext::drawPaint(const GrPaint& origPaint) { | 628 void GrContext::drawPaint(const GrPaint& origPaint) { |
613 // set rect to be big enough to fill the space, but not super-huge, so we | 629 // set rect to be big enough to fill the space, but not super-huge, so we |
614 // don't overflow fixed-point implementations | 630 // don't overflow fixed-point implementations |
615 SkRect r; | 631 SkRect r; |
616 r.setLTRB(0, 0, | 632 r.setLTRB(0, 0, |
617 SkIntToScalar(getRenderTarget()->width()), | 633 SkIntToScalar(getRenderTarget()->width()), |
618 SkIntToScalar(getRenderTarget()->height())); | 634 SkIntToScalar(getRenderTarget()->height())); |
619 SkMatrix inverse; | 635 SkMatrix inverse; |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
748 point.fY >= rect.fTop && point.fY <= rect.fBottom; | 764 point.fY >= rect.fTop && point.fY <= rect.fBottom; |
749 } | 765 } |
750 | 766 |
751 void GrContext::drawRect(const GrPaint& paint, | 767 void GrContext::drawRect(const GrPaint& paint, |
752 const SkRect& rect, | 768 const SkRect& rect, |
753 SkScalar width, | 769 SkScalar width, |
754 const SkMatrix* matrix) { | 770 const SkMatrix* matrix) { |
755 SK_TRACE_EVENT0("GrContext::drawRect"); | 771 SK_TRACE_EVENT0("GrContext::drawRect"); |
756 | 772 |
757 AutoRestoreEffects are; | 773 AutoRestoreEffects are; |
758 GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW, &are); | 774 AutoCheckFlush acf; |
775 GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW, &are, &acf ); | |
759 | 776 |
760 SkMatrix combinedMatrix = target->drawState()->getViewMatrix(); | 777 SkMatrix combinedMatrix = target->drawState()->getViewMatrix(); |
761 if (NULL != matrix) { | 778 if (NULL != matrix) { |
762 combinedMatrix.preConcat(*matrix); | 779 combinedMatrix.preConcat(*matrix); |
763 } | 780 } |
764 | 781 |
765 // Check if this is a full RT draw and can be replaced with a clear. We don' t bother checking | 782 // Check if this is a full RT draw and can be replaced with a clear. We don' t bother checking |
766 // cases where the RT is fully inside a stroke. | 783 // cases where the RT is fully inside a stroke. |
767 if (width < 0) { | 784 if (width < 0) { |
768 SkRect rtRect; | 785 SkRect rtRect; |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
867 } | 884 } |
868 } | 885 } |
869 | 886 |
870 void GrContext::drawRectToRect(const GrPaint& paint, | 887 void GrContext::drawRectToRect(const GrPaint& paint, |
871 const SkRect& dstRect, | 888 const SkRect& dstRect, |
872 const SkRect& localRect, | 889 const SkRect& localRect, |
873 const SkMatrix* dstMatrix, | 890 const SkMatrix* dstMatrix, |
874 const SkMatrix* localMatrix) { | 891 const SkMatrix* localMatrix) { |
875 SK_TRACE_EVENT0("GrContext::drawRectToRect"); | 892 SK_TRACE_EVENT0("GrContext::drawRectToRect"); |
876 AutoRestoreEffects are; | 893 AutoRestoreEffects are; |
877 GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW, &are); | 894 AutoCheckFlush acf; |
895 GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW, &are, &acf ); | |
878 | 896 |
879 target->drawRect(dstRect, dstMatrix, &localRect, localMatrix); | 897 target->drawRect(dstRect, dstMatrix, &localRect, localMatrix); |
880 } | 898 } |
881 | 899 |
882 namespace { | 900 namespace { |
883 | 901 |
884 extern const GrVertexAttrib gPosUVColorAttribs[] = { | 902 extern const GrVertexAttrib gPosUVColorAttribs[] = { |
885 {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding }, | 903 {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding }, |
886 {kVec2f_GrVertexAttribType, sizeof(GrPoint), kLocalCoord_GrVertexAttribBind ing }, | 904 {kVec2f_GrVertexAttribType, sizeof(GrPoint), kLocalCoord_GrVertexAttribBind ing }, |
887 {kVec4ub_GrVertexAttribType, 2*sizeof(GrPoint), kColor_GrVertexAttribBinding } | 905 {kVec4ub_GrVertexAttribType, 2*sizeof(GrPoint), kColor_GrVertexAttribBinding } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
923 const GrPoint positions[], | 941 const GrPoint positions[], |
924 const GrPoint texCoords[], | 942 const GrPoint texCoords[], |
925 const GrColor colors[], | 943 const GrColor colors[], |
926 const uint16_t indices[], | 944 const uint16_t indices[], |
927 int indexCount) { | 945 int indexCount) { |
928 SK_TRACE_EVENT0("GrContext::drawVertices"); | 946 SK_TRACE_EVENT0("GrContext::drawVertices"); |
929 | 947 |
930 GrDrawTarget::AutoReleaseGeometry geo; | 948 GrDrawTarget::AutoReleaseGeometry geo; |
931 | 949 |
932 AutoRestoreEffects are; | 950 AutoRestoreEffects are; |
933 GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW, &are); | 951 AutoCheckFlush acf; |
952 GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW, &are, &acf ); | |
934 | 953 |
935 GrDrawState* drawState = target->drawState(); | 954 GrDrawState* drawState = target->drawState(); |
936 | 955 |
937 int colorOffset = -1, texOffset = -1; | 956 int colorOffset = -1, texOffset = -1; |
938 set_vertex_attributes(drawState, texCoords, colors, &colorOffset, &texOffset ); | 957 set_vertex_attributes(drawState, texCoords, colors, &colorOffset, &texOffset ); |
939 | 958 |
940 size_t vertexSize = drawState->getVertexSize(); | 959 size_t vertexSize = drawState->getVertexSize(); |
941 if (sizeof(GrPoint) != vertexSize) { | 960 if (sizeof(GrPoint) != vertexSize) { |
942 if (!geo.set(target, vertexCount, 0)) { | 961 if (!geo.set(target, vertexCount, 0)) { |
943 GrPrintf("Failed to get space for vertices!\n"); | 962 GrPrintf("Failed to get space for vertices!\n"); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
975 /////////////////////////////////////////////////////////////////////////////// | 994 /////////////////////////////////////////////////////////////////////////////// |
976 | 995 |
977 void GrContext::drawRRect(const GrPaint& paint, | 996 void GrContext::drawRRect(const GrPaint& paint, |
978 const SkRRect& rect, | 997 const SkRRect& rect, |
979 const SkStrokeRec& stroke) { | 998 const SkStrokeRec& stroke) { |
980 if (rect.isEmpty()) { | 999 if (rect.isEmpty()) { |
981 return; | 1000 return; |
982 } | 1001 } |
983 | 1002 |
984 AutoRestoreEffects are; | 1003 AutoRestoreEffects are; |
985 GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW, &are); | 1004 AutoCheckFlush acf; |
1005 GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW, &are, &acf ); | |
986 | 1006 |
987 bool useAA = paint.isAntiAlias() && | 1007 bool useAA = paint.isAntiAlias() && |
988 !target->getDrawState().getRenderTarget()->isMultisampled() && | 1008 !target->getDrawState().getRenderTarget()->isMultisampled() && |
989 !disable_coverage_aa_for_blend(target); | 1009 !disable_coverage_aa_for_blend(target); |
990 | 1010 |
991 if (!fOvalRenderer->drawSimpleRRect(target, this, useAA, rect, stroke)) { | 1011 if (!fOvalRenderer->drawSimpleRRect(target, this, useAA, rect, stroke)) { |
992 SkPath path; | 1012 SkPath path; |
993 path.addRRect(rect); | 1013 path.addRRect(rect); |
994 this->internalDrawPath(target, useAA, path, stroke); | 1014 this->internalDrawPath(target, useAA, path, stroke); |
995 } | 1015 } |
996 } | 1016 } |
997 | 1017 |
998 /////////////////////////////////////////////////////////////////////////////// | 1018 /////////////////////////////////////////////////////////////////////////////// |
999 | 1019 |
1000 void GrContext::drawOval(const GrPaint& paint, | 1020 void GrContext::drawOval(const GrPaint& paint, |
1001 const SkRect& oval, | 1021 const SkRect& oval, |
1002 const SkStrokeRec& stroke) { | 1022 const SkStrokeRec& stroke) { |
1003 if (oval.isEmpty()) { | 1023 if (oval.isEmpty()) { |
1004 return; | 1024 return; |
1005 } | 1025 } |
1006 | 1026 |
1007 AutoRestoreEffects are; | 1027 AutoRestoreEffects are; |
1008 GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW, &are); | 1028 AutoCheckFlush acf; |
1029 GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW, &are, &acf ); | |
1009 | 1030 |
1010 bool useAA = paint.isAntiAlias() && | 1031 bool useAA = paint.isAntiAlias() && |
1011 !target->getDrawState().getRenderTarget()->isMultisampled() && | 1032 !target->getDrawState().getRenderTarget()->isMultisampled() && |
1012 !disable_coverage_aa_for_blend(target); | 1033 !disable_coverage_aa_for_blend(target); |
1013 | 1034 |
1014 if (!fOvalRenderer->drawOval(target, this, useAA, oval, stroke)) { | 1035 if (!fOvalRenderer->drawOval(target, this, useAA, oval, stroke)) { |
1015 SkPath path; | 1036 SkPath path; |
1016 path.addOval(oval); | 1037 path.addOval(oval); |
1017 this->internalDrawPath(target, useAA, path, stroke); | 1038 this->internalDrawPath(target, useAA, path, stroke); |
1018 } | 1039 } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1081 } | 1102 } |
1082 return; | 1103 return; |
1083 } | 1104 } |
1084 | 1105 |
1085 // Note that internalDrawPath may sw-rasterize the path into a scratch textu re. | 1106 // Note that internalDrawPath may sw-rasterize the path into a scratch textu re. |
1086 // Scratch textures can be recycled after they are returned to the texture | 1107 // Scratch textures can be recycled after they are returned to the texture |
1087 // cache. This presents a potential hazard for buffered drawing. However, | 1108 // cache. This presents a potential hazard for buffered drawing. However, |
1088 // the writePixels that uploads to the scratch will perform a flush so we're | 1109 // the writePixels that uploads to the scratch will perform a flush so we're |
1089 // OK. | 1110 // OK. |
1090 AutoRestoreEffects are; | 1111 AutoRestoreEffects are; |
1091 GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW, &are); | 1112 AutoCheckFlush acf; |
1113 GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW, &are, &acf ); | |
1092 | 1114 |
1093 bool useAA = paint.isAntiAlias() && !target->getDrawState().getRenderTarget( )->isMultisampled(); | 1115 bool useAA = paint.isAntiAlias() && !target->getDrawState().getRenderTarget( )->isMultisampled(); |
1094 if (useAA && stroke.getWidth() < 0 && !path.isConvex()) { | 1116 if (useAA && stroke.getWidth() < 0 && !path.isConvex()) { |
1095 // Concave AA paths are expensive - try to avoid them for special cases | 1117 // Concave AA paths are expensive - try to avoid them for special cases |
1096 bool useVertexCoverage; | 1118 bool useVertexCoverage; |
1097 SkRect rects[2]; | 1119 SkRect rects[2]; |
1098 | 1120 |
1099 if (is_nested_rects(target, path, stroke, rects, &useVertexCoverage)) { | 1121 if (is_nested_rects(target, path, stroke, rects, &useVertexCoverage)) { |
1100 SkMatrix origViewMatrix = target->getDrawState().getViewMatrix(); | 1122 SkMatrix origViewMatrix = target->getDrawState().getViewMatrix(); |
1101 GrDrawState::AutoViewMatrixRestore avmr; | 1123 GrDrawState::AutoViewMatrixRestore avmr; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1176 void GrContext::flush(int flagsBitfield) { | 1198 void GrContext::flush(int flagsBitfield) { |
1177 if (NULL == fDrawBuffer) { | 1199 if (NULL == fDrawBuffer) { |
1178 return; | 1200 return; |
1179 } | 1201 } |
1180 | 1202 |
1181 if (kDiscard_FlushBit & flagsBitfield) { | 1203 if (kDiscard_FlushBit & flagsBitfield) { |
1182 fDrawBuffer->reset(); | 1204 fDrawBuffer->reset(); |
1183 } else { | 1205 } else { |
1184 fDrawBuffer->flush(); | 1206 fDrawBuffer->flush(); |
1185 } | 1207 } |
1208 fFlushToReduceCacheSize = false; | |
1186 } | 1209 } |
1187 | 1210 |
1188 bool GrContext::writeTexturePixels(GrTexture* texture, | 1211 bool GrContext::writeTexturePixels(GrTexture* texture, |
1189 int left, int top, int width, int height, | 1212 int left, int top, int width, int height, |
1190 GrPixelConfig config, const void* buffer, siz e_t rowBytes, | 1213 GrPixelConfig config, const void* buffer, siz e_t rowBytes, |
1191 uint32_t flags) { | 1214 uint32_t flags) { |
1192 SK_TRACE_EVENT0("GrContext::writeTexturePixels"); | 1215 SK_TRACE_EVENT0("GrContext::writeTexturePixels"); |
1193 ASSERT_OWNED_RESOURCE(texture); | 1216 ASSERT_OWNED_RESOURCE(texture); |
1194 | 1217 |
1195 if ((kUnpremul_PixelOpsFlag & flags) || !fGpu->canWriteTexturePixels(texture , config)) { | 1218 if ((kUnpremul_PixelOpsFlag & flags) || !fGpu->canWriteTexturePixels(texture , config)) { |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1583 | 1606 |
1584 drawState->setRenderTarget(target); | 1607 drawState->setRenderTarget(target); |
1585 | 1608 |
1586 fGpu->drawSimpleRect(SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(heig ht)), NULL); | 1609 fGpu->drawSimpleRect(SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(heig ht)), NULL); |
1587 return true; | 1610 return true; |
1588 } | 1611 } |
1589 //////////////////////////////////////////////////////////////////////////////// | 1612 //////////////////////////////////////////////////////////////////////////////// |
1590 | 1613 |
1591 GrDrawTarget* GrContext::prepareToDraw(const GrPaint* paint, | 1614 GrDrawTarget* GrContext::prepareToDraw(const GrPaint* paint, |
1592 BufferedDraw buffered, | 1615 BufferedDraw buffered, |
1593 AutoRestoreEffects* are) { | 1616 AutoRestoreEffects* are, |
1617 AutoCheckFlush* acf) { | |
1594 // All users of this draw state should be freeing up all effects when they'r e done. | 1618 // All users of this draw state should be freeing up all effects when they'r e done. |
1595 // Otherwise effects that own resources may keep those resources alive indef initely. | 1619 // Otherwise effects that own resources may keep those resources alive indef initely. |
1596 SkASSERT(0 == fDrawState->numColorStages() && 0 == fDrawState->numCoverageSt ages()); | 1620 SkASSERT(0 == fDrawState->numColorStages() && 0 == fDrawState->numCoverageSt ages()); |
1597 | 1621 |
1598 if (kNo_BufferedDraw == buffered && kYes_BufferedDraw == fLastDrawWasBuffere d) { | 1622 if (kNo_BufferedDraw == buffered && kYes_BufferedDraw == fLastDrawWasBuffere d) { |
1599 fDrawBuffer->flush(); | 1623 fDrawBuffer->flush(); |
1600 fLastDrawWasBuffered = kNo_BufferedDraw; | 1624 fLastDrawWasBuffered = kNo_BufferedDraw; |
1601 } | 1625 } |
1602 ASSERT_OWNED_RESOURCE(fRenderTarget.get()); | 1626 ASSERT_OWNED_RESOURCE(fRenderTarget.get()); |
1603 if (NULL != paint) { | 1627 if (NULL != paint) { |
1604 SkASSERT(NULL != are); | 1628 SkASSERT(NULL != are); |
1629 SkASSERT(NULL != acf); | |
1605 are->set(fDrawState); | 1630 are->set(fDrawState); |
1631 acf->set(this); | |
1606 fDrawState->setFromPaint(*paint, fViewMatrix, fRenderTarget.get()); | 1632 fDrawState->setFromPaint(*paint, fViewMatrix, fRenderTarget.get()); |
1607 #if GR_DEBUG_PARTIAL_COVERAGE_CHECK | 1633 #if GR_DEBUG_PARTIAL_COVERAGE_CHECK |
1608 if ((paint->hasMask() || 0xff != paint->fCoverage) && | 1634 if ((paint->hasMask() || 0xff != paint->fCoverage) && |
1609 !fGpu->canApplyCoverage()) { | 1635 !fGpu->canApplyCoverage()) { |
1610 GrPrintf("Partial pixel coverage will be incorrectly blended.\n"); | 1636 GrPrintf("Partial pixel coverage will be incorrectly blended.\n"); |
1611 } | 1637 } |
1612 #endif | 1638 #endif |
1613 } else { | 1639 } else { |
1614 fDrawState->reset(fViewMatrix); | 1640 fDrawState->reset(fViewMatrix); |
1615 fDrawState->setRenderTarget(fRenderTarget.get()); | 1641 fDrawState->setRenderTarget(fRenderTarget.get()); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1694 DRAW_BUFFER_IBPOOL_PREALLOC_BUFFERS)); | 1720 DRAW_BUFFER_IBPOOL_PREALLOC_BUFFERS)); |
1695 | 1721 |
1696 fDrawBuffer = SkNEW_ARGS(GrInOrderDrawBuffer, (fGpu, | 1722 fDrawBuffer = SkNEW_ARGS(GrInOrderDrawBuffer, (fGpu, |
1697 fDrawBufferVBAllocPool, | 1723 fDrawBufferVBAllocPool, |
1698 fDrawBufferIBAllocPool)); | 1724 fDrawBufferIBAllocPool)); |
1699 | 1725 |
1700 fDrawBuffer->setDrawState(fDrawState); | 1726 fDrawBuffer->setDrawState(fDrawState); |
1701 } | 1727 } |
1702 | 1728 |
1703 GrDrawTarget* GrContext::getTextTarget() { | 1729 GrDrawTarget* GrContext::getTextTarget() { |
1704 return this->prepareToDraw(NULL, BUFFERED_DRAW, NULL); | 1730 return this->prepareToDraw(NULL, BUFFERED_DRAW, NULL, NULL); |
1705 } | 1731 } |
1706 | 1732 |
1707 const GrIndexBuffer* GrContext::getQuadIndexBuffer() const { | 1733 const GrIndexBuffer* GrContext::getQuadIndexBuffer() const { |
1708 return fGpu->getQuadIndexBuffer(); | 1734 return fGpu->getQuadIndexBuffer(); |
1709 } | 1735 } |
1710 | 1736 |
1711 namespace { | 1737 namespace { |
1712 void test_pm_conversions(GrContext* ctx, int* pmToUPMValue, int* upmToPMValue) { | 1738 void test_pm_conversions(GrContext* ctx, int* pmToUPMValue, int* upmToPMValue) { |
1713 GrConfigConversionEffect::PMConversion pmToUPM; | 1739 GrConfigConversionEffect::PMConversion pmToUPM; |
1714 GrConfigConversionEffect::PMConversion upmToPM; | 1740 GrConfigConversionEffect::PMConversion upmToPM; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1749 return NULL; | 1775 return NULL; |
1750 } | 1776 } |
1751 } | 1777 } |
1752 | 1778 |
1753 /////////////////////////////////////////////////////////////////////////////// | 1779 /////////////////////////////////////////////////////////////////////////////// |
1754 #if GR_CACHE_STATS | 1780 #if GR_CACHE_STATS |
1755 void GrContext::printCacheStats() const { | 1781 void GrContext::printCacheStats() const { |
1756 fTextureCache->printStats(); | 1782 fTextureCache->printStats(); |
1757 } | 1783 } |
1758 #endif | 1784 #endif |
OLD | NEW |