Revert "Rm readPixels from GrSurface & move read/writeSurfacePixels to GrContextPriv"
This reverts commit fb0bd98a43
.
Reason for revert: ANGLE failures
Original change's description:
> Rm readPixels from GrSurface & move read/writeSurfacePixels to GrContextPriv
>
> This is in service of: https://skia-review.googlesource.com/c/11125/ (Add parallel proxyID to StencilOps & RenderTargetOpList) where I want a better choke point for texture creation to improve discard handling.
>
> Change-Id: If57a7de47edc0853dae7bc61337d9acdc03d63b0
> Reviewed-on: https://skia-review.googlesource.com/11200
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Robert Phillips <robertphillips@google.com>
>
TBR=bsalomon@google.com,robertphillips@google.com,reviews@skia.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
Change-Id: I7241070dc1f9df47181061e07adab141f9857974
Reviewed-on: https://skia-review.googlesource.com/11324
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
parent
1cfcf2b167
commit
171cc5fc87
@ -246,6 +246,68 @@ public:
|
|||||||
*/
|
*/
|
||||||
void flush();
|
void flush();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* These flags can be used with the read/write pixels functions below.
|
||||||
|
*/
|
||||||
|
enum PixelOpsFlags {
|
||||||
|
/** The GrContext will not be flushed before the surface read or write. This means that
|
||||||
|
the read or write may occur before previous draws have executed. */
|
||||||
|
kDontFlush_PixelOpsFlag = 0x1,
|
||||||
|
/** Any surface writes should be flushed to the backend 3D API after the surface operation
|
||||||
|
is complete */
|
||||||
|
kFlushWrites_PixelOp = 0x2,
|
||||||
|
/** The src for write or dst read is unpremultiplied. This is only respected if both the
|
||||||
|
config src and dst configs are an RGBA/BGRA 8888 format. */
|
||||||
|
kUnpremul_PixelOpsFlag = 0x4,
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads a rectangle of pixels from a surface.
|
||||||
|
* @param surface the surface to read from.
|
||||||
|
* @param srcColorSpace color space of the surface
|
||||||
|
* @param left left edge of the rectangle to read (inclusive)
|
||||||
|
* @param top top edge of the rectangle to read (inclusive)
|
||||||
|
* @param width width of rectangle to read in pixels.
|
||||||
|
* @param height height of rectangle to read in pixels.
|
||||||
|
* @param config the pixel config of the destination buffer
|
||||||
|
* @param dstColorSpace color space of the destination buffer
|
||||||
|
* @param buffer memory to read the rectangle into.
|
||||||
|
* @param rowBytes number of bytes bewtween consecutive rows. Zero means rows are tightly
|
||||||
|
* packed.
|
||||||
|
* @param pixelOpsFlags see PixelOpsFlags enum above.
|
||||||
|
*
|
||||||
|
* @return true if the read succeeded, false if not. The read can fail because of an unsupported
|
||||||
|
* pixel configs
|
||||||
|
*/
|
||||||
|
bool readSurfacePixels(GrSurface* surface, SkColorSpace* srcColorSpace,
|
||||||
|
int left, int top, int width, int height,
|
||||||
|
GrPixelConfig config, SkColorSpace* dstColorSpace, void* buffer,
|
||||||
|
size_t rowBytes = 0,
|
||||||
|
uint32_t pixelOpsFlags = 0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes a rectangle of pixels to a surface.
|
||||||
|
* @param surface the surface to write to.
|
||||||
|
* @param dstColorSpace color space of the surface
|
||||||
|
* @param left left edge of the rectangle to write (inclusive)
|
||||||
|
* @param top top edge of the rectangle to write (inclusive)
|
||||||
|
* @param width width of rectangle to write in pixels.
|
||||||
|
* @param height height of rectangle to write in pixels.
|
||||||
|
* @param config the pixel config of the source buffer
|
||||||
|
* @param srcColorSpace color space of the source buffer
|
||||||
|
* @param buffer memory to read pixels from
|
||||||
|
* @param rowBytes number of bytes between consecutive rows. Zero
|
||||||
|
* means rows are tightly packed.
|
||||||
|
* @param pixelOpsFlags see PixelOpsFlags enum above.
|
||||||
|
* @return true if the write succeeded, false if not. The write can fail because of an
|
||||||
|
* unsupported combination of surface and src configs.
|
||||||
|
*/
|
||||||
|
bool writeSurfacePixels(GrSurface* surface, SkColorSpace* dstColorSpace,
|
||||||
|
int left, int top, int width, int height,
|
||||||
|
GrPixelConfig config, SkColorSpace* srcColorSpace, const void* buffer,
|
||||||
|
size_t rowBytes,
|
||||||
|
uint32_t pixelOpsFlags = 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An ID associated with this context, guaranteed to be unique.
|
* An ID associated with this context, guaranteed to be unique.
|
||||||
*/
|
*/
|
||||||
|
@ -49,12 +49,12 @@ struct GrProcessorTestData {
|
|||||||
GrProcessorTestData(SkRandom* random,
|
GrProcessorTestData(SkRandom* random,
|
||||||
GrContext* context,
|
GrContext* context,
|
||||||
const GrRenderTargetContext* renderTargetContext,
|
const GrRenderTargetContext* renderTargetContext,
|
||||||
sk_sp<GrTextureProxy> proxies[2])
|
GrTexture* const textures[2])
|
||||||
: fRandom(random)
|
: fRandom(random)
|
||||||
, fRenderTargetContext(renderTargetContext)
|
, fRenderTargetContext(renderTargetContext)
|
||||||
, fContext(context) {
|
, fContext(context) {
|
||||||
fProxies[0] = proxies[0];
|
fProxies[0] = GrSurfaceProxy::MakeWrapped(sk_ref_sp(textures[0]));
|
||||||
fProxies[1] = proxies[1];
|
fProxies[1] = GrSurfaceProxy::MakeWrapped(sk_ref_sp(textures[1]));
|
||||||
}
|
}
|
||||||
SkRandom* fRandom;
|
SkRandom* fRandom;
|
||||||
const GrRenderTargetContext* fRenderTargetContext;
|
const GrRenderTargetContext* fRenderTargetContext;
|
||||||
|
@ -66,6 +66,106 @@ public:
|
|||||||
virtual GrRenderTarget* asRenderTarget() { return NULL; }
|
virtual GrRenderTarget* asRenderTarget() { return NULL; }
|
||||||
virtual const GrRenderTarget* asRenderTarget() const { return NULL; }
|
virtual const GrRenderTarget* asRenderTarget() const { return NULL; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads a rectangle of pixels from the surface, possibly performing color space conversion.
|
||||||
|
* @param srcColorSpace color space of the source data (this surface)
|
||||||
|
* @param left left edge of the rectangle to read (inclusive)
|
||||||
|
* @param top top edge of the rectangle to read (inclusive)
|
||||||
|
* @param width width of rectangle to read in pixels.
|
||||||
|
* @param height height of rectangle to read in pixels.
|
||||||
|
* @param config the pixel config of the destination buffer
|
||||||
|
* @param dstColorSpace color space of the destination buffer
|
||||||
|
* @param buffer memory to read the rectangle into.
|
||||||
|
* @param rowBytes number of bytes between consecutive rows. Zero means rows are tightly
|
||||||
|
* packed.
|
||||||
|
* @param pixelOpsFlags See the GrContext::PixelOpsFlags enum.
|
||||||
|
*
|
||||||
|
* @return true if the read succeeded, false if not. The read can fail because of an unsupported
|
||||||
|
* pixel config.
|
||||||
|
*/
|
||||||
|
bool readPixels(SkColorSpace* srcColorSpace,
|
||||||
|
int left, int top, int width, int height,
|
||||||
|
GrPixelConfig config,
|
||||||
|
SkColorSpace* dstColorSpace,
|
||||||
|
void* buffer,
|
||||||
|
size_t rowBytes = 0,
|
||||||
|
uint32_t pixelOpsFlags = 0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads a rectangle of pixels from the surface. Does not perform any color space conversion.
|
||||||
|
* @param left left edge of the rectangle to read (inclusive)
|
||||||
|
* @param top top edge of the rectangle to read (inclusive)
|
||||||
|
* @param width width of rectangle to read in pixels.
|
||||||
|
* @param height height of rectangle to read in pixels.
|
||||||
|
* @param config the pixel config of the destination buffer
|
||||||
|
* @param buffer memory to read the rectangle into.
|
||||||
|
* @param rowBytes number of bytes between consecutive rows. Zero means rows are tightly
|
||||||
|
* packed.
|
||||||
|
* @param pixelOpsFlags See the GrContext::PixelOpsFlags enum.
|
||||||
|
*
|
||||||
|
* @return true if the read succeeded, false if not. The read can fail because of an unsupported
|
||||||
|
* pixel config.
|
||||||
|
*/
|
||||||
|
bool readPixels(int left, int top, int width, int height,
|
||||||
|
GrPixelConfig config,
|
||||||
|
void* buffer,
|
||||||
|
size_t rowBytes = 0,
|
||||||
|
uint32_t pixelOpsFlags = 0) {
|
||||||
|
return this->readPixels(nullptr, left, top, width, height, config, nullptr, buffer,
|
||||||
|
rowBytes, pixelOpsFlags);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copy the src pixels [buffer, rowbytes, pixelconfig] into the surface at the specified
|
||||||
|
* rectangle, possibly performing color space conversion.
|
||||||
|
* @param dstColorSpace color space of the destination (this surface)
|
||||||
|
* @param left left edge of the rectangle to write (inclusive)
|
||||||
|
* @param top top edge of the rectangle to write (inclusive)
|
||||||
|
* @param width width of rectangle to write in pixels.
|
||||||
|
* @param height height of rectangle to write in pixels.
|
||||||
|
* @param config the pixel config of the source buffer
|
||||||
|
* @param srcColorSpace color space of the source buffer
|
||||||
|
* @param buffer memory to read the rectangle from.
|
||||||
|
* @param rowBytes number of bytes between consecutive rows. Zero means rows are tightly
|
||||||
|
* packed.
|
||||||
|
* @param pixelOpsFlags See the GrContext::PixelOpsFlags enum.
|
||||||
|
*
|
||||||
|
* @return true if the write succeeded, false if not. The write can fail because of an
|
||||||
|
* unsupported pixel config.
|
||||||
|
*/
|
||||||
|
bool writePixels(SkColorSpace* dstColorSpace,
|
||||||
|
int left, int top, int width, int height,
|
||||||
|
GrPixelConfig config,
|
||||||
|
SkColorSpace* srcColorSpace,
|
||||||
|
const void* buffer,
|
||||||
|
size_t rowBytes = 0,
|
||||||
|
uint32_t pixelOpsFlags = 0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copy the src pixels [buffer, rowbytes, pixelconfig] into the surface at the specified
|
||||||
|
* rectangle. Does not perform any color space conversion.
|
||||||
|
* @param left left edge of the rectangle to write (inclusive)
|
||||||
|
* @param top top edge of the rectangle to write (inclusive)
|
||||||
|
* @param width width of rectangle to write in pixels.
|
||||||
|
* @param height height of rectangle to write in pixels.
|
||||||
|
* @param config the pixel config of the source buffer
|
||||||
|
* @param buffer memory to read the rectangle from.
|
||||||
|
* @param rowBytes number of bytes between consecutive rows. Zero means rows are tightly
|
||||||
|
* packed.
|
||||||
|
* @param pixelOpsFlags See the GrContext::PixelOpsFlags enum.
|
||||||
|
*
|
||||||
|
* @return true if the write succeeded, false if not. The write can fail because of an
|
||||||
|
* unsupported pixel config.
|
||||||
|
*/
|
||||||
|
bool writePixels(int left, int top, int width, int height,
|
||||||
|
GrPixelConfig config,
|
||||||
|
const void* buffer,
|
||||||
|
size_t rowBytes = 0,
|
||||||
|
uint32_t pixelOpsFlags = 0) {
|
||||||
|
return this->writePixels(nullptr, left, top, width, height, config, nullptr, buffer,
|
||||||
|
rowBytes, pixelOpsFlags);
|
||||||
|
}
|
||||||
|
|
||||||
/** Access methods that are only to be used within Skia code. */
|
/** Access methods that are only to be used within Skia code. */
|
||||||
inline GrSurfacePriv surfacePriv();
|
inline GrSurfacePriv surfacePriv();
|
||||||
inline const GrSurfacePriv surfacePriv() const;
|
inline const GrSurfacePriv surfacePriv() const;
|
||||||
|
@ -26,8 +26,6 @@
|
|||||||
#include "effects/GrConfigConversionEffect.h"
|
#include "effects/GrConfigConversionEffect.h"
|
||||||
#include "text/GrTextBlobCache.h"
|
#include "text/GrTextBlobCache.h"
|
||||||
|
|
||||||
#define ASSERT_OWNED_PROXY(P) \
|
|
||||||
SkASSERT(!(P) || !((P)->priv().peekTexture()) || (P)->priv().peekTexture()->getContext() == this)
|
|
||||||
#define ASSERT_OWNED_PROXY_PRIV(P) \
|
#define ASSERT_OWNED_PROXY_PRIV(P) \
|
||||||
SkASSERT(!(P) || !((P)->priv().peekTexture()) || (P)->priv().peekTexture()->getContext() == fContext)
|
SkASSERT(!(P) || !((P)->priv().peekTexture()) || (P)->priv().peekTexture()->getContext() == fContext)
|
||||||
|
|
||||||
@ -39,7 +37,6 @@ SkASSERT(!(P) || !((P)->priv().peekTexture()) || (P)->priv().peekTexture()->getC
|
|||||||
#define RETURN_IF_ABANDONED if (fDrawingManager->wasAbandoned()) { return; }
|
#define RETURN_IF_ABANDONED if (fDrawingManager->wasAbandoned()) { return; }
|
||||||
#define RETURN_IF_ABANDONED_PRIV if (fContext->fDrawingManager->wasAbandoned()) { return; }
|
#define RETURN_IF_ABANDONED_PRIV if (fContext->fDrawingManager->wasAbandoned()) { return; }
|
||||||
#define RETURN_FALSE_IF_ABANDONED if (fDrawingManager->wasAbandoned()) { return false; }
|
#define RETURN_FALSE_IF_ABANDONED if (fDrawingManager->wasAbandoned()) { return false; }
|
||||||
#define RETURN_FALSE_IF_ABANDONED_PRIV if (fContext->fDrawingManager->wasAbandoned()) { return false; }
|
|
||||||
#define RETURN_NULL_IF_ABANDONED if (fDrawingManager->wasAbandoned()) { return nullptr; }
|
#define RETURN_NULL_IF_ABANDONED if (fDrawingManager->wasAbandoned()) { return nullptr; }
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -267,25 +264,19 @@ static bool valid_unpremul_config(GrPixelConfig config) {
|
|||||||
return GrPixelConfigIs8888Unorm(config) || kRGBA_half_GrPixelConfig == config;
|
return GrPixelConfigIs8888Unorm(config) || kRGBA_half_GrPixelConfig == config;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GrContextPriv::writeSurfacePixels(GrSurfaceProxy* srcProxy, SkColorSpace* dstColorSpace,
|
bool GrContext::writeSurfacePixels(GrSurface* surface, SkColorSpace* dstColorSpace,
|
||||||
int left, int top, int width, int height,
|
int left, int top, int width, int height,
|
||||||
GrPixelConfig srcConfig, SkColorSpace* srcColorSpace,
|
GrPixelConfig srcConfig, SkColorSpace* srcColorSpace,
|
||||||
const void* buffer, size_t rowBytes,
|
const void* buffer, size_t rowBytes, uint32_t pixelOpsFlags) {
|
||||||
uint32_t pixelOpsFlags) {
|
|
||||||
// TODO: Color space conversion
|
// TODO: Color space conversion
|
||||||
|
|
||||||
ASSERT_SINGLE_OWNER_PRIV
|
ASSERT_SINGLE_OWNER
|
||||||
RETURN_FALSE_IF_ABANDONED_PRIV
|
RETURN_FALSE_IF_ABANDONED
|
||||||
ASSERT_OWNED_PROXY_PRIV(srcProxy);
|
ASSERT_OWNED_RESOURCE(surface);
|
||||||
SkASSERT(srcProxy);
|
SkASSERT(surface);
|
||||||
GR_AUDIT_TRAIL_AUTO_FRAME(&fContext->fAuditTrail, "GrContextPriv::writeSurfacePixels");
|
GR_AUDIT_TRAIL_AUTO_FRAME(&fAuditTrail, "GrContext::writeSurfacePixels");
|
||||||
|
|
||||||
GrSurface* surface = srcProxy->instantiate(fContext->resourceProvider());
|
this->testPMConversionsIfNecessary(pixelOpsFlags);
|
||||||
if (!surface) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
fContext->testPMConversionsIfNecessary(pixelOpsFlags);
|
|
||||||
|
|
||||||
// Trim the params here so that if we wind up making a temporary surface it can be as small as
|
// Trim the params here so that if we wind up making a temporary surface it can be as small as
|
||||||
// necessary and because GrGpu::getWritePixelsInfo requires it.
|
// necessary and because GrGpu::getWritePixelsInfo requires it.
|
||||||
@ -307,23 +298,23 @@ bool GrContextPriv::writeSurfacePixels(GrSurfaceProxy* srcProxy, SkColorSpace* d
|
|||||||
GrGpu::DrawPreference drawPreference = GrGpu::kNoDraw_DrawPreference;
|
GrGpu::DrawPreference drawPreference = GrGpu::kNoDraw_DrawPreference;
|
||||||
// Don't prefer to draw for the conversion (and thereby access a texture from the cache) when
|
// Don't prefer to draw for the conversion (and thereby access a texture from the cache) when
|
||||||
// we've already determined that there isn't a roundtrip preserving conversion processor pair.
|
// we've already determined that there isn't a roundtrip preserving conversion processor pair.
|
||||||
if (applyPremulToSrc && fContext->validPMUPMConversionExists(srcConfig)) {
|
if (applyPremulToSrc && this->validPMUPMConversionExists(srcConfig)) {
|
||||||
drawPreference = GrGpu::kCallerPrefersDraw_DrawPreference;
|
drawPreference = GrGpu::kCallerPrefersDraw_DrawPreference;
|
||||||
}
|
}
|
||||||
|
|
||||||
GrGpu::WritePixelTempDrawInfo tempDrawInfo;
|
GrGpu::WritePixelTempDrawInfo tempDrawInfo;
|
||||||
if (!fContext->fGpu->getWritePixelsInfo(surface, width, height, srcConfig,
|
if (!fGpu->getWritePixelsInfo(surface, width, height, srcConfig, &drawPreference,
|
||||||
&drawPreference, &tempDrawInfo)) {
|
&tempDrawInfo)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(kDontFlush_PixelOpsFlag & pixelOpsFlags) && surface->surfacePriv().hasPendingIO()) {
|
if (!(kDontFlush_PixelOpsFlag & pixelOpsFlags) && surface->surfacePriv().hasPendingIO()) {
|
||||||
this->flush(nullptr); // MDB TODO: tighten this
|
this->contextPriv().flush(nullptr); // MDB TODO: tighten this
|
||||||
}
|
}
|
||||||
|
|
||||||
sk_sp<GrTextureProxy> tempProxy;
|
sk_sp<GrTextureProxy> tempProxy;
|
||||||
if (GrGpu::kNoDraw_DrawPreference != drawPreference) {
|
if (GrGpu::kNoDraw_DrawPreference != drawPreference) {
|
||||||
tempProxy = GrSurfaceProxy::MakeDeferred(fContext->resourceProvider(),
|
tempProxy = GrSurfaceProxy::MakeDeferred(this->resourceProvider(),
|
||||||
tempDrawInfo.fTempSurfaceDesc,
|
tempDrawInfo.fTempSurfaceDesc,
|
||||||
SkBackingFit::kApprox,
|
SkBackingFit::kApprox,
|
||||||
SkBudgeted::kYes);
|
SkBudgeted::kYes);
|
||||||
@ -337,7 +328,7 @@ bool GrContextPriv::writeSurfacePixels(GrSurfaceProxy* srcProxy, SkColorSpace* d
|
|||||||
if (tempProxy) {
|
if (tempProxy) {
|
||||||
sk_sp<GrFragmentProcessor> fp;
|
sk_sp<GrFragmentProcessor> fp;
|
||||||
if (applyPremulToSrc) {
|
if (applyPremulToSrc) {
|
||||||
fp = fContext->createUPMToPMEffect(tempProxy, SkMatrix::I());
|
fp = this->createUPMToPMEffect(tempProxy, SkMatrix::I());
|
||||||
fp = GrFragmentProcessor::SwizzleOutput(std::move(fp), tempDrawInfo.fSwizzle);
|
fp = GrFragmentProcessor::SwizzleOutput(std::move(fp), tempDrawInfo.fSwizzle);
|
||||||
// If premultiplying was the only reason for the draw, fall back to a straight write.
|
// If premultiplying was the only reason for the draw, fall back to a straight write.
|
||||||
if (!fp) {
|
if (!fp) {
|
||||||
@ -350,7 +341,7 @@ bool GrContextPriv::writeSurfacePixels(GrSurfaceProxy* srcProxy, SkColorSpace* d
|
|||||||
}
|
}
|
||||||
if (tempProxy) {
|
if (tempProxy) {
|
||||||
if (!fp) {
|
if (!fp) {
|
||||||
fp = GrSimpleTextureEffect::Make(fContext->resourceProvider(), tempProxy, nullptr,
|
fp = GrSimpleTextureEffect::Make(this->resourceProvider(), tempProxy, nullptr,
|
||||||
SkMatrix::I());
|
SkMatrix::I());
|
||||||
fp = GrFragmentProcessor::SwizzleOutput(std::move(fp), tempDrawInfo.fSwizzle);
|
fp = GrFragmentProcessor::SwizzleOutput(std::move(fp), tempDrawInfo.fSwizzle);
|
||||||
|
|
||||||
@ -359,9 +350,9 @@ bool GrContextPriv::writeSurfacePixels(GrSurfaceProxy* srcProxy, SkColorSpace* d
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (tempProxy->priv().hasPendingIO()) {
|
if (tempProxy->priv().hasPendingIO()) {
|
||||||
this->flush(tempProxy.get());
|
this->contextPriv().flush(tempProxy.get());
|
||||||
}
|
}
|
||||||
GrTexture* texture = tempProxy->instantiate(fContext->resourceProvider());
|
GrTexture* texture = tempProxy->instantiate(this->resourceProvider());
|
||||||
if (!texture) {
|
if (!texture) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -376,7 +367,7 @@ bool GrContextPriv::writeSurfacePixels(GrSurfaceProxy* srcProxy, SkColorSpace* d
|
|||||||
buffer = tmpPixels.get();
|
buffer = tmpPixels.get();
|
||||||
applyPremulToSrc = false;
|
applyPremulToSrc = false;
|
||||||
}
|
}
|
||||||
if (!fContext->fGpu->writePixels(texture, 0, 0, width, height,
|
if (!fGpu->writePixels(texture, 0, 0, width, height,
|
||||||
tempDrawInfo.fWriteConfig, buffer,
|
tempDrawInfo.fWriteConfig, buffer,
|
||||||
rowBytes)) {
|
rowBytes)) {
|
||||||
return false;
|
return false;
|
||||||
@ -389,7 +380,8 @@ bool GrContextPriv::writeSurfacePixels(GrSurfaceProxy* srcProxy, SkColorSpace* d
|
|||||||
GrRenderTarget* renderTarget = surface->asRenderTarget();
|
GrRenderTarget* renderTarget = surface->asRenderTarget();
|
||||||
SkASSERT(renderTarget);
|
SkASSERT(renderTarget);
|
||||||
sk_sp<GrRenderTargetContext> renderTargetContext(
|
sk_sp<GrRenderTargetContext> renderTargetContext(
|
||||||
this->makeWrappedRenderTargetContext(sk_ref_sp(renderTarget), nullptr));
|
this->contextPriv().makeWrappedRenderTargetContext(sk_ref_sp(renderTarget),
|
||||||
|
nullptr));
|
||||||
if (!renderTargetContext) {
|
if (!renderTargetContext) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -402,7 +394,7 @@ bool GrContextPriv::writeSurfacePixels(GrSurfaceProxy* srcProxy, SkColorSpace* d
|
|||||||
nullptr);
|
nullptr);
|
||||||
|
|
||||||
if (kFlushWrites_PixelOp & pixelOpsFlags) {
|
if (kFlushWrites_PixelOp & pixelOpsFlags) {
|
||||||
this->flushSurfaceWrites(renderTargetContext->asRenderTargetProxy());
|
this->contextPriv().flushSurfaceWrites(renderTargetContext->asRenderTargetProxy());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -418,31 +410,24 @@ bool GrContextPriv::writeSurfacePixels(GrSurfaceProxy* srcProxy, SkColorSpace* d
|
|||||||
buffer = tmpPixels.get();
|
buffer = tmpPixels.get();
|
||||||
applyPremulToSrc = false;
|
applyPremulToSrc = false;
|
||||||
}
|
}
|
||||||
return fContext->fGpu->writePixels(surface, left, top, width, height, srcConfig,
|
return fGpu->writePixels(surface, left, top, width, height, srcConfig, buffer, rowBytes);
|
||||||
buffer, rowBytes);
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GrContextPriv::readSurfacePixels(GrSurfaceProxy* srcProxy, SkColorSpace* srcColorSpace,
|
bool GrContext::readSurfacePixels(GrSurface* src, SkColorSpace* srcColorSpace,
|
||||||
int left, int top, int width, int height,
|
int left, int top, int width, int height,
|
||||||
GrPixelConfig dstConfig, SkColorSpace* dstColorSpace,
|
GrPixelConfig dstConfig, SkColorSpace* dstColorSpace,
|
||||||
void* buffer, size_t rowBytes, uint32_t flags) {
|
void* buffer, size_t rowBytes, uint32_t flags) {
|
||||||
// TODO: Color space conversion
|
// TODO: Color space conversion
|
||||||
|
|
||||||
ASSERT_SINGLE_OWNER_PRIV
|
ASSERT_SINGLE_OWNER
|
||||||
RETURN_FALSE_IF_ABANDONED_PRIV
|
RETURN_FALSE_IF_ABANDONED
|
||||||
ASSERT_OWNED_PROXY_PRIV(srcProxy);
|
ASSERT_OWNED_RESOURCE(src);
|
||||||
SkASSERT(srcProxy);
|
SkASSERT(src);
|
||||||
GR_AUDIT_TRAIL_AUTO_FRAME(&fContext->fAuditTrail, "GrContextPriv::readSurfacePixels");
|
GR_AUDIT_TRAIL_AUTO_FRAME(&fAuditTrail, "GrContext::readSurfacePixels");
|
||||||
|
|
||||||
// MDB TODO: delay this instantiation until later in the method
|
this->testPMConversionsIfNecessary(flags);
|
||||||
GrSurface* src = srcProxy->instantiate(fContext->resourceProvider());
|
|
||||||
if (!src) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
fContext->testPMConversionsIfNecessary(flags);
|
|
||||||
|
|
||||||
// Adjust the params so that if we wind up using an intermediate surface we've already done
|
// Adjust the params so that if we wind up using an intermediate surface we've already done
|
||||||
// all the trimming and the temporary can be the min size required.
|
// all the trimming and the temporary can be the min size required.
|
||||||
@ -453,7 +438,7 @@ bool GrContextPriv::readSurfacePixels(GrSurfaceProxy* srcProxy, SkColorSpace* sr
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!(kDontFlush_PixelOpsFlag & flags) && src->surfacePriv().hasPendingWrite()) {
|
if (!(kDontFlush_PixelOpsFlag & flags) && src->surfacePriv().hasPendingWrite()) {
|
||||||
this->flush(nullptr); // MDB TODO: tighten this
|
this->contextPriv().flush(nullptr); // MDB TODO: tighten this
|
||||||
}
|
}
|
||||||
|
|
||||||
bool unpremul = SkToBool(kUnpremul_PixelOpsFlag & flags);
|
bool unpremul = SkToBool(kUnpremul_PixelOpsFlag & flags);
|
||||||
@ -469,17 +454,18 @@ bool GrContextPriv::readSurfacePixels(GrSurfaceProxy* srcProxy, SkColorSpace* sr
|
|||||||
GrGpu::DrawPreference drawPreference = GrGpu::kNoDraw_DrawPreference;
|
GrGpu::DrawPreference drawPreference = GrGpu::kNoDraw_DrawPreference;
|
||||||
// Don't prefer to draw for the conversion (and thereby access a texture from the cache) when
|
// Don't prefer to draw for the conversion (and thereby access a texture from the cache) when
|
||||||
// we've already determined that there isn't a roundtrip preserving conversion processor pair.
|
// we've already determined that there isn't a roundtrip preserving conversion processor pair.
|
||||||
if (unpremul && fContext->validPMUPMConversionExists(src->config())) {
|
if (unpremul && this->validPMUPMConversionExists(src->config())) {
|
||||||
drawPreference = GrGpu::kCallerPrefersDraw_DrawPreference;
|
drawPreference = GrGpu::kCallerPrefersDraw_DrawPreference;
|
||||||
}
|
}
|
||||||
|
|
||||||
GrGpu::ReadPixelTempDrawInfo tempDrawInfo;
|
GrGpu::ReadPixelTempDrawInfo tempDrawInfo;
|
||||||
if (!fContext->fGpu->getReadPixelsInfo(src, width, height, rowBytes, dstConfig,
|
if (!fGpu->getReadPixelsInfo(src, width, height, rowBytes, dstConfig, &drawPreference,
|
||||||
&drawPreference, &tempDrawInfo)) {
|
&tempDrawInfo)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
sk_sp<GrSurfaceProxy> proxyToRead = sk_ref_sp(srcProxy);
|
sk_sp<GrSurface> surfaceToRead(SkRef(src));
|
||||||
|
sk_sp<GrTextureProxy> drawnProxy;
|
||||||
bool didTempDraw = false;
|
bool didTempDraw = false;
|
||||||
if (GrGpu::kNoDraw_DrawPreference != drawPreference) {
|
if (GrGpu::kNoDraw_DrawPreference != drawPreference) {
|
||||||
if (SkBackingFit::kExact == tempDrawInfo.fTempSurfaceFit) {
|
if (SkBackingFit::kExact == tempDrawInfo.fTempSurfaceFit) {
|
||||||
@ -492,7 +478,7 @@ bool GrContextPriv::readSurfacePixels(GrSurfaceProxy* srcProxy, SkColorSpace* sr
|
|||||||
// TODO: Need to decide the semantics of this function for color spaces. Do we support
|
// TODO: Need to decide the semantics of this function for color spaces. Do we support
|
||||||
// conversion to a passed-in color space? For now, specifying nullptr means that this
|
// conversion to a passed-in color space? For now, specifying nullptr means that this
|
||||||
// path will do no conversion, so it will match the behavior of the non-draw path.
|
// path will do no conversion, so it will match the behavior of the non-draw path.
|
||||||
sk_sp<GrRenderTargetContext> tempRTC = fContext->makeRenderTargetContext(
|
sk_sp<GrRenderTargetContext> tempRTC = this->makeRenderTargetContext(
|
||||||
tempDrawInfo.fTempSurfaceFit,
|
tempDrawInfo.fTempSurfaceFit,
|
||||||
tempDrawInfo.fTempSurfaceDesc.fWidth,
|
tempDrawInfo.fTempSurfaceDesc.fWidth,
|
||||||
tempDrawInfo.fTempSurfaceDesc.fHeight,
|
tempDrawInfo.fTempSurfaceDesc.fHeight,
|
||||||
@ -502,10 +488,10 @@ bool GrContextPriv::readSurfacePixels(GrSurfaceProxy* srcProxy, SkColorSpace* sr
|
|||||||
tempDrawInfo.fTempSurfaceDesc.fOrigin);
|
tempDrawInfo.fTempSurfaceDesc.fOrigin);
|
||||||
if (tempRTC) {
|
if (tempRTC) {
|
||||||
SkMatrix textureMatrix = SkMatrix::MakeTrans(SkIntToScalar(left), SkIntToScalar(top));
|
SkMatrix textureMatrix = SkMatrix::MakeTrans(SkIntToScalar(left), SkIntToScalar(top));
|
||||||
sk_sp<GrTextureProxy> proxy = sk_ref_sp(srcProxy->asTextureProxy());
|
sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeWrapped(sk_ref_sp(src->asTexture()));
|
||||||
sk_sp<GrFragmentProcessor> fp;
|
sk_sp<GrFragmentProcessor> fp;
|
||||||
if (unpremul) {
|
if (unpremul) {
|
||||||
fp = fContext->createPMToUPMEffect(proxy, textureMatrix);
|
fp = this->createPMToUPMEffect(proxy, textureMatrix);
|
||||||
fp = GrFragmentProcessor::SwizzleOutput(std::move(fp), tempDrawInfo.fSwizzle);
|
fp = GrFragmentProcessor::SwizzleOutput(std::move(fp), tempDrawInfo.fSwizzle);
|
||||||
if (fp) {
|
if (fp) {
|
||||||
unpremul = false; // we no longer need to do this on CPU after the read back.
|
unpremul = false; // we no longer need to do this on CPU after the read back.
|
||||||
@ -516,7 +502,7 @@ bool GrContextPriv::readSurfacePixels(GrSurfaceProxy* srcProxy, SkColorSpace* sr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!fp && tempRTC) {
|
if (!fp && tempRTC) {
|
||||||
fp = GrSimpleTextureEffect::Make(fContext->resourceProvider(), std::move(proxy),
|
fp = GrSimpleTextureEffect::Make(this->resourceProvider(), std::move(proxy),
|
||||||
nullptr, textureMatrix);
|
nullptr, textureMatrix);
|
||||||
fp = GrFragmentProcessor::SwizzleOutput(std::move(fp), tempDrawInfo.fSwizzle);
|
fp = GrFragmentProcessor::SwizzleOutput(std::move(fp), tempDrawInfo.fSwizzle);
|
||||||
}
|
}
|
||||||
@ -528,7 +514,8 @@ bool GrContextPriv::readSurfacePixels(GrSurfaceProxy* srcProxy, SkColorSpace* sr
|
|||||||
SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height));
|
SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height));
|
||||||
tempRTC->drawRect(GrNoClip(), std::move(paint), GrAA::kNo, SkMatrix::I(), rect,
|
tempRTC->drawRect(GrNoClip(), std::move(paint), GrAA::kNo, SkMatrix::I(), rect,
|
||||||
nullptr);
|
nullptr);
|
||||||
proxyToRead = tempRTC->asTextureProxyRef();
|
drawnProxy = tempRTC->asTextureProxyRef();
|
||||||
|
surfaceToRead = sk_ref_sp(drawnProxy->instantiate(this->resourceProvider()));
|
||||||
left = 0;
|
left = 0;
|
||||||
top = 0;
|
top = 0;
|
||||||
didTempDraw = true;
|
didTempDraw = true;
|
||||||
@ -536,11 +523,6 @@ bool GrContextPriv::readSurfacePixels(GrSurfaceProxy* srcProxy, SkColorSpace* sr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!proxyToRead) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
GrSurface* surfaceToRead = proxyToRead->instantiate(fContext->resourceProvider());
|
|
||||||
if (!surfaceToRead) {
|
if (!surfaceToRead) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -550,11 +532,11 @@ bool GrContextPriv::readSurfacePixels(GrSurfaceProxy* srcProxy, SkColorSpace* sr
|
|||||||
}
|
}
|
||||||
GrPixelConfig configToRead = dstConfig;
|
GrPixelConfig configToRead = dstConfig;
|
||||||
if (didTempDraw) {
|
if (didTempDraw) {
|
||||||
this->flushSurfaceWrites(proxyToRead.get());
|
this->contextPriv().flushSurfaceWrites(drawnProxy.get());
|
||||||
configToRead = tempDrawInfo.fReadConfig;
|
configToRead = tempDrawInfo.fReadConfig;
|
||||||
}
|
}
|
||||||
if (!fContext->fGpu->readPixels(surfaceToRead, left, top, width, height, configToRead,
|
if (!fGpu->readPixels(surfaceToRead.get(), left, top, width, height, configToRead, buffer,
|
||||||
buffer, rowBytes)) {
|
rowBytes)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -833,7 +815,7 @@ sk_sp<GrRenderTargetContext> GrContext::makeRenderTargetContext(SkBackingFit fit
|
|||||||
|
|
||||||
sk_sp<GrTexture> tex;
|
sk_sp<GrTexture> tex;
|
||||||
if (SkBackingFit::kExact == fit) {
|
if (SkBackingFit::kExact == fit) {
|
||||||
tex = this->resourceProvider()->createTexture(desc, budgeted);
|
tex.reset(this->resourceProvider()->createTexture(desc, budgeted));
|
||||||
} else {
|
} else {
|
||||||
tex.reset(this->resourceProvider()->createApproxTexture(desc, 0));
|
tex.reset(this->resourceProvider()->createApproxTexture(desc, 0));
|
||||||
}
|
}
|
||||||
@ -896,7 +878,7 @@ void test_pm_conversions(GrContext* ctx, int* pmToUPMValue, int* upmToPMValue) {
|
|||||||
|
|
||||||
void GrContext::testPMConversionsIfNecessary(uint32_t flags) {
|
void GrContext::testPMConversionsIfNecessary(uint32_t flags) {
|
||||||
ASSERT_SINGLE_OWNER
|
ASSERT_SINGLE_OWNER
|
||||||
if (SkToBool(GrContextPriv::kUnpremul_PixelOpsFlag & flags)) {
|
if (SkToBool(kUnpremul_PixelOpsFlag & flags)) {
|
||||||
if (!fDidTestPMConversions) {
|
if (!fDidTestPMConversions) {
|
||||||
test_pm_conversions(this, &fPMToUPMConversion, &fUPMToPMConversion);
|
test_pm_conversions(this, &fPMToUPMConversion, &fUPMToPMConversion);
|
||||||
fDidTestPMConversions = true;
|
fDidTestPMConversions = true;
|
||||||
|
@ -96,68 +96,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
void prepareSurfaceForExternalIO(GrSurfaceProxy*);
|
void prepareSurfaceForExternalIO(GrSurfaceProxy*);
|
||||||
|
|
||||||
/**
|
|
||||||
* These flags can be used with the read/write pixels functions below.
|
|
||||||
*/
|
|
||||||
enum PixelOpsFlags {
|
|
||||||
/** The GrContext will not be flushed before the surface read or write. This means that
|
|
||||||
the read or write may occur before previous draws have executed. */
|
|
||||||
kDontFlush_PixelOpsFlag = 0x1,
|
|
||||||
/** Any surface writes should be flushed to the backend 3D API after the surface operation
|
|
||||||
is complete */
|
|
||||||
kFlushWrites_PixelOp = 0x2,
|
|
||||||
/** The src for write or dst read is unpremultiplied. This is only respected if both the
|
|
||||||
config src and dst configs are an RGBA/BGRA 8888 format. */
|
|
||||||
kUnpremul_PixelOpsFlag = 0x4,
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reads a rectangle of pixels from a surface.
|
|
||||||
* @param surface the surface to read from.
|
|
||||||
* @param srcColorSpace color space of the surface
|
|
||||||
* @param left left edge of the rectangle to read (inclusive)
|
|
||||||
* @param top top edge of the rectangle to read (inclusive)
|
|
||||||
* @param width width of rectangle to read in pixels.
|
|
||||||
* @param height height of rectangle to read in pixels.
|
|
||||||
* @param config the pixel config of the destination buffer
|
|
||||||
* @param dstColorSpace color space of the destination buffer
|
|
||||||
* @param buffer memory to read the rectangle into.
|
|
||||||
* @param rowBytes number of bytes bewtween consecutive rows. Zero means rows are tightly
|
|
||||||
* packed.
|
|
||||||
* @param pixelOpsFlags see PixelOpsFlags enum above.
|
|
||||||
*
|
|
||||||
* @return true if the read succeeded, false if not. The read can fail because of an unsupported
|
|
||||||
* pixel configs
|
|
||||||
*/
|
|
||||||
bool readSurfacePixels(GrSurfaceProxy* src, SkColorSpace* srcColorSpace,
|
|
||||||
int left, int top, int width, int height,
|
|
||||||
GrPixelConfig config, SkColorSpace* dstColorSpace, void* buffer,
|
|
||||||
size_t rowBytes = 0,
|
|
||||||
uint32_t pixelOpsFlags = 0);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Writes a rectangle of pixels to a surface.
|
|
||||||
* @param surface the surface to write to.
|
|
||||||
* @param dstColorSpace color space of the surface
|
|
||||||
* @param left left edge of the rectangle to write (inclusive)
|
|
||||||
* @param top top edge of the rectangle to write (inclusive)
|
|
||||||
* @param width width of rectangle to write in pixels.
|
|
||||||
* @param height height of rectangle to write in pixels.
|
|
||||||
* @param config the pixel config of the source buffer
|
|
||||||
* @param srcColorSpace color space of the source buffer
|
|
||||||
* @param buffer memory to read pixels from
|
|
||||||
* @param rowBytes number of bytes between consecutive rows. Zero
|
|
||||||
* means rows are tightly packed.
|
|
||||||
* @param pixelOpsFlags see PixelOpsFlags enum above.
|
|
||||||
* @return true if the write succeeded, false if not. The write can fail because of an
|
|
||||||
* unsupported combination of surface and src configs.
|
|
||||||
*/
|
|
||||||
bool writeSurfacePixels(GrSurfaceProxy* src, SkColorSpace* dstColorSpace,
|
|
||||||
int left, int top, int width, int height,
|
|
||||||
GrPixelConfig config, SkColorSpace* srcColorSpace, const void* buffer,
|
|
||||||
size_t rowBytes,
|
|
||||||
uint32_t pixelOpsFlags = 0);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit GrContextPriv(GrContext* context) : fContext(context) {}
|
explicit GrContextPriv(GrContext* context) : fContext(context) {}
|
||||||
GrContextPriv(const GrContextPriv&); // unimpl
|
GrContextPriv(const GrContextPriv&); // unimpl
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
#include "GrRenderTargetContext.h"
|
#include "GrRenderTargetContext.h"
|
||||||
#include "GrAppliedClip.h"
|
#include "GrAppliedClip.h"
|
||||||
#include "GrColor.h"
|
#include "GrColor.h"
|
||||||
#include "GrContextPriv.h"
|
|
||||||
#include "GrDrawingManager.h"
|
#include "GrDrawingManager.h"
|
||||||
#include "GrFixedClip.h"
|
#include "GrFixedClip.h"
|
||||||
#include "GrGpuResourcePriv.h"
|
#include "GrGpuResourcePriv.h"
|
||||||
@ -163,14 +162,18 @@ bool GrRenderTargetContext::onReadPixels(const SkImageInfo& dstInfo, void* dstBu
|
|||||||
|
|
||||||
// TODO: this seems to duplicate code in SkImage_Gpu::onReadPixels
|
// TODO: this seems to duplicate code in SkImage_Gpu::onReadPixels
|
||||||
if (kUnpremul_SkAlphaType == dstInfo.alphaType()) {
|
if (kUnpremul_SkAlphaType == dstInfo.alphaType()) {
|
||||||
flags |= GrContextPriv::kUnpremul_PixelOpsFlag;
|
flags |= GrContext::kUnpremul_PixelOpsFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
return fContext->contextPriv().readSurfacePixels(fRenderTargetProxy.get(),
|
// Deferral of the VRAM resources must end in this instance anyway
|
||||||
this->getColorSpace(), x, y,
|
sk_sp<GrRenderTarget> rt(
|
||||||
dstInfo.width(), dstInfo.height(), config,
|
sk_ref_sp(fRenderTargetProxy->instantiate(fContext->resourceProvider())));
|
||||||
dstInfo.colorSpace(),
|
if (!rt) {
|
||||||
dstBuffer, dstRowBytes, flags);
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rt->readPixels(this->getColorSpace(), x, y, dstInfo.width(), dstInfo.height(),
|
||||||
|
config, dstInfo.colorSpace(), dstBuffer, dstRowBytes, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: move this (and GrTextureContext::onReadPixels) to GrSurfaceContext?
|
// TODO: move this (and GrTextureContext::onReadPixels) to GrSurfaceContext?
|
||||||
@ -182,14 +185,18 @@ bool GrRenderTargetContext::onWritePixels(const SkImageInfo& srcInfo, const void
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (kUnpremul_SkAlphaType == srcInfo.alphaType()) {
|
if (kUnpremul_SkAlphaType == srcInfo.alphaType()) {
|
||||||
flags |= GrContextPriv::kUnpremul_PixelOpsFlag;
|
flags |= GrContext::kUnpremul_PixelOpsFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
return fContext->contextPriv().writeSurfacePixels(fRenderTargetProxy.get(),
|
// Deferral of the VRAM resources must end in this instance anyway
|
||||||
this->getColorSpace(), x, y,
|
sk_sp<GrRenderTarget> rt(
|
||||||
srcInfo.width(), srcInfo.height(),
|
sk_ref_sp(fRenderTargetProxy->instantiate(fContext->resourceProvider())));
|
||||||
config, srcInfo.colorSpace(),
|
if (!rt) {
|
||||||
srcBuffer, srcRowBytes, flags);
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rt->writePixels(this->getColorSpace(), x, y, srcInfo.width(), srcInfo.height(),
|
||||||
|
config, srcInfo.colorSpace(), srcBuffer, srcRowBytes, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1780,7 +1787,7 @@ void GrRenderTargetContext::setupDstTexture(GrRenderTarget* rt, const GrClip& cl
|
|||||||
desc.fHeight = rt->height();
|
desc.fHeight = rt->height();
|
||||||
dstPoint = {copyRect.fLeft, copyRect.fTop};
|
dstPoint = {copyRect.fLeft, copyRect.fTop};
|
||||||
dstOffset = {0, 0};
|
dstOffset = {0, 0};
|
||||||
copy = fContext->resourceProvider()->createTexture(desc, SkBudgeted::kYes, kFlags);
|
copy.reset(fContext->resourceProvider()->createTexture(desc, SkBudgeted::kYes, kFlags));
|
||||||
} else {
|
} else {
|
||||||
desc.fWidth = copyRect.width();
|
desc.fWidth = copyRect.width();
|
||||||
desc.fHeight = copyRect.height();
|
desc.fHeight = copyRect.height();
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
#include "GrBuffer.h"
|
#include "GrBuffer.h"
|
||||||
#include "GrCaps.h"
|
#include "GrCaps.h"
|
||||||
#include "GrContext.h"
|
#include "GrContext.h"
|
||||||
#include "GrContextPriv.h"
|
|
||||||
#include "GrGpu.h"
|
#include "GrGpu.h"
|
||||||
#include "GrPathRendering.h"
|
#include "GrPathRendering.h"
|
||||||
#include "GrRenderTarget.h"
|
#include "GrRenderTarget.h"
|
||||||
@ -48,13 +47,9 @@ bool GrResourceProvider::IsFunctionallyExact(GrSurfaceProxy* proxy) {
|
|||||||
return proxy->priv().isExact() || (SkIsPow2(proxy->width()) && SkIsPow2(proxy->height()));
|
return proxy->priv().isExact() || (SkIsPow2(proxy->width()) && SkIsPow2(proxy->height()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// MDB TODO: this should probably be a factory on GrSurfaceProxy
|
GrTexture* GrResourceProvider::createMipMappedTexture(const GrSurfaceDesc& desc,
|
||||||
sk_sp<GrTextureProxy> GrResourceProvider::createMipMappedTexture(
|
SkBudgeted budgeted, const GrMipLevel* texels,
|
||||||
const GrSurfaceDesc& desc,
|
int mipLevelCount, uint32_t flags,
|
||||||
SkBudgeted budgeted,
|
|
||||||
const GrMipLevel* texels,
|
|
||||||
int mipLevelCount,
|
|
||||||
uint32_t flags,
|
|
||||||
SkDestinationSurfaceColorMode mipColorMode) {
|
SkDestinationSurfaceColorMode mipColorMode) {
|
||||||
ASSERT_SINGLE_OWNER
|
ASSERT_SINGLE_OWNER
|
||||||
|
|
||||||
@ -79,19 +74,17 @@ sk_sp<GrTextureProxy> GrResourceProvider::createMipMappedTexture(
|
|||||||
if (!GrPixelConfigIsCompressed(desc.fConfig)) {
|
if (!GrPixelConfigIsCompressed(desc.fConfig)) {
|
||||||
if (mipLevelCount < 2) {
|
if (mipLevelCount < 2) {
|
||||||
flags |= kExact_Flag | kNoCreate_Flag;
|
flags |= kExact_Flag | kNoCreate_Flag;
|
||||||
sk_sp<GrTexture> tex(this->refScratchTexture(desc, flags));
|
if (GrTexture* texture = this->refScratchTexture(desc, flags)) {
|
||||||
if (tex) {
|
|
||||||
sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeWrapped(tex);
|
|
||||||
if (!mipLevelCount ||
|
if (!mipLevelCount ||
|
||||||
fGpu->getContext()->contextPriv().writeSurfacePixels(
|
texture->writePixels(0, 0, desc.fWidth, desc.fHeight, desc.fConfig,
|
||||||
proxy.get(), nullptr, 0, 0, desc.fWidth, desc.fHeight, desc.fConfig,
|
texels[0].fPixels, texels[0].fRowBytes)) {
|
||||||
nullptr, texels[0].fPixels, texels[0].fRowBytes)) {
|
|
||||||
if (SkBudgeted::kNo == budgeted) {
|
if (SkBudgeted::kNo == budgeted) {
|
||||||
tex->resourcePriv().makeUnbudgeted();
|
texture->resourcePriv().makeUnbudgeted();
|
||||||
}
|
}
|
||||||
tex->texturePriv().setMipColorMode(mipColorMode);
|
texture->texturePriv().setMipColorMode(mipColorMode);
|
||||||
return proxy;
|
return texture;
|
||||||
}
|
}
|
||||||
|
texture->unref();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -100,34 +93,25 @@ sk_sp<GrTextureProxy> GrResourceProvider::createMipMappedTexture(
|
|||||||
for (int i = 0; i < mipLevelCount; ++i) {
|
for (int i = 0; i < mipLevelCount; ++i) {
|
||||||
texelsShallowCopy.push_back(texels[i]);
|
texelsShallowCopy.push_back(texels[i]);
|
||||||
}
|
}
|
||||||
sk_sp<GrTexture> tex(fGpu->createTexture(desc, budgeted, texelsShallowCopy));
|
GrTexture* texture = fGpu->createTexture(desc, budgeted, texelsShallowCopy);
|
||||||
if (tex) {
|
if (texture) {
|
||||||
tex->texturePriv().setMipColorMode(mipColorMode);
|
texture->texturePriv().setMipColorMode(mipColorMode);
|
||||||
}
|
}
|
||||||
|
return texture;
|
||||||
return GrSurfaceProxy::MakeWrapped(std::move(tex));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sk_sp<GrTexture> GrResourceProvider::createTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted,
|
GrTexture* GrResourceProvider::createTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted,
|
||||||
uint32_t flags) {
|
const void* srcData, size_t rowBytes, uint32_t flags) {
|
||||||
if ((desc.fFlags & kRenderTarget_GrSurfaceFlag) &&
|
GrMipLevel tempTexels;
|
||||||
!fGpu->caps()->isConfigRenderable(desc.fConfig, desc.fSampleCnt > 0)) {
|
GrMipLevel* texels = nullptr;
|
||||||
return nullptr;
|
int levelCount = 0;
|
||||||
|
if (srcData) {
|
||||||
|
tempTexels.fPixels = srcData;
|
||||||
|
tempTexels.fRowBytes = rowBytes;
|
||||||
|
texels = &tempTexels;
|
||||||
|
levelCount = 1;
|
||||||
}
|
}
|
||||||
|
return this->createMipMappedTexture(desc, budgeted, texels, levelCount, flags);
|
||||||
if (!GrPixelConfigIsCompressed(desc.fConfig)) {
|
|
||||||
flags |= kExact_Flag | kNoCreate_Flag;
|
|
||||||
sk_sp<GrTexture> tex(this->refScratchTexture(desc, flags));
|
|
||||||
if (tex) {
|
|
||||||
if (SkBudgeted::kNo == budgeted) {
|
|
||||||
tex->resourcePriv().makeUnbudgeted();
|
|
||||||
}
|
|
||||||
return tex;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sk_sp<GrTexture> tex(fGpu->createTexture(desc, budgeted));
|
|
||||||
return tex;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GrTexture* GrResourceProvider::createApproxTexture(const GrSurfaceDesc& desc, uint32_t flags) {
|
GrTexture* GrResourceProvider::createApproxTexture(const GrSurfaceDesc& desc, uint32_t flags) {
|
||||||
|
@ -47,12 +47,29 @@ public:
|
|||||||
* @param texels A contiguous array of mipmap levels
|
* @param texels A contiguous array of mipmap levels
|
||||||
* @param mipLevelCount The amount of elements in the texels array
|
* @param mipLevelCount The amount of elements in the texels array
|
||||||
*/
|
*/
|
||||||
sk_sp<GrTextureProxy> createMipMappedTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted,
|
GrTexture* createMipMappedTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted,
|
||||||
const GrMipLevel* texels, int mipLevelCount,
|
const GrMipLevel* texels, int mipLevelCount,
|
||||||
uint32_t flags = 0,
|
uint32_t flags = 0,
|
||||||
SkDestinationSurfaceColorMode mipColorMode =
|
SkDestinationSurfaceColorMode mipColorMode =
|
||||||
SkDestinationSurfaceColorMode::kLegacy);
|
SkDestinationSurfaceColorMode::kLegacy);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function is a shim which creates a SkTArray<GrMipLevel> of size 1.
|
||||||
|
* It then calls createTexture with that SkTArray.
|
||||||
|
*
|
||||||
|
* @param srcData Pointer to the pixel values (optional).
|
||||||
|
* @param rowBytes The number of bytes between rows of the texture. Zero
|
||||||
|
* implies tightly packed rows. For compressed pixel configs, this
|
||||||
|
* field is ignored.
|
||||||
|
*/
|
||||||
|
GrTexture* createTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted, const void* srcData,
|
||||||
|
size_t rowBytes, uint32_t flags = 0);
|
||||||
|
|
||||||
|
/** Shortcut for creating a texture with no initial data to upload. */
|
||||||
|
GrTexture* createTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted, uint32_t flags = 0) {
|
||||||
|
return this->createTexture(desc, budgeted, nullptr, 0, flags);
|
||||||
|
}
|
||||||
|
|
||||||
/** Assigns a unique key to the texture. The texture will be findable via this key using
|
/** Assigns a unique key to the texture. The texture will be findable via this key using
|
||||||
findTextureByUniqueKey(). If an existing texture has this key, it's key will be removed. */
|
findTextureByUniqueKey(). If an existing texture has this key, it's key will be removed. */
|
||||||
void assignUniqueKeyToProxy(const GrUniqueKey& key, GrTextureProxy*);
|
void assignUniqueKeyToProxy(const GrUniqueKey& key, GrTextureProxy*);
|
||||||
@ -69,11 +86,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
GrTexture* createApproxTexture(const GrSurfaceDesc&, uint32_t flags);
|
GrTexture* createApproxTexture(const GrSurfaceDesc&, uint32_t flags);
|
||||||
|
|
||||||
/** Create an exact fit texture with no initial data to upload.
|
|
||||||
*/
|
|
||||||
sk_sp<GrTexture> createTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted,
|
|
||||||
uint32_t flags = 0);
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// Wrapped Backend Surfaces
|
// Wrapped Backend Surfaces
|
||||||
|
|
||||||
|
@ -139,6 +139,30 @@ bool GrSurfacePriv::AdjustWritePixelParams(int surfaceWidth,
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
bool GrSurface::writePixels(SkColorSpace* dstColorSpace, int left, int top, int width, int height,
|
||||||
|
GrPixelConfig config, SkColorSpace* srcColorSpace, const void* buffer,
|
||||||
|
size_t rowBytes, uint32_t pixelOpsFlags) {
|
||||||
|
// go through context so that all necessary flushing occurs
|
||||||
|
GrContext* context = this->getContext();
|
||||||
|
if (nullptr == context) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return context->writeSurfacePixels(this, dstColorSpace, left, top, width, height, config,
|
||||||
|
srcColorSpace, buffer, rowBytes, pixelOpsFlags);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GrSurface::readPixels(SkColorSpace* srcColorSpace, int left, int top, int width, int height,
|
||||||
|
GrPixelConfig config, SkColorSpace* dstColorSpace, void* buffer,
|
||||||
|
size_t rowBytes, uint32_t pixelOpsFlags) {
|
||||||
|
// go through context so that all necessary flushing occurs
|
||||||
|
GrContext* context = this->getContext();
|
||||||
|
if (nullptr == context) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return context->readSurfacePixels(this, srcColorSpace, left, top, width, height, config,
|
||||||
|
dstColorSpace, buffer, rowBytes, pixelOpsFlags);
|
||||||
|
}
|
||||||
|
|
||||||
bool GrSurface::hasPendingRead() const {
|
bool GrSurface::hasPendingRead() const {
|
||||||
const GrTexture* thisTex = this->asTexture();
|
const GrTexture* thisTex = this->asTexture();
|
||||||
if (thisTex && thisTex->internalHasPendingRead()) {
|
if (thisTex && thisTex->internalHasPendingRead()) {
|
||||||
|
@ -46,7 +46,7 @@ GrSurface* GrSurfaceProxy::instantiate(GrResourceProvider* resourceProvider) {
|
|||||||
if (SkBackingFit::kApprox == fFit) {
|
if (SkBackingFit::kApprox == fFit) {
|
||||||
fTarget = resourceProvider->createApproxTexture(fDesc, fFlags);
|
fTarget = resourceProvider->createApproxTexture(fDesc, fFlags);
|
||||||
} else {
|
} else {
|
||||||
fTarget = resourceProvider->createTexture(fDesc, fBudgeted, fFlags).release();
|
fTarget = resourceProvider->createTexture(fDesc, fBudgeted, fFlags);
|
||||||
}
|
}
|
||||||
if (!fTarget) {
|
if (!fTarget) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -216,16 +216,9 @@ sk_sp<GrTextureProxy> GrSurfaceProxy::MakeDeferred(GrResourceProvider* resourceP
|
|||||||
const void* srcData,
|
const void* srcData,
|
||||||
size_t rowBytes) {
|
size_t rowBytes) {
|
||||||
if (srcData) {
|
if (srcData) {
|
||||||
GrMipLevel tempTexels;
|
// If we have srcData, for now, we create a wrapped GrTextureProxy
|
||||||
GrMipLevel* texels = nullptr;
|
sk_sp<GrTexture> tex(resourceProvider->createTexture(desc, budgeted, srcData, rowBytes));
|
||||||
int levelCount = 0;
|
return GrSurfaceProxy::MakeWrapped(std::move(tex));
|
||||||
if (srcData) {
|
|
||||||
tempTexels.fPixels = srcData;
|
|
||||||
tempTexels.fRowBytes = rowBytes;
|
|
||||||
texels = &tempTexels;
|
|
||||||
levelCount = 1;
|
|
||||||
}
|
|
||||||
return resourceProvider->createMipMappedTexture(desc, budgeted, texels, levelCount);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return GrSurfaceProxy::MakeDeferred(resourceProvider, desc, SkBackingFit::kExact, budgeted);
|
return GrSurfaceProxy::MakeDeferred(resourceProvider, desc, SkBackingFit::kExact, budgeted);
|
||||||
|
@ -120,14 +120,17 @@ bool GrTextureContext::onReadPixels(const SkImageInfo& dstInfo, void* dstBuffer,
|
|||||||
|
|
||||||
// TODO: this seems to duplicate code in SkImage_Gpu::onReadPixels
|
// TODO: this seems to duplicate code in SkImage_Gpu::onReadPixels
|
||||||
if (kUnpremul_SkAlphaType == dstInfo.alphaType()) {
|
if (kUnpremul_SkAlphaType == dstInfo.alphaType()) {
|
||||||
flags |= GrContextPriv::kUnpremul_PixelOpsFlag;
|
flags |= GrContext::kUnpremul_PixelOpsFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
return fContext->contextPriv().readSurfacePixels(fTextureProxy.get(), this->getColorSpace(),
|
// Deferral of the VRAM resources must end in this instance anyway
|
||||||
x, y, dstInfo.width(), dstInfo.height(),
|
sk_sp<GrTexture> tex(sk_ref_sp(fTextureProxy->instantiate(fContext->resourceProvider())));
|
||||||
config,
|
if (!tex) {
|
||||||
dstInfo.colorSpace(), dstBuffer, dstRowBytes,
|
return false;
|
||||||
flags);
|
}
|
||||||
|
|
||||||
|
return tex->readPixels(this->getColorSpace(), x, y, dstInfo.width(), dstInfo.height(),
|
||||||
|
config, dstInfo.colorSpace(), dstBuffer, dstRowBytes, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: move this (and GrRenderTargetContext::onReadPixels) to GrSurfaceContext?
|
// TODO: move this (and GrRenderTargetContext::onReadPixels) to GrSurfaceContext?
|
||||||
@ -140,12 +143,15 @@ bool GrTextureContext::onWritePixels(const SkImageInfo& srcInfo, const void* src
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (kUnpremul_SkAlphaType == srcInfo.alphaType()) {
|
if (kUnpremul_SkAlphaType == srcInfo.alphaType()) {
|
||||||
flags |= GrContextPriv::kUnpremul_PixelOpsFlag;
|
flags |= GrContext::kUnpremul_PixelOpsFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
return fContext->contextPriv().writeSurfacePixels(fTextureProxy.get(), this->getColorSpace(),
|
// Deferral of the VRAM resources must end in this instance anyway
|
||||||
x, y, srcInfo.width(), srcInfo.height(),
|
sk_sp<GrTexture> tex(sk_ref_sp(fTextureProxy->instantiate(fContext->resourceProvider())));
|
||||||
config,
|
if (!tex) {
|
||||||
srcInfo.colorSpace(), srcBuffer, srcRowBytes,
|
return false;
|
||||||
flags);
|
}
|
||||||
|
|
||||||
|
return tex->writePixels(this->getColorSpace(), x, y, srcInfo.width(), srcInfo.height(),
|
||||||
|
config, srcInfo.colorSpace(), srcBuffer, srcRowBytes, flags);
|
||||||
}
|
}
|
||||||
|
@ -241,11 +241,13 @@ sk_sp<GrTextureProxy> GrGenerateMipMapsAndUploadToTextureProxy(GrContext* ctx,
|
|||||||
texels[i].fRowBytes = generatedMipLevel.fPixmap.rowBytes();
|
texels[i].fRowBytes = generatedMipLevel.fPixmap.rowBytes();
|
||||||
}
|
}
|
||||||
|
|
||||||
return ctx->resourceProvider()->createMipMappedTexture(desc,
|
sk_sp<GrTexture> tex(ctx->resourceProvider()->createMipMappedTexture(desc,
|
||||||
SkBudgeted::kYes,
|
SkBudgeted::kYes,
|
||||||
texels.get(),
|
texels.get(),
|
||||||
mipLevelCount,
|
mipLevelCount,
|
||||||
0, colorMode);
|
0, colorMode));
|
||||||
|
|
||||||
|
return GrSurfaceProxy::MakeWrapped(std::move(tex));
|
||||||
}
|
}
|
||||||
|
|
||||||
sk_sp<GrTextureProxy> GrUploadMipMapToTextureProxy(GrContext* ctx, const SkImageInfo& info,
|
sk_sp<GrTextureProxy> GrUploadMipMapToTextureProxy(GrContext* ctx, const SkImageInfo& info,
|
||||||
@ -257,9 +259,11 @@ sk_sp<GrTextureProxy> GrUploadMipMapToTextureProxy(GrContext* ctx, const SkImage
|
|||||||
}
|
}
|
||||||
|
|
||||||
const GrCaps* caps = ctx->caps();
|
const GrCaps* caps = ctx->caps();
|
||||||
return ctx->resourceProvider()->createMipMappedTexture(GrImageInfoToSurfaceDesc(info, *caps),
|
sk_sp<GrTexture> tex(ctx->resourceProvider()->createMipMappedTexture(
|
||||||
|
GrImageInfoToSurfaceDesc(info, *caps),
|
||||||
SkBudgeted::kYes, texels,
|
SkBudgeted::kYes, texels,
|
||||||
mipLevelCount, 0, colorMode);
|
mipLevelCount, 0, colorMode));
|
||||||
|
return GrSurfaceProxy::MakeWrapped(std::move(tex));
|
||||||
}
|
}
|
||||||
|
|
||||||
sk_sp<GrTextureProxy> GrRefCachedBitmapTextureProxy(GrContext* ctx,
|
sk_sp<GrTextureProxy> GrRefCachedBitmapTextureProxy(GrContext* ctx,
|
||||||
|
@ -162,7 +162,7 @@ int GrTextureStripAtlas::lockRow(const SkBitmap& bitmap) {
|
|||||||
// that is not currently in use
|
// that is not currently in use
|
||||||
fTexContext->writePixels(bitmap.info(), bitmap.getPixels(), bitmap.rowBytes(),
|
fTexContext->writePixels(bitmap.info(), bitmap.getPixels(), bitmap.rowBytes(),
|
||||||
0, rowNumber * fDesc.fRowHeight,
|
0, rowNumber * fDesc.fRowHeight,
|
||||||
GrContextPriv::kDontFlush_PixelOpsFlag);
|
GrContext::kDontFlush_PixelOpsFlag);
|
||||||
}
|
}
|
||||||
|
|
||||||
SkASSERT(rowNumber >= 0);
|
SkASSERT(rowNumber >= 0);
|
||||||
|
@ -191,7 +191,7 @@ bool SkImage_Gpu::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size
|
|||||||
uint32_t flags = 0;
|
uint32_t flags = 0;
|
||||||
if (kUnpremul_SkAlphaType == rec.fInfo.alphaType() && kPremul_SkAlphaType == fAlphaType) {
|
if (kUnpremul_SkAlphaType == rec.fInfo.alphaType() && kPremul_SkAlphaType == fAlphaType) {
|
||||||
// let the GPU perform this transformation for us
|
// let the GPU perform this transformation for us
|
||||||
flags = GrContextPriv::kUnpremul_PixelOpsFlag;
|
flags = GrContext::kUnpremul_PixelOpsFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
sk_sp<GrSurfaceContext> sContext = fContext->contextPriv().makeWrappedSurfaceContext(
|
sk_sp<GrSurfaceContext> sContext = fContext->contextPriv().makeWrappedSurfaceContext(
|
||||||
|
@ -92,7 +92,8 @@ static sk_sp<SkSurface> create_gpu_surface_backend_texture_as_render_target(
|
|||||||
backingDesc.fOrigin = kDefault_GrSurfaceOrigin;
|
backingDesc.fOrigin = kDefault_GrSurfaceOrigin;
|
||||||
backingDesc.fFlags = kRenderTarget_GrSurfaceFlag;
|
backingDesc.fFlags = kRenderTarget_GrSurfaceFlag;
|
||||||
|
|
||||||
*backingSurface = context->resourceProvider()->createTexture(backingDesc, SkBudgeted::kNo);
|
(*backingSurface)
|
||||||
|
.reset(context->resourceProvider()->createTexture(backingDesc, SkBudgeted::kNo));
|
||||||
|
|
||||||
GrBackendTextureDesc desc;
|
GrBackendTextureDesc desc;
|
||||||
desc.fConfig = config;
|
desc.fConfig = config;
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
|
|
||||||
#if SK_SUPPORT_GPU
|
#if SK_SUPPORT_GPU
|
||||||
#include "GrContext.h"
|
#include "GrContext.h"
|
||||||
#include "GrContextPriv.h"
|
|
||||||
#include "GrResourceProvider.h"
|
#include "GrResourceProvider.h"
|
||||||
#include "GrTexture.h"
|
#include "GrTexture.h"
|
||||||
#include "SkHalf.h"
|
#include "SkHalf.h"
|
||||||
@ -52,18 +51,14 @@ void runFPTest(skiatest::Reporter* reporter, GrContext* context,
|
|||||||
desc.fHeight = DEV_H;
|
desc.fHeight = DEV_H;
|
||||||
desc.fConfig = config;
|
desc.fConfig = config;
|
||||||
desc.fOrigin = 0 == origin ? kTopLeft_GrSurfaceOrigin : kBottomLeft_GrSurfaceOrigin;
|
desc.fOrigin = 0 == origin ? kTopLeft_GrSurfaceOrigin : kBottomLeft_GrSurfaceOrigin;
|
||||||
sk_sp<GrTextureProxy> fpProxy = GrSurfaceProxy::MakeDeferred(context->resourceProvider(),
|
sk_sp<GrTexture> fpTexture(context->resourceProvider()->createTexture(
|
||||||
desc, SkBudgeted::kNo,
|
desc, SkBudgeted::kNo, controlPixelData.begin(), 0));
|
||||||
controlPixelData.begin(), 0);
|
|
||||||
// Floating point textures are NOT supported everywhere
|
// Floating point textures are NOT supported everywhere
|
||||||
if (!fpProxy) {
|
if (nullptr == fpTexture) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
bool result = context->contextPriv().readSurfacePixels(fpProxy.get(), nullptr,
|
REPORTER_ASSERT(reporter,
|
||||||
0, 0, DEV_W, DEV_H,
|
fpTexture->readPixels(0, 0, DEV_W, DEV_H, desc.fConfig, readBuffer.begin(), 0));
|
||||||
desc.fConfig, nullptr,
|
|
||||||
readBuffer.begin(), 0);
|
|
||||||
REPORTER_ASSERT(reporter, result);
|
|
||||||
REPORTER_ASSERT(reporter,
|
REPORTER_ASSERT(reporter,
|
||||||
0 == memcmp(readBuffer.begin(), controlPixelData.begin(), readBuffer.bytes()));
|
0 == memcmp(readBuffer.begin(), controlPixelData.begin(), readBuffer.bytes()));
|
||||||
}
|
}
|
||||||
|
@ -285,30 +285,28 @@ bool GrDrawingManager::ProgramUnitTest(GrContext*, int) { return true; }
|
|||||||
bool GrDrawingManager::ProgramUnitTest(GrContext* context, int maxStages) {
|
bool GrDrawingManager::ProgramUnitTest(GrContext* context, int maxStages) {
|
||||||
GrDrawingManager* drawingManager = context->contextPriv().drawingManager();
|
GrDrawingManager* drawingManager = context->contextPriv().drawingManager();
|
||||||
|
|
||||||
sk_sp<GrTextureProxy> proxies[2];
|
|
||||||
|
|
||||||
// setup dummy textures
|
// setup dummy textures
|
||||||
GrSurfaceDesc dummyDesc;
|
GrSurfaceDesc dummyDesc;
|
||||||
dummyDesc.fFlags = kRenderTarget_GrSurfaceFlag;
|
dummyDesc.fFlags = kRenderTarget_GrSurfaceFlag;
|
||||||
dummyDesc.fOrigin = kBottomLeft_GrSurfaceOrigin;
|
|
||||||
dummyDesc.fConfig = kRGBA_8888_GrPixelConfig;
|
dummyDesc.fConfig = kRGBA_8888_GrPixelConfig;
|
||||||
dummyDesc.fWidth = 34;
|
dummyDesc.fWidth = 34;
|
||||||
dummyDesc.fHeight = 18;
|
dummyDesc.fHeight = 18;
|
||||||
proxies[0] = GrSurfaceProxy::MakeDeferred(context->resourceProvider(),
|
sk_sp<GrTexture> dummyTexture1(
|
||||||
dummyDesc, SkBudgeted::kNo, nullptr, 0);
|
context->resourceProvider()->createTexture(dummyDesc, SkBudgeted::kNo, nullptr, 0));
|
||||||
dummyDesc.fFlags = kNone_GrSurfaceFlags;
|
dummyDesc.fFlags = kNone_GrSurfaceFlags;
|
||||||
dummyDesc.fOrigin = kTopLeft_GrSurfaceOrigin;
|
|
||||||
dummyDesc.fConfig = kAlpha_8_GrPixelConfig;
|
dummyDesc.fConfig = kAlpha_8_GrPixelConfig;
|
||||||
dummyDesc.fWidth = 16;
|
dummyDesc.fWidth = 16;
|
||||||
dummyDesc.fHeight = 22;
|
dummyDesc.fHeight = 22;
|
||||||
proxies[1] = GrSurfaceProxy::MakeDeferred(context->resourceProvider(),
|
sk_sp<GrTexture> dummyTexture2(
|
||||||
dummyDesc, SkBudgeted::kNo, nullptr, 0);
|
context->resourceProvider()->createTexture(dummyDesc, SkBudgeted::kNo, nullptr, 0));
|
||||||
|
|
||||||
if (!proxies[0] || !proxies[1]) {
|
if (!dummyTexture1 || ! dummyTexture2) {
|
||||||
SkDebugf("Could not allocate dummy textures");
|
SkDebugf("Could not allocate dummy textures");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GrTexture* dummyTextures[] = {dummyTexture1.get(), dummyTexture2.get()};
|
||||||
|
|
||||||
// dummy scissor state
|
// dummy scissor state
|
||||||
GrScissorState scissor;
|
GrScissorState scissor;
|
||||||
|
|
||||||
@ -328,7 +326,7 @@ bool GrDrawingManager::ProgramUnitTest(GrContext* context, int maxStages) {
|
|||||||
std::unique_ptr<GrLegacyMeshDrawOp> op(GrRandomDrawOp(&random, context));
|
std::unique_ptr<GrLegacyMeshDrawOp> op(GrRandomDrawOp(&random, context));
|
||||||
SkASSERT(op);
|
SkASSERT(op);
|
||||||
|
|
||||||
GrProcessorTestData ptd(&random, context, renderTargetContext.get(), proxies);
|
GrProcessorTestData ptd(&random, context, renderTargetContext.get(), dummyTextures);
|
||||||
set_random_color_coverage_stages(&grPaint, &ptd, maxStages);
|
set_random_color_coverage_stages(&grPaint, &ptd, maxStages);
|
||||||
set_random_xpf(&grPaint, &ptd);
|
set_random_xpf(&grPaint, &ptd);
|
||||||
bool snapToCenters = set_random_state(&grPaint, &random);
|
bool snapToCenters = set_random_state(&grPaint, &random);
|
||||||
@ -362,7 +360,7 @@ bool GrDrawingManager::ProgramUnitTest(GrContext* context, int maxStages) {
|
|||||||
for (int j = 0; j < 10; ++j) {
|
for (int j = 0; j < 10; ++j) {
|
||||||
std::unique_ptr<GrLegacyMeshDrawOp> op(GrRandomDrawOp(&random, context));
|
std::unique_ptr<GrLegacyMeshDrawOp> op(GrRandomDrawOp(&random, context));
|
||||||
SkASSERT(op);
|
SkASSERT(op);
|
||||||
GrProcessorTestData ptd(&random, context, renderTargetContext.get(), proxies);
|
GrProcessorTestData ptd(&random, context, renderTargetContext.get(), dummyTextures);
|
||||||
GrPaint grPaint;
|
GrPaint grPaint;
|
||||||
grPaint.setXPFactory(GrPorterDuffXPFactory::Get(SkBlendMode::kSrc));
|
grPaint.setXPFactory(GrPorterDuffXPFactory::Get(SkBlendMode::kSrc));
|
||||||
|
|
||||||
|
@ -27,10 +27,11 @@ DEF_GPUTEST_FOR_NULLGL_CONTEXT(GrSurface, reporter, ctxInfo) {
|
|||||||
desc.fWidth = 256;
|
desc.fWidth = 256;
|
||||||
desc.fHeight = 256;
|
desc.fHeight = 256;
|
||||||
desc.fSampleCnt = 0;
|
desc.fSampleCnt = 0;
|
||||||
sk_sp<GrSurface> texRT1 = context->resourceProvider()->createTexture(desc, SkBudgeted::kNo);
|
GrSurface* texRT1 = context->resourceProvider()->createTexture(
|
||||||
|
desc, SkBudgeted::kNo, nullptr, 0);
|
||||||
|
|
||||||
REPORTER_ASSERT(reporter, texRT1.get() == texRT1->asRenderTarget());
|
REPORTER_ASSERT(reporter, texRT1 == texRT1->asRenderTarget());
|
||||||
REPORTER_ASSERT(reporter, texRT1.get() == texRT1->asTexture());
|
REPORTER_ASSERT(reporter, texRT1 == texRT1->asTexture());
|
||||||
REPORTER_ASSERT(reporter, static_cast<GrSurface*>(texRT1->asRenderTarget()) ==
|
REPORTER_ASSERT(reporter, static_cast<GrSurface*>(texRT1->asRenderTarget()) ==
|
||||||
texRT1->asTexture());
|
texRT1->asTexture());
|
||||||
REPORTER_ASSERT(reporter, texRT1->asRenderTarget() ==
|
REPORTER_ASSERT(reporter, texRT1->asRenderTarget() ==
|
||||||
@ -39,10 +40,10 @@ DEF_GPUTEST_FOR_NULLGL_CONTEXT(GrSurface, reporter, ctxInfo) {
|
|||||||
static_cast<GrSurface*>(texRT1->asTexture()));
|
static_cast<GrSurface*>(texRT1->asTexture()));
|
||||||
|
|
||||||
desc.fFlags = kNone_GrSurfaceFlags;
|
desc.fFlags = kNone_GrSurfaceFlags;
|
||||||
sk_sp<GrTexture> tex1 = context->resourceProvider()->createTexture(desc, SkBudgeted::kNo);
|
GrSurface* tex1 = context->resourceProvider()->createTexture(desc, SkBudgeted::kNo, nullptr, 0);
|
||||||
REPORTER_ASSERT(reporter, nullptr == tex1->asRenderTarget());
|
REPORTER_ASSERT(reporter, nullptr == tex1->asRenderTarget());
|
||||||
REPORTER_ASSERT(reporter, tex1.get() == tex1->asTexture());
|
REPORTER_ASSERT(reporter, tex1 == tex1->asTexture());
|
||||||
REPORTER_ASSERT(reporter, static_cast<GrSurface*>(tex1.get()) == tex1->asTexture());
|
REPORTER_ASSERT(reporter, static_cast<GrSurface*>(tex1) == tex1->asTexture());
|
||||||
|
|
||||||
GrBackendObject backendTex = context->getGpu()->createTestingOnlyBackendTexture(
|
GrBackendObject backendTex = context->getGpu()->createTestingOnlyBackendTexture(
|
||||||
nullptr, 256, 256, kRGBA_8888_GrPixelConfig);
|
nullptr, 256, 256, kRGBA_8888_GrPixelConfig);
|
||||||
@ -65,6 +66,8 @@ DEF_GPUTEST_FOR_NULLGL_CONTEXT(GrSurface, reporter, ctxInfo) {
|
|||||||
REPORTER_ASSERT(reporter, static_cast<GrSurface*>(texRT2->asRenderTarget()) ==
|
REPORTER_ASSERT(reporter, static_cast<GrSurface*>(texRT2->asRenderTarget()) ==
|
||||||
static_cast<GrSurface*>(texRT2->asTexture()));
|
static_cast<GrSurface*>(texRT2->asTexture()));
|
||||||
|
|
||||||
|
texRT1->unref();
|
||||||
|
tex1->unref();
|
||||||
context->getGpu()->deleteTestingOnlyBackendTexture(backendTex);
|
context->getGpu()->deleteTestingOnlyBackendTexture(backendTex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,6 +181,18 @@ DEF_TEST(ImageFilterCache_ImageBackedRaster, reporter) {
|
|||||||
#include "GrContext.h"
|
#include "GrContext.h"
|
||||||
#include "GrResourceProvider.h"
|
#include "GrResourceProvider.h"
|
||||||
|
|
||||||
|
static GrTexture* create_texture(GrContext* context) {
|
||||||
|
SkBitmap srcBM = create_bm();
|
||||||
|
|
||||||
|
GrSurfaceDesc desc;
|
||||||
|
desc.fConfig = kRGBA_8888_GrPixelConfig;
|
||||||
|
desc.fFlags = kNone_GrSurfaceFlags;
|
||||||
|
desc.fWidth = kFullSize;
|
||||||
|
desc.fHeight = kFullSize;
|
||||||
|
|
||||||
|
return context->resourceProvider()->createTexture(desc, SkBudgeted::kNo, srcBM.getPixels(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
static sk_sp<GrTextureProxy> create_proxy(GrResourceProvider* resourceProvider) {
|
static sk_sp<GrTextureProxy> create_proxy(GrResourceProvider* resourceProvider) {
|
||||||
SkBitmap srcBM = create_bm();
|
SkBitmap srcBM = create_bm();
|
||||||
|
|
||||||
@ -196,16 +208,10 @@ static sk_sp<GrTextureProxy> create_proxy(GrResourceProvider* resourceProvider)
|
|||||||
srcBM.rowBytes());
|
srcBM.rowBytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageFilterCache_ImageBackedGPU, reporter, ctxInfo) {
|
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageFilterCache_ImageBackedGPU, reporter, ctxInfo) {
|
||||||
GrContext* context = ctxInfo.grContext();
|
sk_sp<GrTexture> srcTexture(create_texture(ctxInfo.grContext()));
|
||||||
|
if (!srcTexture) {
|
||||||
sk_sp<GrTextureProxy> srcProxy(create_proxy(context->resourceProvider()));
|
|
||||||
if (!srcProxy) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
GrTexture* tex = srcProxy->instantiate(context->resourceProvider());
|
|
||||||
if (!tex) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,8 +222,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageFilterCache_ImageBackedGPU, reporter, ct
|
|||||||
backendDesc.fWidth = kFullSize;
|
backendDesc.fWidth = kFullSize;
|
||||||
backendDesc.fHeight = kFullSize;
|
backendDesc.fHeight = kFullSize;
|
||||||
backendDesc.fSampleCnt = 0;
|
backendDesc.fSampleCnt = 0;
|
||||||
backendDesc.fTextureHandle = tex->getTextureHandle();
|
backendDesc.fTextureHandle = srcTexture->getTextureHandle();
|
||||||
sk_sp<SkImage> srcImage(SkImage::MakeFromTexture(context,
|
sk_sp<SkImage> srcImage(SkImage::MakeFromTexture(ctxInfo.grContext(),
|
||||||
backendDesc,
|
backendDesc,
|
||||||
kPremul_SkAlphaType));
|
kPremul_SkAlphaType));
|
||||||
if (!srcImage) {
|
if (!srcImage) {
|
||||||
|
@ -20,17 +20,9 @@
|
|||||||
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageStorageLoad, reporter, ctxInfo) {
|
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageStorageLoad, reporter, ctxInfo) {
|
||||||
class TestFP : public GrFragmentProcessor {
|
class TestFP : public GrFragmentProcessor {
|
||||||
public:
|
public:
|
||||||
static sk_sp<GrFragmentProcessor> Make(GrResourceProvider* resourceProvider,
|
static sk_sp<GrFragmentProcessor> Make(sk_sp<GrTexture> texture, GrSLMemoryModel mm,
|
||||||
sk_sp<GrTextureProxy> proxy,
|
|
||||||
GrSLMemoryModel mm,
|
|
||||||
GrSLRestrict restrict) {
|
GrSLRestrict restrict) {
|
||||||
// MDB TODO: remove this once ImageStorageAccess is converted to GrTextureProxy
|
return sk_sp<GrFragmentProcessor>(new TestFP(std::move(texture), mm, restrict));
|
||||||
sk_sp<GrTexture> tex(sk_ref_sp(proxy->instantiate(resourceProvider)));
|
|
||||||
if (!tex) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
return sk_sp<GrFragmentProcessor>(new TestFP(std::move(tex), mm, restrict));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* name() const override { return "Image Load Test FP"; }
|
const char* name() const override { return "Image Load Test FP"; }
|
||||||
@ -135,17 +127,15 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageStorageLoad, reporter, ctxInfo) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
desc.fConfig = test.fConfig;
|
desc.fConfig = test.fConfig;
|
||||||
sk_sp<GrTextureProxy> imageStorageTexture =
|
sk_sp<GrTexture> imageStorageTexture(context->resourceProvider()->createTexture(
|
||||||
GrSurfaceProxy::MakeDeferred(context->resourceProvider(), desc,
|
desc, SkBudgeted::kYes, test.fData.get(), 0));
|
||||||
SkBudgeted::kYes, test.fData.get(), 0);
|
|
||||||
|
|
||||||
sk_sp<GrRenderTargetContext> rtContext =
|
sk_sp<GrRenderTargetContext> rtContext =
|
||||||
context->makeRenderTargetContext(SkBackingFit::kExact, kS, kS,
|
context->makeRenderTargetContext(SkBackingFit::kExact, kS, kS,
|
||||||
kRGBA_8888_GrPixelConfig, nullptr);
|
kRGBA_8888_GrPixelConfig, nullptr);
|
||||||
GrPaint paint;
|
GrPaint paint;
|
||||||
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
|
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
|
||||||
paint.addColorFragmentProcessor(TestFP::Make(context->resourceProvider(),
|
paint.addColorFragmentProcessor(TestFP::Make(imageStorageTexture, mm, restrict));
|
||||||
imageStorageTexture, mm, restrict));
|
|
||||||
rtContext->drawPaint(GrNoClip(), std::move(paint), SkMatrix::I());
|
rtContext->drawPaint(GrNoClip(), std::move(paint), SkMatrix::I());
|
||||||
std::unique_ptr<uint32_t[]> readData(new uint32_t[kS * kS]);
|
std::unique_ptr<uint32_t[]> readData(new uint32_t[kS * kS]);
|
||||||
SkImageInfo info = SkImageInfo::Make(kS, kS, kRGBA_8888_SkColorType,
|
SkImageInfo info = SkImageInfo::Make(kS, kS, kRGBA_8888_SkColorType,
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
#if SK_SUPPORT_GPU
|
#if SK_SUPPORT_GPU
|
||||||
#include "GrClip.h"
|
#include "GrClip.h"
|
||||||
#include "GrContext.h"
|
#include "GrContext.h"
|
||||||
#include "GrContextPriv.h"
|
|
||||||
#include "GrRenderTargetContext.h"
|
#include "GrRenderTargetContext.h"
|
||||||
#include "GrResourceProvider.h"
|
#include "GrResourceProvider.h"
|
||||||
#include "GrTexture.h"
|
#include "GrTexture.h"
|
||||||
@ -65,8 +64,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(IntTexture, reporter, ctxInfo) {
|
|||||||
levels[1].fPixels = testData.get();
|
levels[1].fPixels = testData.get();
|
||||||
levels[1].fRowBytes = (kS / 2) * sizeof(int32_t);
|
levels[1].fRowBytes = (kS / 2) * sizeof(int32_t);
|
||||||
|
|
||||||
sk_sp<GrTextureProxy> temp(context->resourceProvider()->createMipMappedTexture(
|
sk_sp<GrTexture> temp(context->resourceProvider()->createMipMappedTexture(desc,
|
||||||
desc,
|
|
||||||
SkBudgeted::kYes,
|
SkBudgeted::kYes,
|
||||||
levels, 2));
|
levels, 2));
|
||||||
REPORTER_ASSERT(reporter, !temp);
|
REPORTER_ASSERT(reporter, !temp);
|
||||||
@ -82,21 +80,21 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(IntTexture, reporter, ctxInfo) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GrTexture* texture = proxy->instantiate(context->resourceProvider());
|
||||||
|
REPORTER_ASSERT(reporter, texture);
|
||||||
|
if (!texture) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
std::unique_ptr<int32_t[]> readData(new int32_t[kS * kS]);
|
std::unique_ptr<int32_t[]> readData(new int32_t[kS * kS]);
|
||||||
// Test that reading to a non-integer config fails.
|
// Test that reading to a non-integer config fails.
|
||||||
{
|
{
|
||||||
bool success = context->contextPriv().readSurfacePixels(proxy.get(), nullptr,
|
bool success = texture->readPixels(0, 0, kS, kS, kRGBA_8888_GrPixelConfig, readData.get());
|
||||||
0, 0, kS, kS,
|
|
||||||
kRGBA_8888_GrPixelConfig,
|
|
||||||
nullptr, readData.get());
|
|
||||||
REPORTER_ASSERT(reporter, !success);
|
REPORTER_ASSERT(reporter, !success);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::unique_ptr<uint16_t[]> halfData(new uint16_t[4 * kS * kS]);
|
std::unique_ptr<uint16_t[]> halfData(new uint16_t[4 * kS * kS]);
|
||||||
bool success = context->contextPriv().readSurfacePixels(proxy.get(), nullptr,
|
bool success = texture->readPixels(0, 0, kS, kS, kRGBA_half_GrPixelConfig, halfData.get());
|
||||||
0, 0, kS, kS,
|
|
||||||
kRGBA_half_GrPixelConfig,
|
|
||||||
nullptr, halfData.get());
|
|
||||||
REPORTER_ASSERT(reporter, !success);
|
REPORTER_ASSERT(reporter, !success);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
@ -104,10 +102,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(IntTexture, reporter, ctxInfo) {
|
|||||||
// we don't support. Right now this test is counting on GR_RGBA_INTEGER/GL_BYTE being the
|
// we don't support. Right now this test is counting on GR_RGBA_INTEGER/GL_BYTE being the
|
||||||
// implementation-dependent second format).
|
// implementation-dependent second format).
|
||||||
sk_bzero(readData.get(), sizeof(int32_t) * kS * kS);
|
sk_bzero(readData.get(), sizeof(int32_t) * kS * kS);
|
||||||
bool success = context->contextPriv().readSurfacePixels(proxy.get(), nullptr,
|
bool success = texture->readPixels(0, 0, kS, kS, kRGBA_8888_sint_GrPixelConfig,
|
||||||
0, 0, kS, kS,
|
readData.get());
|
||||||
kRGBA_8888_sint_GrPixelConfig,
|
|
||||||
nullptr, readData.get());
|
|
||||||
REPORTER_ASSERT(reporter, success);
|
REPORTER_ASSERT(reporter, success);
|
||||||
if (success) {
|
if (success) {
|
||||||
check_pixels(reporter, kS, kS, testData.get(), readData.get(), "readPixels");
|
check_pixels(reporter, kS, kS, testData.get(), readData.get(), "readPixels");
|
||||||
@ -115,12 +111,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(IntTexture, reporter, ctxInfo) {
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
// readPixels should fail if we attempt to use the unpremul flag with an integer texture.
|
// readPixels should fail if we attempt to use the unpremul flag with an integer texture.
|
||||||
bool success = context->contextPriv().readSurfacePixels(
|
bool success = texture->readPixels(0, 0, kS, kS, kRGBA_8888_sint_GrPixelConfig,
|
||||||
proxy.get(), nullptr,
|
readData.get(), 0, GrContext::kUnpremul_PixelOpsFlag);
|
||||||
0, 0, kS, kS,
|
|
||||||
kRGBA_8888_sint_GrPixelConfig,
|
|
||||||
nullptr, readData.get(), 0,
|
|
||||||
GrContextPriv::kUnpremul_PixelOpsFlag);
|
|
||||||
REPORTER_ASSERT(reporter, !success);
|
REPORTER_ASSERT(reporter, !success);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,11 +125,16 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(IntTexture, reporter, ctxInfo) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GrSurface* copySurface = dstContext->asTextureProxy()->instantiate(
|
||||||
|
context->resourceProvider());
|
||||||
|
REPORTER_ASSERT(reporter, copySurface);
|
||||||
|
if (!copySurface) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
sk_bzero(readData.get(), sizeof(int32_t) * kS * kS);
|
sk_bzero(readData.get(), sizeof(int32_t) * kS * kS);
|
||||||
bool success = context->contextPriv().readSurfacePixels(dstContext->asSurfaceProxy(),
|
bool success = copySurface->readPixels(0, 0, kS, kS,
|
||||||
nullptr, 0, 0, kS, kS,
|
kRGBA_8888_sint_GrPixelConfig, readData.get());
|
||||||
kRGBA_8888_sint_GrPixelConfig,
|
|
||||||
nullptr, readData.get());
|
|
||||||
REPORTER_ASSERT(reporter, success);
|
REPORTER_ASSERT(reporter, success);
|
||||||
if (success) {
|
if (success) {
|
||||||
check_pixels(reporter, kS, kS, testData.get(), readData.get(), "copyIntegerToInteger");
|
check_pixels(reporter, kS, kS, testData.get(), readData.get(), "copyIntegerToInteger");
|
||||||
@ -171,28 +168,19 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(IntTexture, reporter, ctxInfo) {
|
|||||||
|
|
||||||
{
|
{
|
||||||
// Can't write pixels from a non-int config.
|
// Can't write pixels from a non-int config.
|
||||||
bool success = context->contextPriv().writeSurfacePixels(proxy.get(), nullptr,
|
bool success = texture->writePixels(0, 0, kS/2, kS/2, kRGBA_8888_GrPixelConfig,
|
||||||
0, 0, kS/2, kS/2,
|
|
||||||
kRGBA_8888_GrPixelConfig, nullptr,
|
|
||||||
bottomRightQuarter, kRowBytes);
|
bottomRightQuarter, kRowBytes);
|
||||||
REPORTER_ASSERT(reporter, !success);
|
REPORTER_ASSERT(reporter, !success);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// Can't use unpremul flag.
|
// Can't use unpremul flag.
|
||||||
bool success = context->contextPriv().writeSurfacePixels(
|
bool success = texture->writePixels(0, 0, kS/2, kS/2, kRGBA_8888_sint_GrPixelConfig,
|
||||||
proxy.get(), nullptr,
|
|
||||||
0, 0, kS/2, kS/2,
|
|
||||||
kRGBA_8888_sint_GrPixelConfig,
|
|
||||||
nullptr,
|
|
||||||
bottomRightQuarter, kRowBytes,
|
bottomRightQuarter, kRowBytes,
|
||||||
GrContextPriv::kUnpremul_PixelOpsFlag);
|
GrContext::kUnpremul_PixelOpsFlag);
|
||||||
REPORTER_ASSERT(reporter, !success);
|
REPORTER_ASSERT(reporter, !success);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
bool success = context->contextPriv().writeSurfacePixels(proxy.get(), nullptr,
|
bool success = texture->writePixels(0, 0, kS/2, kS/2, kRGBA_8888_sint_GrPixelConfig,
|
||||||
0, 0, kS/2, kS/2,
|
|
||||||
kRGBA_8888_sint_GrPixelConfig,
|
|
||||||
nullptr,
|
|
||||||
bottomRightQuarter, kRowBytes);
|
bottomRightQuarter, kRowBytes);
|
||||||
REPORTER_ASSERT(reporter, success);
|
REPORTER_ASSERT(reporter, success);
|
||||||
if (!success) {
|
if (!success) {
|
||||||
@ -200,10 +188,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(IntTexture, reporter, ctxInfo) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sk_bzero(readData.get(), sizeof(int32_t) * kS * kS);
|
sk_bzero(readData.get(), sizeof(int32_t) * kS * kS);
|
||||||
success = context->contextPriv().readSurfacePixels(proxy.get(), nullptr,
|
success = texture->readPixels(0, 0, kS, kS, kRGBA_8888_sint_GrPixelConfig, readData.get());
|
||||||
0, 0, kS, kS,
|
|
||||||
kRGBA_8888_sint_GrPixelConfig,
|
|
||||||
nullptr, readData.get(), 0);
|
|
||||||
REPORTER_ASSERT(reporter, success);
|
REPORTER_ASSERT(reporter, success);
|
||||||
if (!success) {
|
if (!success) {
|
||||||
return;
|
return;
|
||||||
@ -234,10 +219,10 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(IntTexture, reporter, ctxInfo) {
|
|||||||
expectedData.get()[i] = ((0xFF * a) << 24) | ((0xFF * b) << 16) |
|
expectedData.get()[i] = ((0xFF * a) << 24) | ((0xFF * b) << 16) |
|
||||||
((0xFF * g) << 8) | (0xFF * r);
|
((0xFF * g) << 8) | (0xFF * r);
|
||||||
}
|
}
|
||||||
context->contextPriv().writeSurfacePixels(proxy.get(), nullptr,
|
texture->writePixels(0, 0, kS, kS, kRGBA_8888_sint_GrPixelConfig, testData.get());
|
||||||
0, 0, kS, kS,
|
|
||||||
kRGBA_8888_sint_GrPixelConfig, nullptr,
|
sk_sp<GrTextureProxy> intTextureProxy = GrSurfaceProxy::MakeWrapped(sk_ref_sp(texture));
|
||||||
testData.get(), 0);
|
texture = nullptr; // unused from here on out
|
||||||
|
|
||||||
sk_sp<GrRenderTargetContext> rtContext = context->makeRenderTargetContext(
|
sk_sp<GrRenderTargetContext> rtContext = context->makeRenderTargetContext(
|
||||||
SkBackingFit::kExact, kS, kS, kRGBA_8888_GrPixelConfig, nullptr);
|
SkBackingFit::kExact, kS, kS, kRGBA_8888_GrPixelConfig, nullptr);
|
||||||
@ -253,7 +238,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(IntTexture, reporter, ctxInfo) {
|
|||||||
|
|
||||||
for (auto filter : kNamedFilters) {
|
for (auto filter : kNamedFilters) {
|
||||||
sk_sp<GrFragmentProcessor> fp(GrSimpleTextureEffect::Make(context->resourceProvider(),
|
sk_sp<GrFragmentProcessor> fp(GrSimpleTextureEffect::Make(context->resourceProvider(),
|
||||||
proxy, nullptr,
|
intTextureProxy, nullptr,
|
||||||
SkMatrix::I(),
|
SkMatrix::I(),
|
||||||
filter.fMode));
|
filter.fMode));
|
||||||
REPORTER_ASSERT(reporter, fp);
|
REPORTER_ASSERT(reporter, fp);
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
|
|
||||||
#if SK_SUPPORT_GPU
|
#if SK_SUPPORT_GPU
|
||||||
#include "GrContext.h"
|
#include "GrContext.h"
|
||||||
#include "GrContextPriv.h"
|
|
||||||
#include "GrResourceProvider.h"
|
#include "GrResourceProvider.h"
|
||||||
#include "GrTexture.h"
|
#include "GrTexture.h"
|
||||||
|
|
||||||
@ -117,13 +116,10 @@ void runTest(skiatest::Reporter* reporter, GrContext* context,
|
|||||||
desc.fHeight = DEV_H;
|
desc.fHeight = DEV_H;
|
||||||
desc.fConfig = config;
|
desc.fConfig = config;
|
||||||
desc.fOrigin = 0 == origin ? kTopLeft_GrSurfaceOrigin : kBottomLeft_GrSurfaceOrigin;
|
desc.fOrigin = 0 == origin ? kTopLeft_GrSurfaceOrigin : kBottomLeft_GrSurfaceOrigin;
|
||||||
sk_sp<GrTextureProxy> fpProxy = GrSurfaceProxy::MakeDeferred(context->resourceProvider(),
|
sk_sp<GrTexture> fpTexture(context->resourceProvider()->createTexture(
|
||||||
desc, SkBudgeted::kNo,
|
desc, SkBudgeted::kNo, controlPixelData.begin(), 0));
|
||||||
controlPixelData.begin(), 0);
|
SkASSERT(fpTexture);
|
||||||
SkASSERT(fpProxy);
|
fpTexture->readPixels(0, 0, DEV_W, DEV_H, kRGBA_8888_GrPixelConfig, readBuffer.begin(), 0);
|
||||||
context->contextPriv().readSurfacePixels(fpProxy.get(), nullptr, 0, 0, DEV_W, DEV_H,
|
|
||||||
kRGBA_8888_GrPixelConfig, nullptr,
|
|
||||||
readBuffer.begin(), 0);
|
|
||||||
if (kRGBA_4444_GrPixelConfig == config) {
|
if (kRGBA_4444_GrPixelConfig == config) {
|
||||||
check_4444(reporter, controlPixelData, readBuffer);
|
check_4444(reporter, controlPixelData, readBuffer);
|
||||||
} else {
|
} else {
|
||||||
|
@ -146,12 +146,12 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(ProcessorRefTest, reporter, ctxInfo) {
|
|||||||
desc,
|
desc,
|
||||||
SkBackingFit::kExact,
|
SkBackingFit::kExact,
|
||||||
SkBudgeted::kYes));
|
SkBudgeted::kYes));
|
||||||
sk_sp<GrTexture> texture2 =
|
sk_sp<GrTexture> texture2(
|
||||||
context->resourceProvider()->createTexture(desc, SkBudgeted::kYes);
|
context->resourceProvider()->createTexture(desc, SkBudgeted::kYes));
|
||||||
sk_sp<GrTexture> texture3 =
|
sk_sp<GrTexture> texture3(
|
||||||
context->resourceProvider()->createTexture(desc, SkBudgeted::kYes);
|
context->resourceProvider()->createTexture(desc, SkBudgeted::kYes));
|
||||||
sk_sp<GrTexture> texture4 =
|
sk_sp<GrTexture> texture4(
|
||||||
context->resourceProvider()->createTexture(desc, SkBudgeted::kYes);
|
context->resourceProvider()->createTexture(desc, SkBudgeted::kYes));
|
||||||
sk_sp<GrBuffer> buffer(texelBufferSupport
|
sk_sp<GrBuffer> buffer(texelBufferSupport
|
||||||
? context->resourceProvider()->createBuffer(
|
? context->resourceProvider()->createBuffer(
|
||||||
1024, GrBufferType::kTexel_GrBufferType,
|
1024, GrBufferType::kTexel_GrBufferType,
|
||||||
@ -298,8 +298,6 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ProcessorOptimizationValidationTest, repor
|
|||||||
desc.fFlags = kRenderTarget_GrSurfaceFlag;
|
desc.fFlags = kRenderTarget_GrSurfaceFlag;
|
||||||
desc.fConfig = kRGBA_8888_GrPixelConfig;
|
desc.fConfig = kRGBA_8888_GrPixelConfig;
|
||||||
|
|
||||||
sk_sp<GrTextureProxy> proxies[2];
|
|
||||||
|
|
||||||
// Put premul data into the RGBA texture that the test FPs can optionally use.
|
// Put premul data into the RGBA texture that the test FPs can optionally use.
|
||||||
std::unique_ptr<GrColor[]> rgbaData(new GrColor[256 * 256]);
|
std::unique_ptr<GrColor[]> rgbaData(new GrColor[256 * 256]);
|
||||||
for (int y = 0; y < 256; ++y) {
|
for (int y = 0; y < 256; ++y) {
|
||||||
@ -308,8 +306,8 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ProcessorOptimizationValidationTest, repor
|
|||||||
texel_color(random.nextULessThan(256), random.nextULessThan(256));
|
texel_color(random.nextULessThan(256), random.nextULessThan(256));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
proxies[0] = GrSurfaceProxy::MakeDeferred(context->resourceProvider(), desc, SkBudgeted::kYes,
|
sk_sp<GrTexture> tex0(context->resourceProvider()->createTexture(
|
||||||
rgbaData.get(), 256 * sizeof(GrColor));
|
desc, SkBudgeted::kYes, rgbaData.get(), 256 * sizeof(GrColor)));
|
||||||
|
|
||||||
// Put random values into the alpha texture that the test FPs can optionally use.
|
// Put random values into the alpha texture that the test FPs can optionally use.
|
||||||
desc.fConfig = kAlpha_8_GrPixelConfig;
|
desc.fConfig = kAlpha_8_GrPixelConfig;
|
||||||
@ -319,9 +317,10 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ProcessorOptimizationValidationTest, repor
|
|||||||
alphaData.get()[256 * y + x] = random.nextULessThan(256);
|
alphaData.get()[256 * y + x] = random.nextULessThan(256);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
proxies[1] = GrSurfaceProxy::MakeDeferred(context->resourceProvider(), desc, SkBudgeted::kYes,
|
sk_sp<GrTexture> tex1(context->resourceProvider()->createTexture(desc, SkBudgeted::kYes,
|
||||||
alphaData.get(), 256);
|
alphaData.get(), 256));
|
||||||
GrProcessorTestData testData(&random, context, rtc.get(), proxies);
|
GrTexture* textures[] = {tex0.get(), tex1.get()};
|
||||||
|
GrProcessorTestData testData(&random, context, rtc.get(), textures);
|
||||||
|
|
||||||
// Use a different array of premul colors for the output of the fragment processor that preceeds
|
// Use a different array of premul colors for the output of the fragment processor that preceeds
|
||||||
// the fragment processor under test.
|
// the fragment processor under test.
|
||||||
|
@ -137,7 +137,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredProxyTest, reporter, ctxInfo) {
|
|||||||
if (SkBackingFit::kApprox == fit) {
|
if (SkBackingFit::kApprox == fit) {
|
||||||
tex.reset(provider->createApproxTexture(desc, 0));
|
tex.reset(provider->createApproxTexture(desc, 0));
|
||||||
} else {
|
} else {
|
||||||
tex = provider->createTexture(desc, budgeted);
|
tex.reset(provider->createTexture(desc, budgeted));
|
||||||
}
|
}
|
||||||
|
|
||||||
sk_sp<GrTextureProxy> proxy(GrSurfaceProxy::MakeDeferred(
|
sk_sp<GrTextureProxy> proxy(GrSurfaceProxy::MakeDeferred(
|
||||||
@ -170,7 +170,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredProxyTest, reporter, ctxInfo) {
|
|||||||
if (SkBackingFit::kApprox == fit) {
|
if (SkBackingFit::kApprox == fit) {
|
||||||
tex.reset(provider->createApproxTexture(desc, 0));
|
tex.reset(provider->createApproxTexture(desc, 0));
|
||||||
} else {
|
} else {
|
||||||
tex = provider->createTexture(desc, budgeted);
|
tex.reset(provider->createTexture(desc, budgeted));
|
||||||
}
|
}
|
||||||
|
|
||||||
sk_sp<GrTextureProxy> proxy(GrSurfaceProxy::MakeDeferred(provider,
|
sk_sp<GrTextureProxy> proxy(GrSurfaceProxy::MakeDeferred(provider,
|
||||||
@ -249,7 +249,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
|
|||||||
// Internal offscreen render target.
|
// Internal offscreen render target.
|
||||||
if (renderable) {
|
if (renderable) {
|
||||||
desc.fFlags = kRenderTarget_GrSurfaceFlag;
|
desc.fFlags = kRenderTarget_GrSurfaceFlag;
|
||||||
tex = provider->createTexture(desc, budgeted);
|
tex.reset(provider->createTexture(desc, budgeted));
|
||||||
sk_sp<GrRenderTarget> rt(sk_ref_sp(tex->asRenderTarget()));
|
sk_sp<GrRenderTarget> rt(sk_ref_sp(tex->asRenderTarget()));
|
||||||
|
|
||||||
sk_sp<GrSurfaceProxy> sProxy(GrSurfaceProxy::MakeWrapped(rt));
|
sk_sp<GrSurfaceProxy> sProxy(GrSurfaceProxy::MakeWrapped(rt));
|
||||||
@ -264,7 +264,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
|
|||||||
if (!tex) {
|
if (!tex) {
|
||||||
SkASSERT(kNone_GrSurfaceFlags == desc.fFlags );
|
SkASSERT(kNone_GrSurfaceFlags == desc.fFlags );
|
||||||
desc.fSampleCnt = 0;
|
desc.fSampleCnt = 0;
|
||||||
tex = provider->createTexture(desc, budgeted);
|
tex.reset(provider->createTexture(desc, budgeted));
|
||||||
}
|
}
|
||||||
|
|
||||||
sk_sp<GrSurfaceProxy> sProxy(GrSurfaceProxy::MakeWrapped(tex));
|
sk_sp<GrSurfaceProxy> sProxy(GrSurfaceProxy::MakeWrapped(tex));
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
#if SK_SUPPORT_GPU
|
#if SK_SUPPORT_GPU
|
||||||
#include "GrContext.h"
|
#include "GrContext.h"
|
||||||
#include "GrContextPriv.h"
|
|
||||||
#include "GrResourceProvider.h"
|
#include "GrResourceProvider.h"
|
||||||
#include "SkGr.h"
|
#include "SkGr.h"
|
||||||
#endif
|
#endif
|
||||||
@ -124,16 +123,11 @@ static void fill_src_canvas(SkCanvas* canvas) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if SK_SUPPORT_GPU
|
#if SK_SUPPORT_GPU
|
||||||
static void fill_src_texture(GrContext* context, GrTextureProxy* proxy) {
|
static void fill_src_texture(GrTexture* texture) {
|
||||||
SkBitmap bmp = make_src_bitmap();
|
SkBitmap bmp = make_src_bitmap();
|
||||||
bmp.lockPixels();
|
bmp.lockPixels();
|
||||||
|
texture->writePixels(0, 0, DEV_W, DEV_H, kSkia8888_GrPixelConfig, bmp.getPixels(),
|
||||||
SkDEBUGCODE(bool result =) context->contextPriv().writeSurfacePixels(
|
bmp.rowBytes());
|
||||||
proxy, nullptr,
|
|
||||||
0, 0, DEV_W, DEV_H,
|
|
||||||
kSkia8888_GrPixelConfig, nullptr,
|
|
||||||
bmp.getPixels(), bmp.rowBytes());
|
|
||||||
SkASSERT(result);
|
|
||||||
bmp.unlockPixels();
|
bmp.unlockPixels();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -442,9 +436,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadPixels_Gpu, reporter, ctxInfo) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if SK_SUPPORT_GPU
|
#if SK_SUPPORT_GPU
|
||||||
static void test_readpixels_texture(skiatest::Reporter* reporter,
|
static void test_readpixels_texture(skiatest::Reporter* reporter, GrTexture* texture) {
|
||||||
GrContext* context, sk_sp<GrTextureProxy> proxy) {
|
fill_src_texture(texture);
|
||||||
fill_src_texture(context, proxy.get());
|
|
||||||
for (size_t rect = 0; rect < SK_ARRAY_COUNT(gReadPixelsTestRects); ++rect) {
|
for (size_t rect = 0; rect < SK_ARRAY_COUNT(gReadPixelsTestRects); ++rect) {
|
||||||
const SkIRect& srcRect = gReadPixelsTestRects[rect];
|
const SkIRect& srcRect = gReadPixelsTestRects[rect];
|
||||||
for (BitmapInit bmi = kFirstBitmapInit; bmi <= kLast_BitmapInit; bmi = nextBMI(bmi)) {
|
for (BitmapInit bmi = kFirstBitmapInit; bmi <= kLast_BitmapInit; bmi = nextBMI(bmi)) {
|
||||||
@ -459,18 +452,16 @@ static void test_readpixels_texture(skiatest::Reporter* reporter,
|
|||||||
// Try doing the read directly from a non-renderable texture
|
// Try doing the read directly from a non-renderable texture
|
||||||
if (startsWithPixels) {
|
if (startsWithPixels) {
|
||||||
fill_dst_bmp_with_init_data(&bmp);
|
fill_dst_bmp_with_init_data(&bmp);
|
||||||
GrPixelConfig dstConfig = SkImageInfo2GrPixelConfig(bmp.info(),
|
GrPixelConfig dstConfig =
|
||||||
*context->caps());
|
SkImageInfo2GrPixelConfig(bmp.info(), *texture->getContext()->caps());
|
||||||
uint32_t flags = 0;
|
uint32_t flags = 0;
|
||||||
if (gReadPixelsConfigs[c].fAlphaType == kUnpremul_SkAlphaType) {
|
if (gReadPixelsConfigs[c].fAlphaType == kUnpremul_SkAlphaType) {
|
||||||
flags = GrContextPriv::kUnpremul_PixelOpsFlag;
|
flags = GrContext::kUnpremul_PixelOpsFlag;
|
||||||
}
|
}
|
||||||
bmp.lockPixels();
|
bmp.lockPixels();
|
||||||
bool success = context->contextPriv().readSurfacePixels(
|
bool success = texture->readPixels(srcRect.fLeft, srcRect.fTop, bmp.width(),
|
||||||
proxy.get(), nullptr,
|
bmp.height(), dstConfig, bmp.getPixels(),
|
||||||
srcRect.fLeft, srcRect.fTop, bmp.width(),
|
bmp.rowBytes(), flags);
|
||||||
bmp.height(), dstConfig, nullptr,
|
|
||||||
bmp.getPixels(), bmp.rowBytes(), flags);
|
|
||||||
bmp.unlockPixels();
|
bmp.unlockPixels();
|
||||||
check_read(reporter, bmp, srcRect.fLeft, srcRect.fTop,
|
check_read(reporter, bmp, srcRect.fLeft, srcRect.fTop,
|
||||||
success, true,
|
success, true,
|
||||||
@ -490,10 +481,9 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadPixels_Texture, reporter, ctxInfo) {
|
|||||||
desc.fHeight = DEV_H;
|
desc.fHeight = DEV_H;
|
||||||
desc.fConfig = kSkia8888_GrPixelConfig;
|
desc.fConfig = kSkia8888_GrPixelConfig;
|
||||||
desc.fOrigin = origin;
|
desc.fOrigin = origin;
|
||||||
sk_sp<GrTexture> texture =
|
sk_sp<GrTexture> texture(ctxInfo.grContext()->resourceProvider()->createTexture(desc,
|
||||||
ctxInfo.grContext()->resourceProvider()->createTexture(desc, SkBudgeted::kNo);
|
SkBudgeted::kNo));
|
||||||
test_readpixels_texture(reporter, ctxInfo.grContext(),
|
test_readpixels_texture(reporter, texture.get());
|
||||||
GrSurfaceProxy::MakeWrapped(std::move(texture)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -159,10 +159,9 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) {
|
|||||||
rgbaData[y * X_SIZE + x] = GrColorPackRGBA(6, 7, 8, alphaData[y * X_SIZE + x]);
|
rgbaData[y * X_SIZE + x] = GrColorPackRGBA(6, 7, 8, alphaData[y * X_SIZE + x]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sk_sp<GrTextureProxy> proxy =
|
sk_sp<GrTexture> texture(
|
||||||
GrSurfaceProxy::MakeDeferred(context->resourceProvider(), desc, SkBudgeted::kNo,
|
context->resourceProvider()->createTexture(desc, SkBudgeted::kNo, rgbaData, 0));
|
||||||
rgbaData, 0);
|
if (!texture) {
|
||||||
if (!proxy) {
|
|
||||||
// We always expect to be able to create a RGBA texture
|
// We always expect to be able to create a RGBA texture
|
||||||
if (!rt && kRGBA_8888_GrPixelConfig == desc.fConfig) {
|
if (!rt && kRGBA_8888_GrPixelConfig == desc.fConfig) {
|
||||||
ERRORF(reporter, "Failed to create RGBA texture.");
|
ERRORF(reporter, "Failed to create RGBA texture.");
|
||||||
@ -178,10 +177,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) {
|
|||||||
memset(readback.get(), kClearValue, nonZeroRowBytes * Y_SIZE);
|
memset(readback.get(), kClearValue, nonZeroRowBytes * Y_SIZE);
|
||||||
|
|
||||||
// read the texture back
|
// read the texture back
|
||||||
bool result = context->contextPriv().readSurfacePixels(
|
bool result = texture->readPixels(0, 0, desc.fWidth, desc.fHeight,
|
||||||
proxy.get(), nullptr,
|
kAlpha_8_GrPixelConfig,
|
||||||
0, 0, desc.fWidth, desc.fHeight,
|
|
||||||
kAlpha_8_GrPixelConfig, nullptr,
|
|
||||||
readback.get(), rowBytes);
|
readback.get(), rowBytes);
|
||||||
REPORTER_ASSERT_MESSAGE(reporter, result, "8888 readPixels failed");
|
REPORTER_ASSERT_MESSAGE(reporter, result, "8888 readPixels failed");
|
||||||
|
|
||||||
|
@ -184,7 +184,7 @@ DEF_GPUTEST_FOR_CONTEXTS(ResourceCacheStencilBuffers, &is_rendering_and_not_angl
|
|||||||
smallMSAART0 && smallMSAART0->asRenderTarget() &&
|
smallMSAART0 && smallMSAART0->asRenderTarget() &&
|
||||||
smallMSAART0->asRenderTarget()->numColorSamples() < 8) {
|
smallMSAART0->asRenderTarget()->numColorSamples() < 8) {
|
||||||
smallMSAADesc.fSampleCnt = 8;
|
smallMSAADesc.fSampleCnt = 8;
|
||||||
smallMSAART1 = resourceProvider->createTexture(smallMSAADesc, SkBudgeted::kNo);
|
smallMSAART1.reset(resourceProvider->createTexture(smallMSAADesc, SkBudgeted::kNo));
|
||||||
sk_sp<GrTexture> smallMSAART1(
|
sk_sp<GrTexture> smallMSAART1(
|
||||||
resourceProvider->createTexture(smallMSAADesc, SkBudgeted::kNo));
|
resourceProvider->createTexture(smallMSAADesc, SkBudgeted::kNo));
|
||||||
if (smallMSAART1 && smallMSAART1->asRenderTarget()) {
|
if (smallMSAART1 && smallMSAART1->asRenderTarget()) {
|
||||||
@ -1514,10 +1514,10 @@ static sk_sp<GrTexture> make_normal_texture(GrResourceProvider* provider,
|
|||||||
desc.fConfig = kRGBA_8888_GrPixelConfig;
|
desc.fConfig = kRGBA_8888_GrPixelConfig;
|
||||||
desc.fSampleCnt = sampleCnt;
|
desc.fSampleCnt = sampleCnt;
|
||||||
|
|
||||||
return provider->createTexture(desc, SkBudgeted::kYes);
|
return sk_sp<GrTexture>(provider->createTexture(desc, SkBudgeted::kYes));
|
||||||
}
|
}
|
||||||
|
|
||||||
static sk_sp<GrTextureProxy> make_mipmap_proxy(GrResourceProvider* provider,
|
static sk_sp<GrTexture> make_mipmap_texture(GrResourceProvider* provider,
|
||||||
GrSurfaceFlags flags,
|
GrSurfaceFlags flags,
|
||||||
int width, int height,
|
int width, int height,
|
||||||
int sampleCnt) {
|
int sampleCnt) {
|
||||||
@ -1552,7 +1552,8 @@ static sk_sp<GrTextureProxy> make_mipmap_proxy(GrResourceProvider* provider,
|
|||||||
desc.fSampleCnt = sampleCnt;
|
desc.fSampleCnt = sampleCnt;
|
||||||
desc.fIsMipMapped = true;
|
desc.fIsMipMapped = true;
|
||||||
|
|
||||||
return provider->createMipMappedTexture(desc, SkBudgeted::kYes, texels.get(), mipLevelCount);
|
return sk_sp<GrTexture>(provider->createMipMappedTexture(desc, SkBudgeted::kYes,
|
||||||
|
texels.get(), mipLevelCount));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exercise GrSurface::gpuMemorySize for different combos of MSAA, RT-only,
|
// Exercise GrSurface::gpuMemorySize for different combos of MSAA, RT-only,
|
||||||
@ -1563,10 +1564,9 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GPUMemorySize, reporter, ctxInfo) {
|
|||||||
|
|
||||||
static const int kSize = 64;
|
static const int kSize = 64;
|
||||||
|
|
||||||
// Normal versions
|
|
||||||
{
|
|
||||||
sk_sp<GrTexture> tex;
|
sk_sp<GrTexture> tex;
|
||||||
|
|
||||||
|
// Normal versions
|
||||||
tex = make_normal_texture(provider, kRenderTarget_GrSurfaceFlag, kSize, kSize, 0);
|
tex = make_normal_texture(provider, kRenderTarget_GrSurfaceFlag, kSize, kSize, 0);
|
||||||
size_t size = tex->gpuMemorySize();
|
size_t size = tex->gpuMemorySize();
|
||||||
REPORTER_ASSERT(reporter, kSize*kSize*4 == size);
|
REPORTER_ASSERT(reporter, kSize*kSize*4 == size);
|
||||||
@ -1582,30 +1582,24 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GPUMemorySize, reporter, ctxInfo) {
|
|||||||
tex = make_normal_texture(provider, kNone_GrSurfaceFlags, kSize, kSize, 0);
|
tex = make_normal_texture(provider, kNone_GrSurfaceFlags, kSize, kSize, 0);
|
||||||
size = tex->gpuMemorySize();
|
size = tex->gpuMemorySize();
|
||||||
REPORTER_ASSERT(reporter, kSize*kSize*4 == size);
|
REPORTER_ASSERT(reporter, kSize*kSize*4 == size);
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Mipmapped versions
|
// Mipmapped versions
|
||||||
{
|
tex = make_mipmap_texture(provider, kRenderTarget_GrSurfaceFlag, kSize, kSize, 0);
|
||||||
sk_sp<GrTextureProxy> proxy;
|
size = tex->gpuMemorySize();
|
||||||
|
|
||||||
proxy = make_mipmap_proxy(provider, kRenderTarget_GrSurfaceFlag, kSize, kSize, 0);
|
|
||||||
size_t size = proxy->gpuMemorySize();
|
|
||||||
REPORTER_ASSERT(reporter, kSize*kSize*4+(kSize*kSize*4)/3 == size);
|
REPORTER_ASSERT(reporter, kSize*kSize*4+(kSize*kSize*4)/3 == size);
|
||||||
|
|
||||||
if (context->caps()->maxSampleCount() >= 4) {
|
if (context->caps()->maxSampleCount() >= 4) {
|
||||||
proxy = make_mipmap_proxy(provider, kRenderTarget_GrSurfaceFlag, kSize, kSize, 4);
|
tex = make_mipmap_texture(provider, kRenderTarget_GrSurfaceFlag, kSize, kSize, 4);
|
||||||
size = proxy->gpuMemorySize();
|
size = tex->gpuMemorySize();
|
||||||
REPORTER_ASSERT(reporter,
|
REPORTER_ASSERT(reporter,
|
||||||
kSize*kSize*4+(kSize*kSize*4)/3 == size || // msaa4 failed
|
kSize*kSize*4+(kSize*kSize*4)/3 == size || // msaa4 failed
|
||||||
kSize*kSize*4*4+(kSize*kSize*4)/3 == size || // auto-resolving
|
kSize*kSize*4*4+(kSize*kSize*4)/3 == size || // auto-resolving
|
||||||
kSize*kSize*4*5+(kSize*kSize*4)/3 == size); // explicit resolve buffer
|
kSize*kSize*4*5+(kSize*kSize*4)/3 == size); // explicit resolve buffer
|
||||||
}
|
}
|
||||||
|
|
||||||
proxy = make_mipmap_proxy(provider, kNone_GrSurfaceFlags, kSize, kSize, 0);
|
tex = make_mipmap_texture(provider, kNone_GrSurfaceFlags, kSize, kSize, 0);
|
||||||
size = proxy->gpuMemorySize();
|
size = tex->gpuMemorySize();
|
||||||
REPORTER_ASSERT(reporter, kSize*kSize*4+(kSize*kSize*4)/3 == size);
|
REPORTER_ASSERT(reporter, kSize*kSize*4+(kSize*kSize*4)/3 == size);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -169,7 +169,6 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SRGBReadWritePixels, reporter, ctxInfo) {
|
|||||||
kPremul_SkAlphaType);
|
kPremul_SkAlphaType);
|
||||||
GrSurfaceDesc desc;
|
GrSurfaceDesc desc;
|
||||||
desc.fFlags = kRenderTarget_GrSurfaceFlag;
|
desc.fFlags = kRenderTarget_GrSurfaceFlag;
|
||||||
desc.fOrigin = kBottomLeft_GrSurfaceOrigin;
|
|
||||||
desc.fWidth = kW;
|
desc.fWidth = kW;
|
||||||
desc.fHeight = kH;
|
desc.fHeight = kH;
|
||||||
desc.fConfig = kSRGBA_8888_GrPixelConfig;
|
desc.fConfig = kSRGBA_8888_GrPixelConfig;
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
#if SK_SUPPORT_GPU && SK_ALLOW_STATIC_GLOBAL_INITIALIZERS && defined(SK_VULKAN)
|
#if SK_SUPPORT_GPU && SK_ALLOW_STATIC_GLOBAL_INITIALIZERS && defined(SK_VULKAN)
|
||||||
|
|
||||||
#include "GrContextFactory.h"
|
#include "GrContextFactory.h"
|
||||||
#include "GrContextPriv.h"
|
|
||||||
#include "GrTest.h"
|
#include "GrTest.h"
|
||||||
#include "Test.h"
|
#include "Test.h"
|
||||||
#include "vk/GrVkGpu.h"
|
#include "vk/GrVkGpu.h"
|
||||||
@ -83,60 +82,51 @@ void basic_texture_test(skiatest::Reporter* reporter, GrContext* context, GrPixe
|
|||||||
surfDesc.fHeight = kHeight;
|
surfDesc.fHeight = kHeight;
|
||||||
surfDesc.fConfig = config;
|
surfDesc.fConfig = config;
|
||||||
surfDesc.fSampleCnt = 0;
|
surfDesc.fSampleCnt = 0;
|
||||||
sk_sp<GrTexture> tex0(gpu->createTexture(surfDesc, SkBudgeted::kNo, srcBuffer, 0));
|
GrTexture* tex0 = gpu->createTexture(surfDesc, SkBudgeted::kNo, srcBuffer, 0);
|
||||||
if (tex0) {
|
if (tex0) {
|
||||||
REPORTER_ASSERT(reporter, canCreate);
|
REPORTER_ASSERT(reporter, canCreate);
|
||||||
gpu->readPixels(tex0.get(), 0, 0, kWidth, kHeight, config, dstBuffer, 0);
|
gpu->readPixels(tex0, 0, 0, kWidth, kHeight, config, dstBuffer, 0);
|
||||||
REPORTER_ASSERT(reporter, does_full_buffer_contain_correct_color(srcBuffer,
|
REPORTER_ASSERT(reporter, does_full_buffer_contain_correct_color(srcBuffer,
|
||||||
dstBuffer,
|
dstBuffer,
|
||||||
config,
|
config,
|
||||||
kWidth,
|
kWidth,
|
||||||
kHeight));
|
kHeight));
|
||||||
|
|
||||||
sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeWrapped(tex0);
|
tex0->writePixels(2, 10, 10, 2, config, srcBuffer);
|
||||||
|
|
||||||
bool success = context->contextPriv().writeSurfacePixels(proxy.get(), nullptr,
|
|
||||||
2, 10, 10, 2,
|
|
||||||
config, nullptr, srcBuffer, 0);
|
|
||||||
REPORTER_ASSERT(reporter, success);
|
|
||||||
|
|
||||||
memset(dstBuffer, 0, kWidth*kHeight*sizeof(GrColor));
|
memset(dstBuffer, 0, kWidth*kHeight*sizeof(GrColor));
|
||||||
gpu->readPixels(tex0.get(), 2, 10, 10, 2, config, dstBuffer, 0);
|
gpu->readPixels(tex0, 2, 10, 10, 2, config, dstBuffer, 0);
|
||||||
REPORTER_ASSERT(reporter, does_full_buffer_contain_correct_color(srcBuffer,
|
REPORTER_ASSERT(reporter, does_full_buffer_contain_correct_color(srcBuffer,
|
||||||
dstBuffer,
|
dstBuffer,
|
||||||
config,
|
config,
|
||||||
10,
|
10,
|
||||||
2));
|
2));
|
||||||
|
|
||||||
|
tex0->unref();
|
||||||
} else {
|
} else {
|
||||||
REPORTER_ASSERT(reporter, !canCreate);
|
REPORTER_ASSERT(reporter, !canCreate);
|
||||||
}
|
}
|
||||||
|
|
||||||
surfDesc.fOrigin = kBottomLeft_GrSurfaceOrigin;
|
surfDesc.fOrigin = kBottomLeft_GrSurfaceOrigin;
|
||||||
sk_sp<GrTexture> tex1(gpu->createTexture(surfDesc, SkBudgeted::kNo, srcBuffer, 0));
|
GrTexture* tex1 = gpu->createTexture(surfDesc, SkBudgeted::kNo, srcBuffer, 0);
|
||||||
if (tex1) {
|
if (tex1) {
|
||||||
REPORTER_ASSERT(reporter, canCreate);
|
REPORTER_ASSERT(reporter, canCreate);
|
||||||
gpu->readPixels(tex1.get(), 0, 0, kWidth, kHeight, config, dstBuffer, 0);
|
gpu->readPixels(tex1, 0, 0, kWidth, kHeight, config, dstBuffer, 0);
|
||||||
REPORTER_ASSERT(reporter, does_full_buffer_contain_correct_color(srcBuffer,
|
REPORTER_ASSERT(reporter, does_full_buffer_contain_correct_color(srcBuffer,
|
||||||
dstBuffer,
|
dstBuffer,
|
||||||
config,
|
config,
|
||||||
kWidth,
|
kWidth,
|
||||||
kHeight));
|
kHeight));
|
||||||
|
|
||||||
sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeWrapped(tex1);
|
tex1->writePixels(5, 4, 4, 5, config, srcBuffer);
|
||||||
|
|
||||||
bool success = context->contextPriv().writeSurfacePixels(proxy.get(), nullptr,
|
|
||||||
5, 4, 4, 5, config, nullptr,
|
|
||||||
srcBuffer, 0);
|
|
||||||
REPORTER_ASSERT(reporter, success);
|
|
||||||
|
|
||||||
memset(dstBuffer, 0, kWidth*kHeight*sizeof(GrColor));
|
memset(dstBuffer, 0, kWidth*kHeight*sizeof(GrColor));
|
||||||
gpu->readPixels(tex1.get(), 5, 4, 4, 5, config, dstBuffer, 0);
|
gpu->readPixels(tex1, 5, 4, 4, 5, config, dstBuffer, 0);
|
||||||
REPORTER_ASSERT(reporter, does_full_buffer_contain_correct_color(srcBuffer,
|
REPORTER_ASSERT(reporter, does_full_buffer_contain_correct_color(srcBuffer,
|
||||||
dstBuffer,
|
dstBuffer,
|
||||||
config,
|
config,
|
||||||
4,
|
4,
|
||||||
5));
|
5));
|
||||||
|
|
||||||
|
tex1->unref();
|
||||||
} else {
|
} else {
|
||||||
REPORTER_ASSERT(reporter, !canCreate);
|
REPORTER_ASSERT(reporter, !canCreate);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user