GrDrawTarget::GrDrawTarget(GrContext* context)
: fClip(NULL)
- , fContext(context) {
+ , fContext(context)
+ , fGpuTraceMarkerCount(0) {
SkASSERT(NULL != context);
fDrawState = &fDefaultDrawState;
#endif
break;
default:
- GrCrash("Unknown Vertex Source Type.");
+ SkFAIL("Unknown Vertex Source Type.");
break;
}
}
#endif
break;
default:
- GrCrash("Unknown Index Source Type.");
+ SkFAIL("Unknown Index Source Type.");
break;
}
}
int maxValidVertex;
switch (geoSrc.fVertexSrc) {
case kNone_GeometrySrcType:
- GrCrash("Attempting to draw without vertex src.");
+ SkFAIL("Attempting to draw without vertex src.");
case kReserved_GeometrySrcType: // fallthrough
case kArray_GeometrySrcType:
maxValidVertex = geoSrc.fVertexCount;
break;
case kBuffer_GeometrySrcType:
- maxValidVertex = static_cast<int>(geoSrc.fVertexBuffer->sizeInBytes() / geoSrc.fVertexSize);
+ maxValidVertex = static_cast<int>(geoSrc.fVertexBuffer->gpuMemorySize() / geoSrc.fVertexSize);
break;
}
if (maxVertex > maxValidVertex) {
- GrCrash("Drawing outside valid vertex range.");
+ SkFAIL("Drawing outside valid vertex range.");
}
if (indexCount > 0) {
int maxIndex = startIndex + indexCount;
int maxValidIndex;
switch (geoSrc.fIndexSrc) {
case kNone_GeometrySrcType:
- GrCrash("Attempting to draw indexed geom without index src.");
+ SkFAIL("Attempting to draw indexed geom without index src.");
case kReserved_GeometrySrcType: // fallthrough
case kArray_GeometrySrcType:
maxValidIndex = geoSrc.fIndexCount;
break;
case kBuffer_GeometrySrcType:
- maxValidIndex = static_cast<int>(geoSrc.fIndexBuffer->sizeInBytes() / sizeof(uint16_t));
+ maxValidIndex = static_cast<int>(geoSrc.fIndexBuffer->gpuMemorySize() / sizeof(uint16_t));
break;
}
if (maxIndex > maxValidIndex) {
- GrCrash("Index reads outside valid index range.");
+ SkFAIL("Index reads outside valid index range.");
}
}
this->onDrawPath(path, fill, dstCopy.texture() ? &dstCopy : NULL);
}
+void GrDrawTarget::drawPaths(int pathCount, const GrPath** paths,
+ const SkMatrix* transforms,
+ SkPath::FillType fill, SkStrokeRec::Style stroke) {
+ SkASSERT(pathCount > 0);
+ SkASSERT(NULL != paths);
+ SkASSERT(NULL != paths[0]);
+ SkASSERT(this->caps()->pathRenderingSupport());
+ SkASSERT(!SkPath::IsInverseFillType(fill));
+
+ const GrDrawState* drawState = &getDrawState();
+
+ SkRect devBounds;
+ for (int i = 0; i < pathCount; ++i) {
+ SkRect mappedPathBounds;
+ transforms[i].mapRect(&mappedPathBounds, paths[i]->getBounds());
+ devBounds.join(mappedPathBounds);
+ }
+
+ SkMatrix viewM = drawState->getViewMatrix();
+ viewM.mapRect(&devBounds);
+
+ GrDeviceCoordTexture dstCopy;
+ if (!this->setupDstReadIfNecessary(&dstCopy, &devBounds)) {
+ return;
+ }
+
+ this->onDrawPaths(pathCount, paths, transforms, fill, stroke,
+ dstCopy.texture() ? &dstCopy : NULL);
+}
+
+void GrDrawTarget::addGpuTraceMarker(GrGpuTraceMarker* marker) {
+ if (this->caps()->gpuTracingSupport()) {
+ SkASSERT(fGpuTraceMarkerCount >= 0);
+ this->fActiveTraceMarkers.add(*marker);
+ this->didAddGpuTraceMarker();
+ ++fGpuTraceMarkerCount;
+ }
+}
+
+void GrDrawTarget::removeGpuTraceMarker(GrGpuTraceMarker* marker) {
+ if (this->caps()->gpuTracingSupport()) {
+ SkASSERT(fGpuTraceMarkerCount >= 1);
+ this->fActiveTraceMarkers.remove(*marker);
+ this->didRemoveGpuTraceMarker();
+ --fGpuTraceMarkerCount;
+ }
+}
+
////////////////////////////////////////////////////////////////////////////////
bool GrDrawTarget::willUseHWAALines() const {
}
while (instanceCount) {
- info.fInstanceCount = GrMin(instanceCount, maxInstancesPerDraw);
+ info.fInstanceCount = SkTMin(instanceCount, maxInstancesPerDraw);
info.fVertexCount = info.fInstanceCount * verticesPerInstance;
info.fIndexCount = info.fInstanceCount * indicesPerInstance;
// position + (optional) texture coord
extern const GrVertexAttrib gBWRectPosUVAttribs[] = {
{kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding},
- {kVec2f_GrVertexAttribType, sizeof(GrPoint), kLocalCoord_GrVertexAttribBinding}
+ {kVec2f_GrVertexAttribType, sizeof(SkPoint), kLocalCoord_GrVertexAttribBinding}
};
void set_vertex_attributes(GrDrawState* drawState, bool hasUVs) {
size_t vsize = this->drawState()->getVertexSize();
geo.positions()->setRectFan(rect.fLeft, rect.fTop, rect.fRight, rect.fBottom, vsize);
if (NULL != localRect) {
- GrPoint* coords = GrTCast<GrPoint*>(GrTCast<intptr_t>(geo.vertices()) +
- sizeof(GrPoint));
+ SkPoint* coords = GrTCast<SkPoint*>(GrTCast<intptr_t>(geo.vertices()) +
+ sizeof(SkPoint));
coords->setRectFan(localRect->fLeft, localRect->fTop,
localRect->fRight, localRect->fBottom,
vsize);
localMatrix->mapPointsWithStride(coords, vsize, 4);
}
}
- SkTLazy<SkRect> bounds;
- if (this->getDrawState().willEffectReadDstColor()) {
- bounds.init();
- this->getDrawState().getViewMatrix().mapRect(bounds.get(), rect);
- }
+ SkRect bounds;
+ this->getDrawState().getViewMatrix().mapRect(&bounds, rect);
- this->drawNonIndexed(kTriangleFan_GrPrimitiveType, 0, 4, bounds.getMaybeNull());
+ this->drawNonIndexed(kTriangleFan_GrPrimitiveType, 0, 4, &bounds);
}
void GrDrawTarget::clipWillBeSet(const GrClipData* clipData) {
fShaderDerivativeSupport = false;
fGeometryShaderSupport = false;
fDualSourceBlendingSupport = false;
- fBufferLockSupport = false;
fPathRenderingSupport = false;
fDstReadInShaderSupport = false;
+ fDiscardRenderTargetSupport = false;
fReuseScratchTextures = true;
+ fGpuTracingSupport = false;
+
+ fMapBufferFlags = kNone_MapFlags;
fMaxRenderTargetSize = 0;
fMaxTextureSize = 0;
fShaderDerivativeSupport = other.fShaderDerivativeSupport;
fGeometryShaderSupport = other.fGeometryShaderSupport;
fDualSourceBlendingSupport = other.fDualSourceBlendingSupport;
- fBufferLockSupport = other.fBufferLockSupport;
fPathRenderingSupport = other.fPathRenderingSupport;
fDstReadInShaderSupport = other.fDstReadInShaderSupport;
+ fDiscardRenderTargetSupport = other.fDiscardRenderTargetSupport;
fReuseScratchTextures = other.fReuseScratchTextures;
+ fGpuTracingSupport = other.fGpuTracingSupport;
+
+ fMapBufferFlags = other.fMapBufferFlags;
fMaxRenderTargetSize = other.fMaxRenderTargetSize;
fMaxTextureSize = other.fMaxTextureSize;
return *this;
}
+static SkString map_flags_to_string(uint32_t flags) {
+ SkString str;
+ if (GrDrawTargetCaps::kNone_MapFlags == flags) {
+ str = "none";
+ } else {
+ SkASSERT(GrDrawTargetCaps::kCanMap_MapFlag & flags);
+ SkDEBUGCODE(flags &= ~GrDrawTargetCaps::kCanMap_MapFlag);
+ str = "can_map";
+
+ if (GrDrawTargetCaps::kSubset_MapFlag & flags) {
+ str.append(" partial");
+ } else {
+ str.append(" full");
+ }
+ SkDEBUGCODE(flags &= ~GrDrawTargetCaps::kSubset_MapFlag);
+ }
+ SkASSERT(0 == flags); // Make sure we handled all the flags.
+ return str;
+}
+
SkString GrDrawTargetCaps::dump() const {
SkString r;
static const char* gNY[] = {"NO", "YES"};
- r.appendf("8 Bit Palette Support : %s\n", gNY[f8BitPaletteSupport]);
- r.appendf("MIP Map Support : %s\n", gNY[fMipMapSupport]);
- r.appendf("NPOT Texture Tile Support : %s\n", gNY[fNPOTTextureTileSupport]);
- r.appendf("Two Sided Stencil Support : %s\n", gNY[fTwoSidedStencilSupport]);
- r.appendf("Stencil Wrap Ops Support : %s\n", gNY[fStencilWrapOpsSupport]);
- r.appendf("HW AA Lines Support : %s\n", gNY[fHWAALineSupport]);
- r.appendf("Shader Derivative Support : %s\n", gNY[fShaderDerivativeSupport]);
- r.appendf("Geometry Shader Support : %s\n", gNY[fGeometryShaderSupport]);
- r.appendf("Dual Source Blending Support: %s\n", gNY[fDualSourceBlendingSupport]);
- r.appendf("Buffer Lock Support : %s\n", gNY[fBufferLockSupport]);
- r.appendf("Path Rendering Support : %s\n", gNY[fPathRenderingSupport]);
- r.appendf("Dst Read In Shader Support : %s\n", gNY[fDstReadInShaderSupport]);
- r.appendf("Reuse Scratch Textures : %s\n", gNY[fReuseScratchTextures]);
- r.appendf("Max Texture Size : %d\n", fMaxTextureSize);
- r.appendf("Max Render Target Size : %d\n", fMaxRenderTargetSize);
- r.appendf("Max Sample Count : %d\n", fMaxSampleCount);
+ r.appendf("8 Bit Palette Support : %s\n", gNY[f8BitPaletteSupport]);
+ r.appendf("MIP Map Support : %s\n", gNY[fMipMapSupport]);
+ r.appendf("NPOT Texture Tile Support : %s\n", gNY[fNPOTTextureTileSupport]);
+ r.appendf("Two Sided Stencil Support : %s\n", gNY[fTwoSidedStencilSupport]);
+ r.appendf("Stencil Wrap Ops Support : %s\n", gNY[fStencilWrapOpsSupport]);
+ r.appendf("HW AA Lines Support : %s\n", gNY[fHWAALineSupport]);
+ r.appendf("Shader Derivative Support : %s\n", gNY[fShaderDerivativeSupport]);
+ r.appendf("Geometry Shader Support : %s\n", gNY[fGeometryShaderSupport]);
+ r.appendf("Dual Source Blending Support : %s\n", gNY[fDualSourceBlendingSupport]);
+ r.appendf("Path Rendering Support : %s\n", gNY[fPathRenderingSupport]);
+ r.appendf("Dst Read In Shader Support : %s\n", gNY[fDstReadInShaderSupport]);
+ r.appendf("Discard Render Target Support: %s\n", gNY[fDiscardRenderTargetSupport]);
+ r.appendf("Reuse Scratch Textures : %s\n", gNY[fReuseScratchTextures]);
+ r.appendf("Gpu Tracing Support : %s\n", gNY[fGpuTracingSupport]);
+ r.appendf("Max Texture Size : %d\n", fMaxTextureSize);
+ r.appendf("Max Render Target Size : %d\n", fMaxRenderTargetSize);
+ r.appendf("Max Sample Count : %d\n", fMaxSampleCount);
+
+ r.appendf("Map Buffer Support : %s\n", map_flags_to_string(fMapBufferFlags).c_str());
static const char* kConfigNames[] = {
"Unknown", // kUnknown_GrPixelConfig