aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/gpu/GrCoordTransform.cpp4
-rw-r--r--src/gpu/GrCoordTransform.h32
-rw-r--r--src/gpu/GrOpList.h1
-rw-r--r--src/gpu/GrProcessor.cpp29
-rw-r--r--src/gpu/GrProcessor.h27
-rw-r--r--src/gpu/GrRenderTargetOpList.h4
-rw-r--r--src/gpu/GrSurfacePriv.h2
-rw-r--r--src/gpu/effects/GrBitmapTextGeoProc.cpp2
-rw-r--r--src/gpu/effects/GrDistanceFieldGeoProc.cpp4
-rw-r--r--src/gpu/effects/GrSingleTextureEffect.h5
-rw-r--r--src/gpu/effects/GrTextureDomain.cpp2
-rw-r--r--src/gpu/gl/GrGLTexture.cpp1
-rw-r--r--src/gpu/glsl/GrGLSLPrimitiveProcessor.cpp4
-rw-r--r--tests/ProcessorTest.cpp1
14 files changed, 48 insertions, 70 deletions
diff --git a/src/gpu/GrCoordTransform.cpp b/src/gpu/GrCoordTransform.cpp
index 4767e53d69..de8b8cc168 100644
--- a/src/gpu/GrCoordTransform.cpp
+++ b/src/gpu/GrCoordTransform.cpp
@@ -16,9 +16,7 @@ void GrCoordTransform::reset(GrResourceProvider* resourceProvider, const SkMatri
fMatrix = m;
// MDB TODO: just GrCaps is needed for this method
- // MDB TODO: once all the coord transforms take a proxy just store it here and
- // instantiate later
- fTexture = proxy->instantiateTexture(resourceProvider);
+ fProxy = proxy;
fNormalize = normalize;
fReverseY = kBottomLeft_GrSurfaceOrigin == proxy->origin();
}
diff --git a/src/gpu/GrCoordTransform.h b/src/gpu/GrCoordTransform.h
index 54c21b7472..325dbbd94b 100644
--- a/src/gpu/GrCoordTransform.h
+++ b/src/gpu/GrCoordTransform.h
@@ -9,10 +9,11 @@
#define GrCoordTransform_DEFINED
#include "SkMatrix.h"
+#include "GrSurfaceProxyPriv.h"
#include "GrTexture.h"
+#include "GrTextureProxy.h"
class GrResourceProvider;
-class GrTextureProxy;
/**
* A class representing a linear transformation of local coordinates. GrFragnentProcessors
@@ -21,7 +22,7 @@ class GrTextureProxy;
class GrCoordTransform : SkNoncopyable {
public:
GrCoordTransform()
- : fTexture(nullptr)
+ : fProxy(nullptr)
, fNormalize(false)
, fReverseY(false) {
SkDEBUGCODE(fInProcessor = false);
@@ -34,7 +35,7 @@ public:
GrCoordTransform(GrResourceProvider* resourceProvider, GrTextureProxy* proxy) {
SkASSERT(proxy);
SkDEBUGCODE(fInProcessor = false);
- this->reset(resourceProvider, SkMatrix::I(), proxy);
+ this->reset(resourceProvider, SkMatrix::I(), proxy, true);
}
/**
@@ -45,7 +46,7 @@ public:
GrTextureProxy* proxy) {
SkASSERT(proxy);
SkDEBUGCODE(fInProcessor = false);
- this->reset(resourceProvider, m, proxy);
+ this->reset(resourceProvider, m, proxy, true);
}
/**
@@ -56,12 +57,12 @@ public:
this->reset(m);
}
- void reset(GrResourceProvider*, const SkMatrix&, GrTextureProxy*, bool normalize = true);
+ void reset(GrResourceProvider*, const SkMatrix&, GrTextureProxy*, bool normalize);
void reset(const SkMatrix& m) {
SkASSERT(!fInProcessor);
fMatrix = m;
- fTexture = nullptr;
+ fProxy = nullptr;
fNormalize = false;
fReverseY = false;
}
@@ -69,7 +70,7 @@ public:
GrCoordTransform& operator= (const GrCoordTransform& that) {
SkASSERT(!fInProcessor);
fMatrix = that.fMatrix;
- fTexture = that.fTexture;
+ fProxy = that.fProxy;
fNormalize = that.fNormalize;
fReverseY = that.fReverseY;
return *this;
@@ -92,19 +93,26 @@ public:
}
if (fNormalize) {
- SkASSERT(fTexture && that.fTexture);
- return fTexture->width() == that.fTexture->width() &&
- fTexture->height() == that.fTexture->height();
+ if (fProxy != that.fProxy) {
+ return false;
+ }
}
return true;
}
const SkMatrix& getMatrix() const { return fMatrix; }
- const GrTexture* texture() const { return fTexture; }
+ const GrTextureProxy* proxy() const { return fProxy; }
bool normalize() const { return fNormalize; }
bool reverseY() const { return fReverseY; }
+ // This should only ever be called at flush time after the backing texture has been
+ // successfully instantiated
+ GrTexture* peekTexture() const {
+ SkASSERT(fProxy->priv().peekTexture());
+ return fProxy->priv().peekTexture();
+ }
+
private:
// The textures' effect is to optionally normalize the final matrix, so a blind
// equality check could be misleading
@@ -112,7 +120,7 @@ private:
bool operator!=(const GrCoordTransform& that) const;
SkMatrix fMatrix;
- const GrTexture* fTexture;
+ const GrTextureProxy* fProxy;
bool fNormalize;
bool fReverseY;
typedef SkNoncopyable INHERITED;
diff --git a/src/gpu/GrOpList.h b/src/gpu/GrOpList.h
index ced1395114..dc624415d1 100644
--- a/src/gpu/GrOpList.h
+++ b/src/gpu/GrOpList.h
@@ -21,6 +21,7 @@ class GrOpFlushState;
class GrRenderTargetOpList;
class GrResourceProvider;
class GrSurfaceProxy;
+class GrTextureProxy;
class GrTextureOpList;
class GrOpList : public SkRefCnt {
diff --git a/src/gpu/GrProcessor.cpp b/src/gpu/GrProcessor.cpp
index 0bce078784..51cfdfb73c 100644
--- a/src/gpu/GrProcessor.cpp
+++ b/src/gpu/GrProcessor.cpp
@@ -143,7 +143,7 @@ void GrResourceIOProcessor::addImageStorageAccess(GrResourceProvider* resourcePr
void GrResourceIOProcessor::addPendingIOs() const {
for (const auto& sampler : fTextureSamplers) {
- sampler->programTexture()->markPendingIO();
+ sampler->programProxy()->markPendingIO();
}
for (const auto& buffer : fBufferAccesses) {
buffer->programBuffer()->markPendingIO();
@@ -155,7 +155,7 @@ void GrResourceIOProcessor::addPendingIOs() const {
void GrResourceIOProcessor::removeRefs() const {
for (const auto& sampler : fTextureSamplers) {
- sampler->programTexture()->removeRef();
+ sampler->programProxy()->removeRef();
}
for (const auto& buffer : fBufferAccesses) {
buffer->programBuffer()->removeRef();
@@ -167,7 +167,7 @@ void GrResourceIOProcessor::removeRefs() const {
void GrResourceIOProcessor::pendingIOComplete() const {
for (const auto& sampler : fTextureSamplers) {
- sampler->programTexture()->pendingIOComplete();
+ sampler->programProxy()->pendingIOComplete();
}
for (const auto& buffer : fBufferAccesses) {
buffer->programBuffer()->pendingIOComplete();
@@ -242,16 +242,8 @@ void GrResourceIOProcessor::TextureSampler::reset(GrResourceProvider* resourcePr
const GrSamplerParams& params,
GrShaderFlags visibility) {
fParams = params;
-
- // For now, end the deferral at this time. Once all the TextureSamplers are swapped over
- // to taking a GrSurfaceProxy just use the IORefs on the proxy
- GrTexture* texture = proxy->instantiateTexture(resourceProvider);
- if (texture) {
- fTexture.set(SkRef(texture), kRead_GrIOType);
- SkASSERT(texture->texturePriv().highestFilterMode() == proxy->highestFilterMode());
- fParams.setFilterMode(SkTMin(params.filterMode(), proxy->highestFilterMode()));
- }
-
+ fProxyRef.setProxy(std::move(proxy), kRead_GrIOType);
+ fParams.setFilterMode(SkTMin(params.filterMode(), this->proxy()->highestFilterMode()));
fVisibility = visibility;
}
@@ -260,15 +252,8 @@ void GrResourceIOProcessor::TextureSampler::reset(GrResourceProvider* resourcePr
GrSamplerParams::FilterMode filterMode,
SkShader::TileMode tileXAndY,
GrShaderFlags visibility) {
- // For now, end the deferral at this time. Once all the TextureSamplers are swapped over
- // to taking a GrSurfaceProxy just use the IORefs on the proxy
- GrTexture* texture = proxy->instantiateTexture(resourceProvider);
- if (texture) {
- fTexture.set(SkRef(texture), kRead_GrIOType);
- SkASSERT(texture->texturePriv().highestFilterMode() == proxy->highestFilterMode());
- filterMode = SkTMin(filterMode, proxy->highestFilterMode());
- }
-
+ fProxyRef.setProxy(std::move(proxy), kRead_GrIOType);
+ filterMode = SkTMin(filterMode, this->proxy()->highestFilterMode());
fParams.reset(tileXAndY, filterMode);
fVisibility = visibility;
}
diff --git a/src/gpu/GrProcessor.h b/src/gpu/GrProcessor.h
index 0cf4fb1370..7a12b6c196 100644
--- a/src/gpu/GrProcessor.h
+++ b/src/gpu/GrProcessor.h
@@ -233,50 +233,37 @@ public:
GrShaderFlags visibility = kFragment_GrShaderFlag);
bool operator==(const TextureSampler& that) const {
- return this->texture() == that.texture() &&
+ return this->proxy() == that.proxy() &&
fParams == that.fParams &&
fVisibility == that.fVisibility;
}
bool operator!=(const TextureSampler& other) const { return !(*this == other); }
- // MDB TODO: remove the remaining callers of this accessor
- GrTexture* texture() const { return fTexture.get(); }
-
// 'instantiate' should only ever be called at flush time.
bool instantiate(GrResourceProvider* resourceProvider) const {
- // MDB TODO: return SkToBool(fProxy->instantiate(resourceProvider));
- // and remove the following 2 lines
- SkDEBUGCODE(fInstantiated = true;)
- return SkToBool(fTexture.get());
+ return SkToBool(fProxyRef.get()->instantiate(resourceProvider));
}
// 'peekTexture' should only ever be called after a successful 'instantiate' call
GrTexture* peekTexture() const {
- // MDB TODO:
- // SkASSERT(fProxy->priv().peekTexture());
- // return fProxy->priv().peekTexture();
- // and remove the following 3 lines:
- SkASSERT(fInstantiated);
- SkASSERT(fTexture.get());
- return fTexture.get();
+ SkASSERT(fProxyRef.get()->priv().peekTexture());
+ return fProxyRef.get()->priv().peekTexture();
}
+ GrTextureProxy* proxy() const { return fProxyRef.get()->asTextureProxy(); }
GrShaderFlags visibility() const { return fVisibility; }
const GrSamplerParams& params() const { return fParams; }
/**
* For internal use by GrProcessor.
*/
- const GrGpuResourceRef* programTexture() const { return &fTexture; }
+ const GrSurfaceProxyRef* programProxy() const { return &fProxyRef; }
private:
- typedef GrTGpuResourceRef<GrTexture> ProgramTexture;
-
- ProgramTexture fTexture;
+ GrSurfaceProxyRef fProxyRef;
GrSamplerParams fParams;
GrShaderFlags fVisibility;
- SkDEBUGCODE(mutable bool fInstantiated = false;) // MDB TODO: remove this line
typedef SkNoncopyable INHERITED;
};
diff --git a/src/gpu/GrRenderTargetOpList.h b/src/gpu/GrRenderTargetOpList.h
index 216ede451e..6945f47df4 100644
--- a/src/gpu/GrRenderTargetOpList.h
+++ b/src/gpu/GrRenderTargetOpList.h
@@ -120,8 +120,8 @@ private:
}
}
std::unique_ptr<GrOp> fOp;
- DstProxy fDstProxy;
- const GrAppliedClip* fAppliedClip;
+ DstProxy fDstProxy;
+ const GrAppliedClip* fAppliedClip;
};
// If the input op is combined with an earlier op, this returns the combined op. Otherwise, it
diff --git a/src/gpu/GrSurfacePriv.h b/src/gpu/GrSurfacePriv.h
index c7ae6a4149..ce144c8a01 100644
--- a/src/gpu/GrSurfacePriv.h
+++ b/src/gpu/GrSurfacePriv.h
@@ -17,7 +17,7 @@
implemented privately in GrSurface with a inline public method here). */
class GrSurfacePriv {
public:
- /** Helpers used in read/write pixels implementations. The paramters are adjusted so that the
+ /** Helpers used in read/write pixels implementations. The parameters are adjusted so that the
read/write respects the bounds of a surface. If the input *rowBytes is 0 it will be
the tight row bytes (based on width and bpp) on output. */
static bool AdjustReadPixelParams(int surfaceWidth,
diff --git a/src/gpu/effects/GrBitmapTextGeoProc.cpp b/src/gpu/effects/GrBitmapTextGeoProc.cpp
index 93b4a0f836..eb9b7b8c7d 100644
--- a/src/gpu/effects/GrBitmapTextGeoProc.cpp
+++ b/src/gpu/effects/GrBitmapTextGeoProc.cpp
@@ -98,7 +98,7 @@ public:
// Currently we hardcode numbers to convert atlas coordinates to normalized floating point
SkASSERT(gp.numTextureSamplers() == 1);
- GrTexture* atlas = gp.textureSampler(0).texture();
+ GrTextureProxy* atlas = gp.textureSampler(0).proxy();
if (atlas) {
b->add32(atlas->width());
b->add32(atlas->height());
diff --git a/src/gpu/effects/GrDistanceFieldGeoProc.cpp b/src/gpu/effects/GrDistanceFieldGeoProc.cpp
index 6101c4115f..51c4b55c83 100644
--- a/src/gpu/effects/GrDistanceFieldGeoProc.cpp
+++ b/src/gpu/effects/GrDistanceFieldGeoProc.cpp
@@ -202,7 +202,7 @@ public:
// Currently we hardcode numbers to convert atlas coordinates to normalized floating point
SkASSERT(gp.numTextureSamplers() == 1);
- GrTexture* atlas = gp.textureSampler(0).texture();
+ GrTextureProxy* atlas = gp.textureSampler(0).proxy();
if (atlas) {
b->add32(atlas->width());
b->add32(atlas->height());
@@ -757,7 +757,7 @@ public:
// Currently we hardcode numbers to convert atlas coordinates to normalized floating point
SkASSERT(gp.numTextureSamplers() == 1);
- GrTexture* atlas = gp.textureSampler(0).texture();
+ GrTextureProxy* atlas = gp.textureSampler(0).proxy();
if (atlas) {
b->add32(atlas->width());
b->add32(atlas->height());
diff --git a/src/gpu/effects/GrSingleTextureEffect.h b/src/gpu/effects/GrSingleTextureEffect.h
index d3ba0157e7..8c16d3342d 100644
--- a/src/gpu/effects/GrSingleTextureEffect.h
+++ b/src/gpu/effects/GrSingleTextureEffect.h
@@ -24,10 +24,7 @@ class GrSingleTextureEffect : public GrFragmentProcessor {
public:
SkString dumpInfo() const override {
SkString str;
- // MDB TODO: this should just print out the uniqueID of the proxy
- str.appendf("Texture: %d", fTextureSampler.peekTexture()
- ? fTextureSampler.peekTexture()->uniqueID().asUInt()
- : -1);
+ str.appendf("Texture: %d", fTextureSampler.proxy()->uniqueID().asUInt());
return str;
}
diff --git a/src/gpu/effects/GrTextureDomain.cpp b/src/gpu/effects/GrTextureDomain.cpp
index 1a6db7a9af..ebe4f040ac 100644
--- a/src/gpu/effects/GrTextureDomain.cpp
+++ b/src/gpu/effects/GrTextureDomain.cpp
@@ -441,7 +441,7 @@ GrGLSLFragmentProcessor* GrDeviceSpaceTextureDecalFragmentProcessor::onCreateGLS
bool GrDeviceSpaceTextureDecalFragmentProcessor::onIsEqual(const GrFragmentProcessor& fp) const {
const GrDeviceSpaceTextureDecalFragmentProcessor& dstdfp =
fp.cast<GrDeviceSpaceTextureDecalFragmentProcessor>();
- return dstdfp.fTextureSampler.texture() == fTextureSampler.texture() &&
+ return dstdfp.fTextureSampler.proxy() == fTextureSampler.proxy() &&
dstdfp.fDeviceSpaceOffset == fDeviceSpaceOffset &&
dstdfp.fTextureDomain == fTextureDomain;
}
diff --git a/src/gpu/gl/GrGLTexture.cpp b/src/gpu/gl/GrGLTexture.cpp
index ccbd1a6dae..c93ff41ec6 100644
--- a/src/gpu/gl/GrGLTexture.cpp
+++ b/src/gpu/gl/GrGLTexture.cpp
@@ -33,6 +33,7 @@ static inline GrSLType sampler_type(const GrGLTexture::IDDesc& idDesc, GrPixelCo
}
}
+// This method parallels GrTextureProxy::highestFilterMode
static inline GrSamplerParams::FilterMode highest_filter_mode(const GrGLTexture::IDDesc& idDesc,
GrPixelConfig config) {
if (GrPixelConfigIsSint(config)) {
diff --git a/src/gpu/glsl/GrGLSLPrimitiveProcessor.cpp b/src/gpu/glsl/GrGLSLPrimitiveProcessor.cpp
index d32766c3fc..7c6b2d432e 100644
--- a/src/gpu/glsl/GrGLSLPrimitiveProcessor.cpp
+++ b/src/gpu/glsl/GrGLSLPrimitiveProcessor.cpp
@@ -18,8 +18,8 @@ SkMatrix GrGLSLPrimitiveProcessor::GetTransformMatrix(const SkMatrix& localMatri
SkMatrix combined;
combined.setConcat(coordTransform.getMatrix(), localMatrix);
if (coordTransform.normalize()) {
- SkASSERT(coordTransform.texture());
- combined.postIDiv(coordTransform.texture()->width(), coordTransform.texture()->height());
+ combined.postIDiv(coordTransform.peekTexture()->width(),
+ coordTransform.peekTexture()->height());
}
if (coordTransform.reverseY()) {
diff --git a/tests/ProcessorTest.cpp b/tests/ProcessorTest.cpp
index 41bb183884..528dd61562 100644
--- a/tests/ProcessorTest.cpp
+++ b/tests/ProcessorTest.cpp
@@ -447,6 +447,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ProcessorOptimizationValidationTest, repor
}
}
}
+
#endif // GR_TEST_UTILS
#endif // SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
#endif // SK_SUPPORT_GPU