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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 SkASSERT(fStartIndex >= 0); | 81 SkASSERT(fStartIndex >= 0); |
82 } | 82 } |
83 | 83 |
84 //////////////////////////////////////////////////////////////////////////////// | 84 //////////////////////////////////////////////////////////////////////////////// |
85 | 85 |
86 #define DEBUG_INVAL_BUFFER 0xdeadcafe | 86 #define DEBUG_INVAL_BUFFER 0xdeadcafe |
87 #define DEBUG_INVAL_START_IDX -1 | 87 #define DEBUG_INVAL_START_IDX -1 |
88 | 88 |
89 GrDrawTarget::GrDrawTarget(GrContext* context) | 89 GrDrawTarget::GrDrawTarget(GrContext* context) |
90 : fClip(NULL) | 90 : fClip(NULL) |
91 , fContext(context) { | 91 , fContext(context) |
| 92 , fPushGpuTraceCount(0) { |
92 SkASSERT(NULL != context); | 93 SkASSERT(NULL != context); |
93 | 94 |
94 fDrawState = &fDefaultDrawState; | 95 fDrawState = &fDefaultDrawState; |
95 // 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. |
96 fDefaultDrawState.ref(); | 97 fDefaultDrawState.ref(); |
97 GeometrySrcState& geoSrc = fGeoSrcStateStack.push_back(); | 98 GeometrySrcState& geoSrc = fGeoSrcStateStack.push_back(); |
98 #ifdef SK_DEBUG | 99 #ifdef SK_DEBUG |
99 geoSrc.fVertexCount = DEBUG_INVAL_START_IDX; | 100 geoSrc.fVertexCount = DEBUG_INVAL_START_IDX; |
100 geoSrc.fVertexBuffer = (GrVertexBuffer*)DEBUG_INVAL_BUFFER; | 101 geoSrc.fVertexBuffer = (GrVertexBuffer*)DEBUG_INVAL_BUFFER; |
101 geoSrc.fIndexCount = DEBUG_INVAL_START_IDX; | 102 geoSrc.fIndexCount = DEBUG_INVAL_START_IDX; |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 viewM.mapRect(&devBounds); | 541 viewM.mapRect(&devBounds); |
541 | 542 |
542 GrDeviceCoordTexture dstCopy; | 543 GrDeviceCoordTexture dstCopy; |
543 if (!this->setupDstReadIfNecessary(&dstCopy, &devBounds)) { | 544 if (!this->setupDstReadIfNecessary(&dstCopy, &devBounds)) { |
544 return; | 545 return; |
545 } | 546 } |
546 | 547 |
547 this->onDrawPath(path, fill, dstCopy.texture() ? &dstCopy : NULL); | 548 this->onDrawPath(path, fill, dstCopy.texture() ? &dstCopy : NULL); |
548 } | 549 } |
549 | 550 |
| 551 void GrDrawTarget::instantGpuTraceEvent(const char* marker) { |
| 552 if (this->caps()->gpuTracingSupport()) { |
| 553 this->onInstantGpuTraceEvent(marker); |
| 554 } |
| 555 } |
| 556 |
| 557 void GrDrawTarget::pushGpuTraceEvent(const char* marker) { |
| 558 SkASSERT(fPushGpuTraceCount >= 0); |
| 559 if (this->caps()->gpuTracingSupport()) { |
| 560 this->onPushGpuTraceEvent(marker); |
| 561 ++fPushGpuTraceCount; |
| 562 } |
| 563 } |
| 564 |
| 565 void GrDrawTarget::popGpuTraceEvent() { |
| 566 SkASSERT(fPushGpuTraceCount >= 1); |
| 567 if (this->caps()->gpuTracingSupport()) { |
| 568 this->onPopGpuTraceEvent(); |
| 569 --fPushGpuTraceCount; |
| 570 } |
| 571 } |
| 572 |
550 //////////////////////////////////////////////////////////////////////////////// | 573 //////////////////////////////////////////////////////////////////////////////// |
551 | 574 |
552 bool GrDrawTarget::willUseHWAALines() const { | 575 bool GrDrawTarget::willUseHWAALines() const { |
553 // There is a conflict between using smooth lines and our use of premultipli
ed alpha. Smooth | 576 // There is a conflict between using smooth lines and our use of premultipli
ed alpha. Smooth |
554 // lines tweak the incoming alpha value but not in a premul-alpha way. So we
only use them when | 577 // lines tweak the incoming alpha value but not in a premul-alpha way. So we
only use them when |
555 // our alpha is 0xff and tweaking the color for partial coverage is OK | 578 // our alpha is 0xff and tweaking the color for partial coverage is OK |
556 if (!this->caps()->hwAALineSupport() || | 579 if (!this->caps()->hwAALineSupport() || |
557 !this->getDrawState().isHWAntialiasState()) { | 580 !this->getDrawState().isHWAntialiasState()) { |
558 return false; | 581 return false; |
559 } | 582 } |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
964 fTwoSidedStencilSupport = false; | 987 fTwoSidedStencilSupport = false; |
965 fStencilWrapOpsSupport = false; | 988 fStencilWrapOpsSupport = false; |
966 fHWAALineSupport = false; | 989 fHWAALineSupport = false; |
967 fShaderDerivativeSupport = false; | 990 fShaderDerivativeSupport = false; |
968 fGeometryShaderSupport = false; | 991 fGeometryShaderSupport = false; |
969 fDualSourceBlendingSupport = false; | 992 fDualSourceBlendingSupport = false; |
970 fBufferLockSupport = false; | 993 fBufferLockSupport = false; |
971 fPathRenderingSupport = false; | 994 fPathRenderingSupport = false; |
972 fDstReadInShaderSupport = false; | 995 fDstReadInShaderSupport = false; |
973 fReuseScratchTextures = true; | 996 fReuseScratchTextures = true; |
| 997 fGpuTracingSupport = false; |
974 | 998 |
975 fMaxRenderTargetSize = 0; | 999 fMaxRenderTargetSize = 0; |
976 fMaxTextureSize = 0; | 1000 fMaxTextureSize = 0; |
977 fMaxSampleCount = 0; | 1001 fMaxSampleCount = 0; |
978 | 1002 |
979 memset(fConfigRenderSupport, 0, sizeof(fConfigRenderSupport)); | 1003 memset(fConfigRenderSupport, 0, sizeof(fConfigRenderSupport)); |
980 } | 1004 } |
981 | 1005 |
982 GrDrawTargetCaps& GrDrawTargetCaps::operator=(const GrDrawTargetCaps& other) { | 1006 GrDrawTargetCaps& GrDrawTargetCaps::operator=(const GrDrawTargetCaps& other) { |
983 f8BitPaletteSupport = other.f8BitPaletteSupport; | 1007 f8BitPaletteSupport = other.f8BitPaletteSupport; |
984 fMipMapSupport = other.fMipMapSupport; | 1008 fMipMapSupport = other.fMipMapSupport; |
985 fNPOTTextureTileSupport = other.fNPOTTextureTileSupport; | 1009 fNPOTTextureTileSupport = other.fNPOTTextureTileSupport; |
986 fTwoSidedStencilSupport = other.fTwoSidedStencilSupport; | 1010 fTwoSidedStencilSupport = other.fTwoSidedStencilSupport; |
987 fStencilWrapOpsSupport = other.fStencilWrapOpsSupport; | 1011 fStencilWrapOpsSupport = other.fStencilWrapOpsSupport; |
988 fHWAALineSupport = other.fHWAALineSupport; | 1012 fHWAALineSupport = other.fHWAALineSupport; |
989 fShaderDerivativeSupport = other.fShaderDerivativeSupport; | 1013 fShaderDerivativeSupport = other.fShaderDerivativeSupport; |
990 fGeometryShaderSupport = other.fGeometryShaderSupport; | 1014 fGeometryShaderSupport = other.fGeometryShaderSupport; |
991 fDualSourceBlendingSupport = other.fDualSourceBlendingSupport; | 1015 fDualSourceBlendingSupport = other.fDualSourceBlendingSupport; |
992 fBufferLockSupport = other.fBufferLockSupport; | 1016 fBufferLockSupport = other.fBufferLockSupport; |
993 fPathRenderingSupport = other.fPathRenderingSupport; | 1017 fPathRenderingSupport = other.fPathRenderingSupport; |
994 fDstReadInShaderSupport = other.fDstReadInShaderSupport; | 1018 fDstReadInShaderSupport = other.fDstReadInShaderSupport; |
995 fReuseScratchTextures = other.fReuseScratchTextures; | 1019 fReuseScratchTextures = other.fReuseScratchTextures; |
| 1020 fGpuTracingSupport = other.fGpuTracingSupport; |
996 | 1021 |
997 fMaxRenderTargetSize = other.fMaxRenderTargetSize; | 1022 fMaxRenderTargetSize = other.fMaxRenderTargetSize; |
998 fMaxTextureSize = other.fMaxTextureSize; | 1023 fMaxTextureSize = other.fMaxTextureSize; |
999 fMaxSampleCount = other.fMaxSampleCount; | 1024 fMaxSampleCount = other.fMaxSampleCount; |
1000 | 1025 |
1001 memcpy(fConfigRenderSupport, other.fConfigRenderSupport, sizeof(fConfigRende
rSupport)); | 1026 memcpy(fConfigRenderSupport, other.fConfigRenderSupport, sizeof(fConfigRende
rSupport)); |
1002 | 1027 |
1003 return *this; | 1028 return *this; |
1004 } | 1029 } |
1005 | 1030 |
1006 SkString GrDrawTargetCaps::dump() const { | 1031 SkString GrDrawTargetCaps::dump() const { |
1007 SkString r; | 1032 SkString r; |
1008 static const char* gNY[] = {"NO", "YES"}; | 1033 static const char* gNY[] = {"NO", "YES"}; |
1009 r.appendf("8 Bit Palette Support : %s\n", gNY[f8BitPaletteSupport]); | 1034 r.appendf("8 Bit Palette Support : %s\n", gNY[f8BitPaletteSupport]); |
1010 r.appendf("MIP Map Support : %s\n", gNY[fMipMapSupport]); | 1035 r.appendf("MIP Map Support : %s\n", gNY[fMipMapSupport]); |
1011 r.appendf("NPOT Texture Tile Support : %s\n", gNY[fNPOTTextureTileSupport]
); | 1036 r.appendf("NPOT Texture Tile Support : %s\n", gNY[fNPOTTextureTileSupport]
); |
1012 r.appendf("Two Sided Stencil Support : %s\n", gNY[fTwoSidedStencilSupport]
); | 1037 r.appendf("Two Sided Stencil Support : %s\n", gNY[fTwoSidedStencilSupport]
); |
1013 r.appendf("Stencil Wrap Ops Support : %s\n", gNY[fStencilWrapOpsSupport])
; | 1038 r.appendf("Stencil Wrap Ops Support : %s\n", gNY[fStencilWrapOpsSupport])
; |
1014 r.appendf("HW AA Lines Support : %s\n", gNY[fHWAALineSupport]); | 1039 r.appendf("HW AA Lines Support : %s\n", gNY[fHWAALineSupport]); |
1015 r.appendf("Shader Derivative Support : %s\n", gNY[fShaderDerivativeSupport
]); | 1040 r.appendf("Shader Derivative Support : %s\n", gNY[fShaderDerivativeSupport
]); |
1016 r.appendf("Geometry Shader Support : %s\n", gNY[fGeometryShaderSupport])
; | 1041 r.appendf("Geometry Shader Support : %s\n", gNY[fGeometryShaderSupport])
; |
1017 r.appendf("Dual Source Blending Support: %s\n", gNY[fDualSourceBlendingSuppo
rt]); | 1042 r.appendf("Dual Source Blending Support: %s\n", gNY[fDualSourceBlendingSuppo
rt]); |
1018 r.appendf("Buffer Lock Support : %s\n", gNY[fBufferLockSupport]); | 1043 r.appendf("Buffer Lock Support : %s\n", gNY[fBufferLockSupport]); |
1019 r.appendf("Path Rendering Support : %s\n", gNY[fPathRenderingSupport]); | 1044 r.appendf("Path Rendering Support : %s\n", gNY[fPathRenderingSupport]); |
1020 r.appendf("Dst Read In Shader Support : %s\n", gNY[fDstReadInShaderSupport]
); | 1045 r.appendf("Dst Read In Shader Support : %s\n", gNY[fDstReadInShaderSupport]
); |
1021 r.appendf("Reuse Scratch Textures : %s\n", gNY[fReuseScratchTextures]); | 1046 r.appendf("Reuse Scratch Textures : %s\n", gNY[fReuseScratchTextures]); |
| 1047 r.appendf("Gpu Tracing Support : %s\n", gNY[fGpuTracingSupport]); |
1022 r.appendf("Max Texture Size : %d\n", fMaxTextureSize); | 1048 r.appendf("Max Texture Size : %d\n", fMaxTextureSize); |
1023 r.appendf("Max Render Target Size : %d\n", fMaxRenderTargetSize); | 1049 r.appendf("Max Render Target Size : %d\n", fMaxRenderTargetSize); |
1024 r.appendf("Max Sample Count : %d\n", fMaxSampleCount); | 1050 r.appendf("Max Sample Count : %d\n", fMaxSampleCount); |
1025 | 1051 |
1026 static const char* kConfigNames[] = { | 1052 static const char* kConfigNames[] = { |
1027 "Unknown", // kUnknown_GrPixelConfig | 1053 "Unknown", // kUnknown_GrPixelConfig |
1028 "Alpha8", // kAlpha_8_GrPixelConfig, | 1054 "Alpha8", // kAlpha_8_GrPixelConfig, |
1029 "Index8", // kIndex_8_GrPixelConfig, | 1055 "Index8", // kIndex_8_GrPixelConfig, |
1030 "RGB565", // kRGB_565_GrPixelConfig, | 1056 "RGB565", // kRGB_565_GrPixelConfig, |
1031 "RGBA444", // kRGBA_4444_GrPixelConfig, | 1057 "RGBA444", // kRGBA_4444_GrPixelConfig, |
(...skipping 14 matching lines...) Expand all Loading... |
1046 for (size_t i = 0; i < SK_ARRAY_COUNT(kConfigNames); ++i) { | 1072 for (size_t i = 0; i < SK_ARRAY_COUNT(kConfigNames); ++i) { |
1047 if (i != kUnknown_GrPixelConfig) { | 1073 if (i != kUnknown_GrPixelConfig) { |
1048 r.appendf("%s is renderable: %s, with MSAA: %s\n", | 1074 r.appendf("%s is renderable: %s, with MSAA: %s\n", |
1049 kConfigNames[i], | 1075 kConfigNames[i], |
1050 gNY[fConfigRenderSupport[i][0]], | 1076 gNY[fConfigRenderSupport[i][0]], |
1051 gNY[fConfigRenderSupport[i][1]]); | 1077 gNY[fConfigRenderSupport[i][1]]); |
1052 } | 1078 } |
1053 } | 1079 } |
1054 return r; | 1080 return r; |
1055 } | 1081 } |
OLD | NEW |