Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(232)

Unified Diff: src/gpu/GrDrawTarget.cpp

Issue 22686002: Implement path cover with nv_path_rendering (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: fix a comment Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrDrawTarget.h ('k') | src/gpu/GrDrawTargetCaps.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrDrawTarget.cpp
diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp
index c2256a84d8c7cf5cac2df1b09df4bd76b01e4f52..64eedfbef7716b08f716f2f2c33c9e9577e82eeb 100644
--- a/src/gpu/GrDrawTarget.cpp
+++ b/src/gpu/GrDrawTarget.cpp
@@ -11,6 +11,7 @@
#include "GrDrawTarget.h"
#include "GrContext.h"
#include "GrDrawTargetCaps.h"
+#include "GrPath.h"
#include "GrRenderTarget.h"
#include "GrTexture.h"
#include "GrVertexBuffer.h"
@@ -413,17 +414,18 @@ bool GrDrawTarget::checkDraw(GrPrimitiveType type, int startVertex,
return true;
}
-bool GrDrawTarget::setupDstReadIfNecessary(DrawInfo* info) {
+bool GrDrawTarget::setupDstReadIfNecessary(GrDeviceCoordTexture* dstCopy, const SkRect* drawBounds) {
if (this->caps()->dstReadInShaderSupport() || !this->getDrawState().willEffectReadDstColor()) {
return true;
}
GrRenderTarget* rt = this->drawState()->getRenderTarget();
-
- const GrClipData* clip = this->getClip();
SkIRect copyRect;
- clip->getConservativeBounds(this->getDrawState().getRenderTarget(), &copyRect);
- SkIRect drawIBounds;
- if (info->getDevIBounds(&drawIBounds)) {
+ const GrClipData* clip = this->getClip();
+ clip->getConservativeBounds(rt, &copyRect);
+
+ if (NULL != drawBounds) {
+ SkIRect drawIBounds;
+ drawBounds->roundOut(&drawIBounds);
if (!copyRect.intersect(drawIBounds)) {
#ifdef SK_DEBUG
GrPrintf("Missed an early reject. Bailing on draw from setupDstReadIfNecessary.\n");
@@ -451,8 +453,8 @@ bool GrDrawTarget::setupDstReadIfNecessary(DrawInfo* info) {
}
SkIPoint dstPoint = {0, 0};
if (this->copySurface(ast.texture(), rt, copyRect, dstPoint)) {
- info->fDstCopy.setTexture(ast.texture());
- info->fDstCopy.setOffset(copyRect.fLeft, copyRect.fTop);
+ dstCopy->setTexture(ast.texture());
+ dstCopy->setOffset(copyRect.fLeft, copyRect.fTop);
return true;
} else {
return false;
@@ -518,12 +520,37 @@ void GrDrawTarget::drawNonIndexed(GrPrimitiveType type,
void GrDrawTarget::stencilPath(const GrPath* path, const SkStrokeRec& stroke, SkPath::FillType fill) {
// TODO: extract portions of checkDraw that are relevant to path stenciling.
SkASSERT(NULL != path);
- SkASSERT(this->caps()->pathStencilingSupport());
+ SkASSERT(this->caps()->pathRenderingSupport());
SkASSERT(!stroke.isHairlineStyle());
SkASSERT(!SkPath::IsInverseFillType(fill));
this->onStencilPath(path, stroke, fill);
}
+void GrDrawTarget::fillPath(const GrPath* path, const SkStrokeRec& stroke, SkPath::FillType fill) {
+ // TODO: extract portions of checkDraw that are relevant to path rendering.
+ SkASSERT(NULL != path);
+ SkASSERT(this->caps()->pathRenderingSupport());
+ SkASSERT(!stroke.isHairlineStyle());
+ const GrDrawState* drawState = &getDrawState();
+
+ SkRect devBounds;
+ if (SkPath::IsInverseFillType(fill)) {
+ devBounds = SkRect::MakeWH(SkIntToScalar(drawState->getRenderTarget()->width()),
+ SkIntToScalar(drawState->getRenderTarget()->height()));
+ } else {
+ devBounds = path->getBounds();
+ }
+ SkMatrix viewM = drawState->getViewMatrix();
+ viewM.mapRect(&devBounds);
+
+ GrDeviceCoordTexture dstCopy;
+ if (!this->setupDstReadIfNecessary(&dstCopy, &devBounds)) {
+ return;
+ }
+
+ this->onFillPath(path, stroke, fill, dstCopy.texture() ? &dstCopy : NULL);
+}
+
////////////////////////////////////////////////////////////////////////////////
bool GrDrawTarget::willUseHWAALines() const {
@@ -949,7 +976,7 @@ void GrDrawTargetCaps::reset() {
fGeometryShaderSupport = false;
fDualSourceBlendingSupport = false;
fBufferLockSupport = false;
- fPathStencilingSupport = false;
+ fPathRenderingSupport = false;
fDstReadInShaderSupport = false;
fReuseScratchTextures = true;
@@ -968,7 +995,7 @@ GrDrawTargetCaps& GrDrawTargetCaps::operator=(const GrDrawTargetCaps& other) {
fGeometryShaderSupport = other.fGeometryShaderSupport;
fDualSourceBlendingSupport = other.fDualSourceBlendingSupport;
fBufferLockSupport = other.fBufferLockSupport;
- fPathStencilingSupport = other.fPathStencilingSupport;
+ fPathRenderingSupport = other.fPathRenderingSupport;
fDstReadInShaderSupport = other.fDstReadInShaderSupport;
fReuseScratchTextures = other.fReuseScratchTextures;
@@ -990,7 +1017,7 @@ void GrDrawTargetCaps::print() const {
GrPrintf("Geometry Shader Support : %s\n", gNY[fGeometryShaderSupport]);
GrPrintf("Dual Source Blending Support: %s\n", gNY[fDualSourceBlendingSupport]);
GrPrintf("Buffer Lock Support : %s\n", gNY[fBufferLockSupport]);
- GrPrintf("Path Stenciling Support : %s\n", gNY[fPathStencilingSupport]);
+ GrPrintf("Path Rendering Support : %s\n", gNY[fPathRenderingSupport]);
GrPrintf("Dst Read In Shader Support : %s\n", gNY[fDstReadInShaderSupport]);
GrPrintf("Reuse Scratch Textures : %s\n", gNY[fReuseScratchTextures]);
GrPrintf("Max Texture Size : %d\n", fMaxTextureSize);
« no previous file with comments | « src/gpu/GrDrawTarget.h ('k') | src/gpu/GrDrawTargetCaps.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698