Revert of Make "priv" classes for GrTexure and GrSurface. (patchset #9 id:260001 of https://codereview.chromium.org/596053002/)
Reason for revert: Breaking the Chrome builds with: lib/libcc.so: error: undefined reference to 'GrAutoScratchTexture::detach()' (http://108.170.220.120:10117/builders/Canary-Chrome-Ubuntu13.10-Ninja-x86_64-DRT/builds/2990/steps/Retry_BuildContentShell_1/logs/stdio) Original issue's description: > Make "priv" classes for GrTexure and GrSurface. R=egdaniel@google.com, joshualitt@google.com, bsalomon@google.com TBR=bsalomon@google.com, egdaniel@google.com, joshualitt@google.com NOTREECHECKS=true NOTRY=true Author: robertphillips@google.com Review URL: https://codereview.chromium.org/618733002
This commit is contained in:
parent
dbe6074a06
commit
b06e5a2f55
@ -14,7 +14,6 @@
|
|||||||
#include "GrResourceCache.h"
|
#include "GrResourceCache.h"
|
||||||
#include "GrStencilBuffer.h"
|
#include "GrStencilBuffer.h"
|
||||||
#include "GrTexture.h"
|
#include "GrTexture.h"
|
||||||
#include "GrTexturePriv.h"
|
|
||||||
#include "SkCanvas.h"
|
#include "SkCanvas.h"
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@ -63,7 +62,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static GrResourceKey ComputeKey(const GrTextureDesc& desc) {
|
static GrResourceKey ComputeKey(const GrTextureDesc& desc) {
|
||||||
return GrTexturePriv::ComputeScratchKey(desc);
|
return GrTextureImpl::ComputeScratchKey(desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
int fID;
|
int fID;
|
||||||
|
@ -149,7 +149,6 @@
|
|||||||
'<(skia_src_path)/gpu/GrSWMaskHelper.h',
|
'<(skia_src_path)/gpu/GrSWMaskHelper.h',
|
||||||
'<(skia_src_path)/gpu/GrSoftwarePathRenderer.cpp',
|
'<(skia_src_path)/gpu/GrSoftwarePathRenderer.cpp',
|
||||||
'<(skia_src_path)/gpu/GrSoftwarePathRenderer.h',
|
'<(skia_src_path)/gpu/GrSoftwarePathRenderer.h',
|
||||||
'<(skia_src_path)/gpu/GrSurfacePriv.h',
|
|
||||||
'<(skia_src_path)/gpu/GrSurface.cpp',
|
'<(skia_src_path)/gpu/GrSurface.cpp',
|
||||||
'<(skia_src_path)/gpu/GrTemplates.h',
|
'<(skia_src_path)/gpu/GrTemplates.h',
|
||||||
'<(skia_src_path)/gpu/GrTextContext.cpp',
|
'<(skia_src_path)/gpu/GrTextContext.cpp',
|
||||||
@ -158,7 +157,6 @@
|
|||||||
'<(skia_src_path)/gpu/GrTextStrike.h',
|
'<(skia_src_path)/gpu/GrTextStrike.h',
|
||||||
'<(skia_src_path)/gpu/GrTextStrike_impl.h',
|
'<(skia_src_path)/gpu/GrTextStrike_impl.h',
|
||||||
'<(skia_src_path)/gpu/GrTexture.cpp',
|
'<(skia_src_path)/gpu/GrTexture.cpp',
|
||||||
'<(skia_src_path)/gpu/GrTexturePriv.h',
|
|
||||||
'<(skia_src_path)/gpu/GrTextureAccess.cpp',
|
'<(skia_src_path)/gpu/GrTextureAccess.cpp',
|
||||||
'<(skia_src_path)/gpu/GrVertexBuffer.h',
|
'<(skia_src_path)/gpu/GrVertexBuffer.h',
|
||||||
|
|
||||||
|
@ -1121,7 +1121,24 @@ public:
|
|||||||
* Note that the caller is assumed to accept and manage the ref to the
|
* Note that the caller is assumed to accept and manage the ref to the
|
||||||
* returned texture.
|
* returned texture.
|
||||||
*/
|
*/
|
||||||
GrTexture* detach();
|
GrTexture* detach() {
|
||||||
|
if (NULL == fTexture) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
GrTexture* texture = fTexture;
|
||||||
|
fTexture = NULL;
|
||||||
|
|
||||||
|
// This GrAutoScratchTexture has a ref from lockAndRefScratchTexture, which we give up now.
|
||||||
|
// The cache also has a ref which we are lending to the caller of detach(). When the caller
|
||||||
|
// lets go of the ref and the ref count goes to 0 internal_dispose will see this flag is
|
||||||
|
// set and re-ref the texture, thereby restoring the cache's ref.
|
||||||
|
SkASSERT(!texture->unique());
|
||||||
|
texture->impl()->setFlag((GrTextureFlags) GrTextureImpl::kReturnToCache_FlagBit);
|
||||||
|
texture->unref();
|
||||||
|
SkASSERT(texture->getCacheEntry());
|
||||||
|
|
||||||
|
return texture;
|
||||||
|
}
|
||||||
|
|
||||||
GrTexture* set(GrContext* context,
|
GrTexture* set(GrContext* context,
|
||||||
const GrTextureDesc& desc,
|
const GrTextureDesc& desc,
|
||||||
|
@ -11,12 +11,11 @@
|
|||||||
|
|
||||||
#include "GrTypes.h"
|
#include "GrTypes.h"
|
||||||
#include "GrGpuResource.h"
|
#include "GrGpuResource.h"
|
||||||
#include "SkImageInfo.h"
|
|
||||||
#include "SkRect.h"
|
#include "SkRect.h"
|
||||||
|
|
||||||
class GrRenderTarget;
|
|
||||||
class GrSurfacePriv;
|
|
||||||
class GrTexture;
|
class GrTexture;
|
||||||
|
class GrRenderTarget;
|
||||||
|
struct SkImageInfo;
|
||||||
|
|
||||||
class GrSurface : public GrGpuResource {
|
class GrSurface : public GrGpuResource {
|
||||||
public:
|
public:
|
||||||
@ -60,6 +59,8 @@ public:
|
|||||||
*/
|
*/
|
||||||
const GrTextureDesc& desc() const { return fDesc; }
|
const GrTextureDesc& desc() const { return fDesc; }
|
||||||
|
|
||||||
|
SkImageInfo info() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the texture associated with the surface, may be NULL.
|
* @return the texture associated with the surface, may be NULL.
|
||||||
*/
|
*/
|
||||||
@ -72,6 +73,22 @@ public:
|
|||||||
virtual GrRenderTarget* asRenderTarget() = 0;
|
virtual GrRenderTarget* asRenderTarget() = 0;
|
||||||
virtual const GrRenderTarget* asRenderTarget() const = 0;
|
virtual const GrRenderTarget* asRenderTarget() const = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether this GrSurface refers to the same GPU object as other. This
|
||||||
|
* catches the case where a GrTexture and GrRenderTarget refer to the same
|
||||||
|
* GPU memory.
|
||||||
|
*/
|
||||||
|
bool isSameAs(const GrSurface* other) const {
|
||||||
|
const GrRenderTarget* thisRT = this->asRenderTarget();
|
||||||
|
if (thisRT) {
|
||||||
|
return thisRT == other->asRenderTarget();
|
||||||
|
} else {
|
||||||
|
const GrTexture* thisTex = this->asTexture();
|
||||||
|
SkASSERT(thisTex); // We must be one or the other
|
||||||
|
return thisTex == other->asTexture();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads a rectangle of pixels from the surface.
|
* Reads a rectangle of pixels from the surface.
|
||||||
* @param left left edge of the rectangle to read (inclusive)
|
* @param left left edge of the rectangle to read (inclusive)
|
||||||
@ -112,22 +129,17 @@ public:
|
|||||||
size_t rowBytes = 0,
|
size_t rowBytes = 0,
|
||||||
uint32_t pixelOpsFlags = 0) = 0;
|
uint32_t pixelOpsFlags = 0) = 0;
|
||||||
|
|
||||||
/** Access methods that are only to be used within Skia code. */
|
/**
|
||||||
inline GrSurfacePriv surfacePriv();
|
* Write the contents of the surface to a PNG. Returns true if successful.
|
||||||
inline const GrSurfacePriv surfacePriv() const;
|
* @param filename Full path to desired file
|
||||||
|
*/
|
||||||
protected:
|
|
||||||
// Methods made available via GrSurfacePriv
|
|
||||||
SkImageInfo info() const;
|
|
||||||
bool savePixels(const char* filename);
|
bool savePixels(const char* filename);
|
||||||
|
|
||||||
bool hasPendingRead() const;
|
bool hasPendingRead() const;
|
||||||
bool hasPendingWrite() const;
|
bool hasPendingWrite() const;
|
||||||
bool hasPendingIO() const;
|
bool hasPendingIO() const;
|
||||||
bool isSameAs(const GrSurface* other) const;
|
|
||||||
|
|
||||||
// Provides access to methods that should be public within Skia code.
|
|
||||||
friend class GrSurfacePriv;
|
|
||||||
|
|
||||||
|
protected:
|
||||||
GrSurface(GrGpu* gpu, bool isWrapped, const GrTextureDesc& desc)
|
GrSurface(GrGpu* gpu, bool isWrapped, const GrTextureDesc& desc)
|
||||||
: INHERITED(gpu, isWrapped)
|
: INHERITED(gpu, isWrapped)
|
||||||
, fDesc(desc) {
|
, fDesc(desc) {
|
||||||
@ -139,4 +151,4 @@ private:
|
|||||||
typedef GrGpuResource INHERITED;
|
typedef GrGpuResource INHERITED;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // GrSurface_DEFINED
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
class GrResourceKey;
|
class GrResourceKey;
|
||||||
class GrTextureParams;
|
class GrTextureParams;
|
||||||
class GrTexturePriv;
|
class GrTextureImpl;
|
||||||
|
|
||||||
class GrTexture : public GrSurface {
|
class GrTexture : public GrSurface {
|
||||||
public:
|
public:
|
||||||
@ -43,6 +43,19 @@ public:
|
|||||||
virtual GrRenderTarget* asRenderTarget() SK_OVERRIDE { return fRenderTarget.get(); }
|
virtual GrRenderTarget* asRenderTarget() SK_OVERRIDE { return fRenderTarget.get(); }
|
||||||
virtual const GrRenderTarget* asRenderTarget() const SK_OVERRIDE { return fRenderTarget.get(); }
|
virtual const GrRenderTarget* asRenderTarget() const SK_OVERRIDE { return fRenderTarget.get(); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert from texels to normalized texture coords for POT textures only. Please don't add
|
||||||
|
* new callsites for these functions. They are slated for removal.
|
||||||
|
*/
|
||||||
|
SkFixed normalizeFixedX(SkFixed x) const {
|
||||||
|
SkASSERT(SkIsPow2(fDesc.fWidth));
|
||||||
|
return x >> fShiftFixedX;
|
||||||
|
}
|
||||||
|
SkFixed normalizeFixedY(SkFixed y) const {
|
||||||
|
SkASSERT(SkIsPow2(fDesc.fHeight));
|
||||||
|
return y >> fShiftFixedY;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the native ID or handle to the texture, depending on the
|
* Return the native ID or handle to the texture, depending on the
|
||||||
* platform. e.g. on OpenGL, return the texture ID.
|
* platform. e.g. on OpenGL, return the texture ID.
|
||||||
@ -54,9 +67,11 @@ public:
|
|||||||
* changed externally to Skia.
|
* changed externally to Skia.
|
||||||
*/
|
*/
|
||||||
virtual void textureParamsModified() = 0;
|
virtual void textureParamsModified() = 0;
|
||||||
|
SK_ATTR_DEPRECATED("Renamed to textureParamsModified.")
|
||||||
|
void invalidateCachedState() { this->textureParamsModified(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Informational texture flags. This will be removed soon.
|
* Informational texture flags. This will be moved to the private GrTextureImpl class soon.
|
||||||
*/
|
*/
|
||||||
enum FlagBits {
|
enum FlagBits {
|
||||||
kFirstBit = (kLastPublic_GrTextureFlagBit << 1),
|
kFirstBit = (kLastPublic_GrTextureFlagBit << 1),
|
||||||
@ -79,16 +94,21 @@ public:
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** Access methods that are only to be used within Skia code. */
|
GrTextureImpl* impl() { return reinterpret_cast<GrTextureImpl*>(this); }
|
||||||
inline GrTexturePriv texturePriv();
|
const GrTextureImpl* impl() const { return reinterpret_cast<const GrTextureImpl*>(this); }
|
||||||
inline const GrTexturePriv texturePriv() const;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// A texture refs its rt representation but not vice-versa. It is up to
|
// A texture refs its rt representation but not vice-versa. It is up to
|
||||||
// the subclass constructor to initialize this pointer.
|
// the subclass constructor to initialize this pointer.
|
||||||
SkAutoTUnref<GrRenderTarget> fRenderTarget;
|
SkAutoTUnref<GrRenderTarget> fRenderTarget;
|
||||||
|
|
||||||
GrTexture(GrGpu* gpu, bool isWrapped, const GrTextureDesc& desc);
|
GrTexture(GrGpu* gpu, bool isWrapped, const GrTextureDesc& desc)
|
||||||
|
: INHERITED(gpu, isWrapped, desc)
|
||||||
|
, fRenderTarget(NULL) {
|
||||||
|
// only make sense if alloc size is pow2
|
||||||
|
fShiftFixedX = 31 - SkCLZ(fDesc.fWidth);
|
||||||
|
fShiftFixedY = 31 - SkCLZ(fDesc.fHeight);
|
||||||
|
}
|
||||||
|
|
||||||
virtual ~GrTexture();
|
virtual ~GrTexture();
|
||||||
|
|
||||||
@ -101,8 +121,51 @@ protected:
|
|||||||
private:
|
private:
|
||||||
void abandonReleaseCommon();
|
void abandonReleaseCommon();
|
||||||
virtual void internal_dispose() const SK_OVERRIDE;
|
virtual void internal_dispose() const SK_OVERRIDE;
|
||||||
|
|
||||||
|
// these two shift a fixed-point value into normalized coordinates
|
||||||
|
// for this texture if the texture is power of two sized.
|
||||||
|
int fShiftFixedX;
|
||||||
|
int fShiftFixedY;
|
||||||
|
|
||||||
|
typedef GrSurface INHERITED;
|
||||||
|
};
|
||||||
|
|
||||||
|
class GrTextureImpl : public GrTexture {
|
||||||
|
public:
|
||||||
|
SK_DECLARE_INST_COUNT(GrTextureImpl)
|
||||||
|
|
||||||
|
void setFlag(GrTextureFlags flags) {
|
||||||
|
fDesc.fFlags = fDesc.fFlags | flags;
|
||||||
|
}
|
||||||
|
void resetFlag(GrTextureFlags flags) {
|
||||||
|
fDesc.fFlags = fDesc.fFlags & ~flags;
|
||||||
|
}
|
||||||
|
bool isSetFlag(GrTextureFlags flags) const {
|
||||||
|
return 0 != (fDesc.fFlags & flags);
|
||||||
|
}
|
||||||
|
|
||||||
void dirtyMipMaps(bool mipMapsDirty);
|
void dirtyMipMaps(bool mipMapsDirty);
|
||||||
|
|
||||||
|
bool mipMapsAreDirty() const {
|
||||||
|
return kValid_MipMapsStatus != fMipMapsStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool hasMipMaps() const {
|
||||||
|
return kNotAllocated_MipMapsStatus != fMipMapsStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
static GrResourceKey ComputeKey(const GrGpu* gpu,
|
||||||
|
const GrTextureParams* params,
|
||||||
|
const GrTextureDesc& desc,
|
||||||
|
const GrCacheID& cacheID);
|
||||||
|
static GrResourceKey ComputeScratchKey(const GrTextureDesc& desc);
|
||||||
|
static bool NeedsResizing(const GrResourceKey& key);
|
||||||
|
static bool NeedsBilerp(const GrResourceKey& key);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
GrTextureImpl(GrGpu* gpu, bool isWrapped, const GrTextureDesc& desc);
|
||||||
|
|
||||||
|
private:
|
||||||
enum MipMapsStatus {
|
enum MipMapsStatus {
|
||||||
kNotAllocated_MipMapsStatus,
|
kNotAllocated_MipMapsStatus,
|
||||||
kAllocated_MipMapsStatus,
|
kAllocated_MipMapsStatus,
|
||||||
@ -110,14 +173,8 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
MipMapsStatus fMipMapsStatus;
|
MipMapsStatus fMipMapsStatus;
|
||||||
// These two shift a fixed-point value into normalized coordinates
|
|
||||||
// for this texture if the texture is power of two sized.
|
|
||||||
int fShiftFixedX;
|
|
||||||
int fShiftFixedY;
|
|
||||||
|
|
||||||
friend class GrTexturePriv;
|
typedef GrTexture INHERITED;
|
||||||
|
|
||||||
typedef GrSurface INHERITED;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -11,21 +11,20 @@
|
|||||||
#include "GrFontScaler.h"
|
#include "GrFontScaler.h"
|
||||||
#include "GrIndexBuffer.h"
|
#include "GrIndexBuffer.h"
|
||||||
#include "GrStrokeInfo.h"
|
#include "GrStrokeInfo.h"
|
||||||
#include "GrTexturePriv.h"
|
|
||||||
#include "GrTextStrike.h"
|
#include "GrTextStrike.h"
|
||||||
#include "GrTextStrike_impl.h"
|
#include "GrTextStrike_impl.h"
|
||||||
|
#include "SkColorPriv.h"
|
||||||
|
#include "SkPath.h"
|
||||||
|
#include "SkRTConf.h"
|
||||||
|
#include "SkStrokeRec.h"
|
||||||
#include "effects/GrCustomCoordsTextureEffect.h"
|
#include "effects/GrCustomCoordsTextureEffect.h"
|
||||||
|
|
||||||
#include "SkAutoKern.h"
|
#include "SkAutoKern.h"
|
||||||
#include "SkColorPriv.h"
|
|
||||||
#include "SkDraw.h"
|
#include "SkDraw.h"
|
||||||
#include "SkDrawProcs.h"
|
#include "SkDrawProcs.h"
|
||||||
#include "SkGlyphCache.h"
|
#include "SkGlyphCache.h"
|
||||||
#include "SkGpuDevice.h"
|
#include "SkGpuDevice.h"
|
||||||
#include "SkGr.h"
|
#include "SkGr.h"
|
||||||
#include "SkPath.h"
|
|
||||||
#include "SkRTConf.h"
|
|
||||||
#include "SkStrokeRec.h"
|
|
||||||
#include "SkTextMapStateProc.h"
|
#include "SkTextMapStateProc.h"
|
||||||
|
|
||||||
SK_CONF_DECLARE(bool, c_DumpFontCache, "gpu.dumpFontCache", false,
|
SK_CONF_DECLARE(bool, c_DumpFontCache, "gpu.dumpFontCache", false,
|
||||||
@ -589,10 +588,10 @@ HAS_ATLAS:
|
|||||||
// The texture coords are last in both the with and without color vertex layouts.
|
// The texture coords are last in both the with and without color vertex layouts.
|
||||||
SkPoint* textureCoords = reinterpret_cast<SkPoint*>(
|
SkPoint* textureCoords = reinterpret_cast<SkPoint*>(
|
||||||
reinterpret_cast<intptr_t>(positions) + vertSize - sizeof(SkPoint));
|
reinterpret_cast<intptr_t>(positions) + vertSize - sizeof(SkPoint));
|
||||||
textureCoords->setRectFan(SkFixedToFloat(texture->texturePriv().normalizeFixedX(tx)),
|
textureCoords->setRectFan(SkFixedToFloat(texture->normalizeFixedX(tx)),
|
||||||
SkFixedToFloat(texture->texturePriv().normalizeFixedY(ty)),
|
SkFixedToFloat(texture->normalizeFixedY(ty)),
|
||||||
SkFixedToFloat(texture->texturePriv().normalizeFixedX(tx + width)),
|
SkFixedToFloat(texture->normalizeFixedX(tx + width)),
|
||||||
SkFixedToFloat(texture->texturePriv().normalizeFixedY(ty + height)),
|
SkFixedToFloat(texture->normalizeFixedY(ty + height)),
|
||||||
vertSize);
|
vertSize);
|
||||||
if (useColorVerts) {
|
if (useColorVerts) {
|
||||||
if (0xFF == GrColorUnpackA(fPaint.getColor())) {
|
if (0xFF == GrColorUnpackA(fPaint.getColor())) {
|
||||||
|
@ -30,9 +30,7 @@
|
|||||||
#include "GrStencilBuffer.h"
|
#include "GrStencilBuffer.h"
|
||||||
#include "GrStencilAndCoverTextContext.h"
|
#include "GrStencilAndCoverTextContext.h"
|
||||||
#include "GrStrokeInfo.h"
|
#include "GrStrokeInfo.h"
|
||||||
#include "GrSurfacePriv.h"
|
|
||||||
#include "GrTextStrike.h"
|
#include "GrTextStrike.h"
|
||||||
#include "GrTexturePriv.h"
|
|
||||||
#include "GrTraceMarker.h"
|
#include "GrTraceMarker.h"
|
||||||
#include "GrTracing.h"
|
#include "GrTracing.h"
|
||||||
#include "SkDashPathPriv.h"
|
#include "SkDashPathPriv.h"
|
||||||
@ -70,25 +68,6 @@ static const int DRAW_BUFFER_IBPOOL_PREALLOC_BUFFERS = 4;
|
|||||||
|
|
||||||
#define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == this)
|
#define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == this)
|
||||||
|
|
||||||
GrTexture* GrAutoScratchTexture::detach() {
|
|
||||||
if (NULL == fTexture) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
GrTexture* texture = fTexture;
|
|
||||||
fTexture = NULL;
|
|
||||||
|
|
||||||
// This GrAutoScratchTexture has a ref from lockAndRefScratchTexture, which we give up now.
|
|
||||||
// The cache also has a ref which we are lending to the caller of detach(). When the caller
|
|
||||||
// lets go of the ref and the ref count goes to 0 internal_dispose will see this flag is
|
|
||||||
// set and re-ref the texture, thereby restoring the cache's ref.
|
|
||||||
SkASSERT(!texture->unique());
|
|
||||||
texture->texturePriv().setFlag((GrTextureFlags) GrTexture::kReturnToCache_FlagBit);
|
|
||||||
texture->unref();
|
|
||||||
SkASSERT(texture->getCacheEntry());
|
|
||||||
|
|
||||||
return texture;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Glorified typedef to avoid including GrDrawState.h in GrContext.h
|
// Glorified typedef to avoid including GrDrawState.h in GrContext.h
|
||||||
class GrContext::AutoRestoreEffects : public GrDrawState::AutoRestoreEffects {};
|
class GrContext::AutoRestoreEffects : public GrDrawState::AutoRestoreEffects {};
|
||||||
|
|
||||||
@ -283,7 +262,7 @@ GrTextContext* GrContext::createTextContext(GrRenderTarget* renderTarget,
|
|||||||
GrTexture* GrContext::findAndRefTexture(const GrTextureDesc& desc,
|
GrTexture* GrContext::findAndRefTexture(const GrTextureDesc& desc,
|
||||||
const GrCacheID& cacheID,
|
const GrCacheID& cacheID,
|
||||||
const GrTextureParams* params) {
|
const GrTextureParams* params) {
|
||||||
GrResourceKey resourceKey = GrTexturePriv::ComputeKey(fGpu, params, desc, cacheID);
|
GrResourceKey resourceKey = GrTextureImpl::ComputeKey(fGpu, params, desc, cacheID);
|
||||||
GrGpuResource* resource = fResourceCache->find(resourceKey);
|
GrGpuResource* resource = fResourceCache->find(resourceKey);
|
||||||
SkSafeRef(resource);
|
SkSafeRef(resource);
|
||||||
return static_cast<GrTexture*>(resource);
|
return static_cast<GrTexture*>(resource);
|
||||||
@ -292,7 +271,7 @@ GrTexture* GrContext::findAndRefTexture(const GrTextureDesc& desc,
|
|||||||
bool GrContext::isTextureInCache(const GrTextureDesc& desc,
|
bool GrContext::isTextureInCache(const GrTextureDesc& desc,
|
||||||
const GrCacheID& cacheID,
|
const GrCacheID& cacheID,
|
||||||
const GrTextureParams* params) const {
|
const GrTextureParams* params) const {
|
||||||
GrResourceKey resourceKey = GrTexturePriv::ComputeKey(fGpu, params, desc, cacheID);
|
GrResourceKey resourceKey = GrTextureImpl::ComputeKey(fGpu, params, desc, cacheID);
|
||||||
return fResourceCache->hasKey(resourceKey);
|
return fResourceCache->hasKey(resourceKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -431,16 +410,16 @@ GrTexture* GrContext::createTexture(const GrTextureParams* params,
|
|||||||
const void* srcData,
|
const void* srcData,
|
||||||
size_t rowBytes,
|
size_t rowBytes,
|
||||||
GrResourceKey* cacheKey) {
|
GrResourceKey* cacheKey) {
|
||||||
GrResourceKey resourceKey = GrTexturePriv::ComputeKey(fGpu, params, desc, cacheID);
|
GrResourceKey resourceKey = GrTextureImpl::ComputeKey(fGpu, params, desc, cacheID);
|
||||||
|
|
||||||
GrTexture* texture;
|
GrTexture* texture;
|
||||||
if (GrTexturePriv::NeedsResizing(resourceKey)) {
|
if (GrTextureImpl::NeedsResizing(resourceKey)) {
|
||||||
// We do not know how to resize compressed textures.
|
// We do not know how to resize compressed textures.
|
||||||
SkASSERT(!GrPixelConfigIsCompressed(desc.fConfig));
|
SkASSERT(!GrPixelConfigIsCompressed(desc.fConfig));
|
||||||
|
|
||||||
texture = this->createResizedTexture(desc, cacheID,
|
texture = this->createResizedTexture(desc, cacheID,
|
||||||
srcData, rowBytes,
|
srcData, rowBytes,
|
||||||
GrTexturePriv::NeedsBilerp(resourceKey));
|
GrTextureImpl::NeedsBilerp(resourceKey));
|
||||||
} else {
|
} else {
|
||||||
texture = fGpu->createTexture(desc, srcData, rowBytes);
|
texture = fGpu->createTexture(desc, srcData, rowBytes);
|
||||||
}
|
}
|
||||||
@ -464,7 +443,7 @@ static GrTexture* create_scratch_texture(GrGpu* gpu,
|
|||||||
const GrTextureDesc& desc) {
|
const GrTextureDesc& desc) {
|
||||||
GrTexture* texture = gpu->createTexture(desc, NULL, 0);
|
GrTexture* texture = gpu->createTexture(desc, NULL, 0);
|
||||||
if (texture) {
|
if (texture) {
|
||||||
GrResourceKey key = GrTexturePriv::ComputeScratchKey(texture->desc());
|
GrResourceKey key = GrTextureImpl::ComputeScratchKey(texture->desc());
|
||||||
// Adding a resource could put us overbudget. Try to free up the
|
// Adding a resource could put us overbudget. Try to free up the
|
||||||
// necessary space before adding it.
|
// necessary space before adding it.
|
||||||
resourceCache->purgeAsNeeded(1, texture->gpuMemorySize());
|
resourceCache->purgeAsNeeded(1, texture->gpuMemorySize());
|
||||||
@ -504,7 +483,7 @@ GrTexture* GrContext::lockAndRefScratchTexture(const GrTextureDesc& inDesc, Scra
|
|||||||
int origHeight = desc.fHeight;
|
int origHeight = desc.fHeight;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
GrResourceKey key = GrTexturePriv::ComputeScratchKey(desc);
|
GrResourceKey key = GrTextureImpl::ComputeScratchKey(desc);
|
||||||
// Ensure we have exclusive access to the texture so future 'find' calls don't return it
|
// Ensure we have exclusive access to the texture so future 'find' calls don't return it
|
||||||
resource = fResourceCache->find(key, GrResourceCache::kHide_OwnershipFlag);
|
resource = fResourceCache->find(key, GrResourceCache::kHide_OwnershipFlag);
|
||||||
if (resource) {
|
if (resource) {
|
||||||
@ -599,7 +578,7 @@ void GrContext::unlockScratchTexture(GrTexture* texture) {
|
|||||||
// Instead, give up the cache's ref and leave the decision up to
|
// Instead, give up the cache's ref and leave the decision up to
|
||||||
// addExistingTextureToCache once its ref count reaches 0. For
|
// addExistingTextureToCache once its ref count reaches 0. For
|
||||||
// this to work we need to leave it in the exclusive list.
|
// this to work we need to leave it in the exclusive list.
|
||||||
texture->texturePriv().setFlag((GrTextureFlags) GrTexture::kReturnToCache_FlagBit);
|
texture->impl()->setFlag((GrTextureFlags) GrTextureImpl::kReturnToCache_FlagBit);
|
||||||
// Give up the cache's ref to the texture
|
// Give up the cache's ref to the texture
|
||||||
texture->unref();
|
texture->unref();
|
||||||
}
|
}
|
||||||
@ -1368,7 +1347,7 @@ bool GrContext::writeTexturePixels(GrTexture* texture,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(kDontFlush_PixelOpsFlag & flags) && texture->surfacePriv().hasPendingIO()) {
|
if (!(kDontFlush_PixelOpsFlag & flags) && texture->hasPendingIO()) {
|
||||||
this->flush();
|
this->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1439,7 +1418,7 @@ bool GrContext::readRenderTargetPixels(GrRenderTarget* target,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(kDontFlush_PixelOpsFlag & flags) && target->surfacePriv().hasPendingWrite()) {
|
if (!(kDontFlush_PixelOpsFlag & flags) && target->hasPendingWrite()) {
|
||||||
this->flush();
|
this->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,20 +7,18 @@
|
|||||||
|
|
||||||
#include "GrDistanceFieldTextContext.h"
|
#include "GrDistanceFieldTextContext.h"
|
||||||
#include "GrAtlas.h"
|
#include "GrAtlas.h"
|
||||||
|
#include "SkColorFilter.h"
|
||||||
#include "GrDrawTarget.h"
|
#include "GrDrawTarget.h"
|
||||||
#include "GrDrawTargetCaps.h"
|
#include "GrDrawTargetCaps.h"
|
||||||
#include "GrFontScaler.h"
|
#include "GrFontScaler.h"
|
||||||
|
#include "SkGlyphCache.h"
|
||||||
#include "GrGpu.h"
|
#include "GrGpu.h"
|
||||||
#include "GrIndexBuffer.h"
|
#include "GrIndexBuffer.h"
|
||||||
#include "GrStrokeInfo.h"
|
#include "GrStrokeInfo.h"
|
||||||
#include "GrTexturePriv.h"
|
|
||||||
#include "GrTextStrike.h"
|
#include "GrTextStrike.h"
|
||||||
#include "GrTextStrike_impl.h"
|
#include "GrTextStrike_impl.h"
|
||||||
|
|
||||||
#include "SkColorFilter.h"
|
|
||||||
#include "SkDistanceFieldGen.h"
|
#include "SkDistanceFieldGen.h"
|
||||||
#include "SkDraw.h"
|
#include "SkDraw.h"
|
||||||
#include "SkGlyphCache.h"
|
|
||||||
#include "SkGpuDevice.h"
|
#include "SkGpuDevice.h"
|
||||||
#include "SkPath.h"
|
#include "SkPath.h"
|
||||||
#include "SkRTConf.h"
|
#include "SkRTConf.h"
|
||||||
@ -425,10 +423,10 @@ HAS_ATLAS:
|
|||||||
// The texture coords are last in both the with and without color vertex layouts.
|
// The texture coords are last in both the with and without color vertex layouts.
|
||||||
SkPoint* textureCoords = reinterpret_cast<SkPoint*>(
|
SkPoint* textureCoords = reinterpret_cast<SkPoint*>(
|
||||||
reinterpret_cast<intptr_t>(positions) + vertSize - sizeof(SkPoint));
|
reinterpret_cast<intptr_t>(positions) + vertSize - sizeof(SkPoint));
|
||||||
textureCoords->setRectFan(SkFixedToFloat(texture->texturePriv().normalizeFixedX(tx)),
|
textureCoords->setRectFan(SkFixedToFloat(texture->normalizeFixedX(tx)),
|
||||||
SkFixedToFloat(texture->texturePriv().normalizeFixedY(ty)),
|
SkFixedToFloat(texture->normalizeFixedY(ty)),
|
||||||
SkFixedToFloat(texture->texturePriv().normalizeFixedX(tx + tw)),
|
SkFixedToFloat(texture->normalizeFixedX(tx + tw)),
|
||||||
SkFixedToFloat(texture->texturePriv().normalizeFixedY(ty + th)),
|
SkFixedToFloat(texture->normalizeFixedY(ty + th)),
|
||||||
vertSize);
|
vertSize);
|
||||||
if (useColorVerts) {
|
if (useColorVerts) {
|
||||||
if (0xFF == GrColorUnpackA(fPaint.getColor())) {
|
if (0xFF == GrColorUnpackA(fPaint.getColor())) {
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
#include "GrDrawTargetCaps.h"
|
#include "GrDrawTargetCaps.h"
|
||||||
#include "GrPath.h"
|
#include "GrPath.h"
|
||||||
#include "GrRenderTarget.h"
|
#include "GrRenderTarget.h"
|
||||||
#include "GrSurfacePriv.h"
|
|
||||||
#include "GrTemplates.h"
|
#include "GrTemplates.h"
|
||||||
#include "GrTexture.h"
|
#include "GrTexture.h"
|
||||||
#include "GrVertexBuffer.h"
|
#include "GrVertexBuffer.h"
|
||||||
@ -965,7 +964,7 @@ bool GrDrawTarget::onCanCopySurface(GrSurface* dst,
|
|||||||
SkASSERT(dstPoint.fX + srcRect.width() <= dst->width() &&
|
SkASSERT(dstPoint.fX + srcRect.width() <= dst->width() &&
|
||||||
dstPoint.fY + srcRect.height() <= dst->height());
|
dstPoint.fY + srcRect.height() <= dst->height());
|
||||||
|
|
||||||
return !dst->surfacePriv().isSameAs(src) && dst->asRenderTarget() && src->asTexture();
|
return !dst->isSameAs(src) && dst->asRenderTarget() && src->asTexture();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GrDrawTarget::onCopySurface(GrSurface* dst,
|
bool GrDrawTarget::onCopySurface(GrSurface* dst,
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "GrSurface.h"
|
#include "GrSurface.h"
|
||||||
#include "GrSurfacePriv.h"
|
|
||||||
|
|
||||||
#include "SkBitmap.h"
|
#include "SkBitmap.h"
|
||||||
#include "SkGr.h"
|
#include "SkGr.h"
|
||||||
@ -21,15 +20,13 @@ SkImageInfo GrSurface::info() const {
|
|||||||
return SkImageInfo::Make(this->width(), this->height(), colorType, kPremul_SkAlphaType);
|
return SkImageInfo::Make(this->width(), this->height(), colorType, kPremul_SkAlphaType);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: This should probably be a non-member helper function. It might only be needed in
|
|
||||||
// debug or developer builds.
|
|
||||||
bool GrSurface::savePixels(const char* filename) {
|
bool GrSurface::savePixels(const char* filename) {
|
||||||
SkBitmap bm;
|
SkBitmap bm;
|
||||||
if (!bm.tryAllocPixels(SkImageInfo::MakeN32Premul(this->width(), this->height()))) {
|
if (!bm.tryAllocPixels(SkImageInfo::MakeN32Premul(this->width(), this->height()))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool result = this->readPixels(0, 0, this->width(), this->height(), kSkia8888_GrPixelConfig,
|
bool result = readPixels(0, 0, this->width(), this->height(), kSkia8888_GrPixelConfig,
|
||||||
bm.getPixels());
|
bm.getPixels());
|
||||||
if (!result) {
|
if (!result) {
|
||||||
SkDebugf("------ failed to read pixels for %s\n", filename);
|
SkDebugf("------ failed to read pixels for %s\n", filename);
|
||||||
@ -83,14 +80,3 @@ bool GrSurface::hasPendingIO() const {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GrSurface::isSameAs(const GrSurface* other) const {
|
|
||||||
const GrRenderTarget* thisRT = this->asRenderTarget();
|
|
||||||
if (thisRT) {
|
|
||||||
return thisRT == other->asRenderTarget();
|
|
||||||
} else {
|
|
||||||
const GrTexture* thisTex = this->asTexture();
|
|
||||||
SkASSERT(thisTex); // We must be one or the other
|
|
||||||
return thisTex == other->asTexture();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,63 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014 Google Inc.
|
|
||||||
*
|
|
||||||
* Use of this source code is governed by a BSD-style license that can be
|
|
||||||
* found in the LICENSE file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef GrSurfacePriv_DEFINED
|
|
||||||
#define GrSurfacePriv_DEFINED
|
|
||||||
|
|
||||||
#include "GrSurface.h"
|
|
||||||
|
|
||||||
/** Class that adds methods to GrSurface that are only intended for use internal to Skia.
|
|
||||||
This class is purely a privileged window into GrSurface. It should never have additional data
|
|
||||||
members or virtual methods.
|
|
||||||
Non-static methods that are not trivial inlines should be spring-boarded (e.g. declared and
|
|
||||||
implemented privately in GrSurface with a inline public method here). */
|
|
||||||
class GrSurfacePriv {
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* Derive a SkImageInfo from the surface's descriptor. This is lossy as ImageInfo has fields not
|
|
||||||
* known to GrSurface (e.g. alphaType).
|
|
||||||
*/
|
|
||||||
SkImageInfo info() const { return fSurface->info(); }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks whether this GrSurface refers to the same GPU object as other. This
|
|
||||||
* catches the case where a GrTexture and GrRenderTarget refer to the same
|
|
||||||
* GPU memory.
|
|
||||||
*/
|
|
||||||
bool isSameAs(const GrSurface* other) const { return fSurface->isSameAs(other); }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Write the contents of the surface to a PNG. Returns true if successful.
|
|
||||||
* @param filename Full path to desired file
|
|
||||||
*/
|
|
||||||
bool savePixels(const char* filename) { return fSurface->savePixels(filename); }
|
|
||||||
|
|
||||||
bool hasPendingRead() const { return fSurface->hasPendingRead(); }
|
|
||||||
bool hasPendingWrite() const { return fSurface->hasPendingWrite(); }
|
|
||||||
bool hasPendingIO() const { return fSurface->hasPendingIO(); }
|
|
||||||
|
|
||||||
private:
|
|
||||||
GrSurfacePriv(GrSurface* surface) : fSurface(surface) { }
|
|
||||||
GrSurfacePriv(const GrSurfacePriv& that) : fSurface(that.fSurface) { }
|
|
||||||
GrSurfacePriv& operator=(const GrSurface&); // unimpl
|
|
||||||
|
|
||||||
// No taking addresses of this type.
|
|
||||||
const GrSurfacePriv* operator&() const;
|
|
||||||
GrSurfacePriv* operator&();
|
|
||||||
|
|
||||||
GrSurface* fSurface;
|
|
||||||
|
|
||||||
friend class GrSurface; // to construct/copy this type.
|
|
||||||
};
|
|
||||||
|
|
||||||
inline GrSurfacePriv GrSurface::surfacePriv() { return GrSurfacePriv(this); }
|
|
||||||
|
|
||||||
inline const GrSurfacePriv GrSurface::surfacePriv() const {
|
|
||||||
return GrSurfacePriv(const_cast<GrSurface*>(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
#include "GrGpu.h"
|
#include "GrGpu.h"
|
||||||
#include "GrRectanizer.h"
|
#include "GrRectanizer.h"
|
||||||
#include "GrSurfacePriv.h"
|
|
||||||
#include "GrTextStrike.h"
|
#include "GrTextStrike.h"
|
||||||
#include "GrTextStrike_impl.h"
|
#include "GrTextStrike_impl.h"
|
||||||
#include "SkString.h"
|
#include "SkString.h"
|
||||||
@ -207,7 +206,7 @@ void GrFontCache::dump() const {
|
|||||||
#else
|
#else
|
||||||
filename.printf("fontcache_%d%d.png", gDumpCount, i);
|
filename.printf("fontcache_%d%d.png", gDumpCount, i);
|
||||||
#endif
|
#endif
|
||||||
texture->surfacePriv().savePixels(filename.c_str());
|
texture->savePixels(filename.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,13 +7,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "GrTexture.h"
|
||||||
|
|
||||||
#include "GrContext.h"
|
#include "GrContext.h"
|
||||||
#include "GrDrawTargetCaps.h"
|
#include "GrDrawTargetCaps.h"
|
||||||
#include "GrGpu.h"
|
#include "GrGpu.h"
|
||||||
#include "GrRenderTarget.h"
|
#include "GrRenderTarget.h"
|
||||||
#include "GrResourceCache.h"
|
#include "GrResourceCache.h"
|
||||||
#include "GrTexture.h"
|
|
||||||
#include "GrTexturePriv.h"
|
|
||||||
|
|
||||||
GrTexture::~GrTexture() {
|
GrTexture::~GrTexture() {
|
||||||
if (fRenderTarget.get()) {
|
if (fRenderTarget.get()) {
|
||||||
@ -26,12 +26,12 @@ GrTexture::~GrTexture() {
|
|||||||
* textures back in the texture cache when their ref count goes to zero.
|
* textures back in the texture cache when their ref count goes to zero.
|
||||||
*/
|
*/
|
||||||
void GrTexture::internal_dispose() const {
|
void GrTexture::internal_dispose() const {
|
||||||
if (this->texturePriv().isSetFlag((GrTextureFlags) GrTexture::kReturnToCache_FlagBit) &&
|
if (this->impl()->isSetFlag((GrTextureFlags) GrTextureImpl::kReturnToCache_FlagBit) &&
|
||||||
this->INHERITED::getContext()) {
|
this->INHERITED::getContext()) {
|
||||||
GrTexture* nonConstThis = const_cast<GrTexture *>(this);
|
GrTexture* nonConstThis = const_cast<GrTexture *>(this);
|
||||||
this->ref(); // restore ref count to initial setting
|
this->ref(); // restore ref count to initial setting
|
||||||
|
|
||||||
nonConstThis->texturePriv().resetFlag((GrTextureFlags) kReturnToCache_FlagBit);
|
nonConstThis->impl()->resetFlag((GrTextureFlags) GrTextureImpl::kReturnToCache_FlagBit);
|
||||||
nonConstThis->INHERITED::getContext()->addExistingTextureToCache(nonConstThis);
|
nonConstThis->INHERITED::getContext()->addExistingTextureToCache(nonConstThis);
|
||||||
|
|
||||||
// Note: "this" texture might be freed inside addExistingTextureToCache
|
// Note: "this" texture might be freed inside addExistingTextureToCache
|
||||||
@ -42,7 +42,7 @@ void GrTexture::internal_dispose() const {
|
|||||||
this->INHERITED::internal_dispose();
|
this->INHERITED::internal_dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GrTexture::dirtyMipMaps(bool mipMapsDirty) {
|
void GrTextureImpl::dirtyMipMaps(bool mipMapsDirty) {
|
||||||
if (mipMapsDirty) {
|
if (mipMapsDirty) {
|
||||||
if (kValid_MipMapsStatus == fMipMapsStatus) {
|
if (kValid_MipMapsStatus == fMipMapsStatus) {
|
||||||
fMipMapsStatus = kAllocated_MipMapsStatus;
|
fMipMapsStatus = kAllocated_MipMapsStatus;
|
||||||
@ -66,7 +66,7 @@ size_t GrTexture::gpuMemorySize() const {
|
|||||||
textureSize = (size_t) fDesc.fWidth * fDesc.fHeight * GrBytesPerPixel(fDesc.fConfig);
|
textureSize = (size_t) fDesc.fWidth * fDesc.fHeight * GrBytesPerPixel(fDesc.fConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->texturePriv().hasMipMaps()) {
|
if (this->impl()->hasMipMaps()) {
|
||||||
// We don't have to worry about the mipmaps being a different size than
|
// We don't have to worry about the mipmaps being a different size than
|
||||||
// we'd expect because we never change fDesc.fWidth/fHeight.
|
// we'd expect because we never change fDesc.fWidth/fHeight.
|
||||||
textureSize *= 2;
|
textureSize *= 2;
|
||||||
@ -107,17 +107,17 @@ void GrTexture::abandonReleaseCommon() {
|
|||||||
// After abandon() or release() the resource cache will be unreachable (getContext() == NULL).
|
// After abandon() or release() the resource cache will be unreachable (getContext() == NULL).
|
||||||
// So we readd the texture to the cache here so that it is removed from the exclusive list and
|
// So we readd the texture to the cache here so that it is removed from the exclusive list and
|
||||||
// there is no longer an unref'ed ptr to the texture in the cache.
|
// there is no longer an unref'ed ptr to the texture in the cache.
|
||||||
if (this->texturePriv().isSetFlag((GrTextureFlags)kReturnToCache_FlagBit)) {
|
if (this->impl()->isSetFlag((GrTextureFlags)GrTextureImpl::kReturnToCache_FlagBit)) {
|
||||||
SkASSERT(!this->wasDestroyed());
|
SkASSERT(!this->wasDestroyed());
|
||||||
this->ref(); // restores the ref the resource cache gave up when it marked this exclusive.
|
this->ref(); // restores the ref the resource cache gave up when it marked this exclusive.
|
||||||
this->texturePriv().resetFlag((GrTextureFlags) kReturnToCache_FlagBit);
|
this->impl()->resetFlag((GrTextureFlags) GrTextureImpl::kReturnToCache_FlagBit);
|
||||||
this->getContext()->addExistingTextureToCache(this);
|
this->getContext()->addExistingTextureToCache(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GrTexture::onRelease() {
|
void GrTexture::onRelease() {
|
||||||
this->abandonReleaseCommon();
|
this->abandonReleaseCommon();
|
||||||
SkASSERT(!this->texturePriv().isSetFlag((GrTextureFlags) kReturnToCache_FlagBit));
|
SkASSERT(!this->impl()->isSetFlag((GrTextureFlags) GrTextureImpl::kReturnToCache_FlagBit));
|
||||||
INHERITED::onRelease();
|
INHERITED::onRelease();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,17 +207,13 @@ GrSurfaceOrigin resolve_origin(const GrTextureDesc& desc) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
GrTexture::GrTexture(GrGpu* gpu, bool isWrapped, const GrTextureDesc& desc)
|
GrTextureImpl::GrTextureImpl(GrGpu* gpu, bool isWrapped, const GrTextureDesc& desc)
|
||||||
: INHERITED(gpu, isWrapped, desc)
|
: INHERITED(gpu, isWrapped, desc)
|
||||||
, fRenderTarget(NULL)
|
|
||||||
, fMipMapsStatus(kNotAllocated_MipMapsStatus) {
|
, fMipMapsStatus(kNotAllocated_MipMapsStatus) {
|
||||||
this->setScratchKey(GrTexturePriv::ComputeScratchKey(desc));
|
this->setScratchKey(ComputeScratchKey(desc));
|
||||||
// only make sense if alloc size is pow2
|
|
||||||
fShiftFixedX = 31 - SkCLZ(fDesc.fWidth);
|
|
||||||
fShiftFixedY = 31 - SkCLZ(fDesc.fHeight);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GrResourceKey GrTexturePriv::ComputeKey(const GrGpu* gpu,
|
GrResourceKey GrTextureImpl::ComputeKey(const GrGpu* gpu,
|
||||||
const GrTextureParams* params,
|
const GrTextureParams* params,
|
||||||
const GrTextureDesc& desc,
|
const GrTextureDesc& desc,
|
||||||
const GrCacheID& cacheID) {
|
const GrCacheID& cacheID) {
|
||||||
@ -225,7 +221,7 @@ GrResourceKey GrTexturePriv::ComputeKey(const GrGpu* gpu,
|
|||||||
return GrResourceKey(cacheID, texture_resource_type(), flags);
|
return GrResourceKey(cacheID, texture_resource_type(), flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
GrResourceKey GrTexturePriv::ComputeScratchKey(const GrTextureDesc& desc) {
|
GrResourceKey GrTextureImpl::ComputeScratchKey(const GrTextureDesc& desc) {
|
||||||
GrCacheID::Key idKey;
|
GrCacheID::Key idKey;
|
||||||
// Instead of a client-provided key of the texture contents we create a key from the
|
// Instead of a client-provided key of the texture contents we create a key from the
|
||||||
// descriptor.
|
// descriptor.
|
||||||
@ -244,10 +240,10 @@ GrResourceKey GrTexturePriv::ComputeScratchKey(const GrTextureDesc& desc) {
|
|||||||
return GrResourceKey(cacheID, texture_resource_type(), 0);
|
return GrResourceKey(cacheID, texture_resource_type(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GrTexturePriv::NeedsResizing(const GrResourceKey& key) {
|
bool GrTextureImpl::NeedsResizing(const GrResourceKey& key) {
|
||||||
return SkToBool(key.getResourceFlags() & kStretchToPOT_TextureFlag);
|
return SkToBool(key.getResourceFlags() & kStretchToPOT_TextureFlag);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GrTexturePriv::NeedsBilerp(const GrResourceKey& key) {
|
bool GrTextureImpl::NeedsBilerp(const GrResourceKey& key) {
|
||||||
return SkToBool(key.getResourceFlags() & kBilerp_TextureFlag);
|
return SkToBool(key.getResourceFlags() & kBilerp_TextureFlag);
|
||||||
}
|
}
|
||||||
|
@ -1,82 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014 Google Inc.
|
|
||||||
*
|
|
||||||
* Use of this source code is governed by a BSD-style license that can be
|
|
||||||
* found in the LICENSE file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef GrTexturePriv_DEFINED
|
|
||||||
#define GrTexturePriv_DEFINED
|
|
||||||
|
|
||||||
#include "GrTexture.h"
|
|
||||||
|
|
||||||
/** Class that adds methods to GrTexture that are only intended for use internal to Skia.
|
|
||||||
This class is purely a privileged window into GrTexture. It should never have additional data
|
|
||||||
members or virtual methods.
|
|
||||||
Non-static methods that are not trivial inlines should be spring-boarded (e.g. declared and
|
|
||||||
implemented privately in GrTexture with a inline public method here). */
|
|
||||||
class GrTexturePriv {
|
|
||||||
public:
|
|
||||||
void setFlag(GrTextureFlags flags) {
|
|
||||||
fTexture->fDesc.fFlags = fTexture->fDesc.fFlags | flags;
|
|
||||||
}
|
|
||||||
|
|
||||||
void resetFlag(GrTextureFlags flags) {
|
|
||||||
fTexture->fDesc.fFlags = fTexture->fDesc.fFlags & ~flags;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isSetFlag(GrTextureFlags flags) const {
|
|
||||||
return 0 != (fTexture->fDesc.fFlags & flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
void dirtyMipMaps(bool mipMapsDirty) { fTexture->dirtyMipMaps(mipMapsDirty); }
|
|
||||||
|
|
||||||
bool mipMapsAreDirty() const {
|
|
||||||
return GrTexture::kValid_MipMapsStatus != fTexture->fMipMapsStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool hasMipMaps() const {
|
|
||||||
return GrTexture::kNotAllocated_MipMapsStatus != fTexture->fMipMapsStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GrResourceKey ComputeKey(const GrGpu* gpu,
|
|
||||||
const GrTextureParams* params,
|
|
||||||
const GrTextureDesc& desc,
|
|
||||||
const GrCacheID& cacheID);
|
|
||||||
static GrResourceKey ComputeScratchKey(const GrTextureDesc& desc);
|
|
||||||
static bool NeedsResizing(const GrResourceKey& key);
|
|
||||||
static bool NeedsBilerp(const GrResourceKey& key);
|
|
||||||
|
|
||||||
|
|
||||||
// TODO: Move this logic and the shift values out of here and to the callers.
|
|
||||||
SkFixed normalizeFixedX(SkFixed x) const {
|
|
||||||
SkASSERT(SkIsPow2(fTexture->fDesc.fWidth));
|
|
||||||
return x >> fTexture->fShiftFixedX;
|
|
||||||
}
|
|
||||||
|
|
||||||
SkFixed normalizeFixedY(SkFixed y) const {
|
|
||||||
SkASSERT(SkIsPow2(fTexture->fDesc.fHeight));
|
|
||||||
return y >> fTexture->fShiftFixedY;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
GrTexturePriv(GrTexture* texture) : fTexture(texture) { }
|
|
||||||
GrTexturePriv(const GrTexturePriv& that) : fTexture(that.fTexture) { }
|
|
||||||
GrTexturePriv& operator=(const GrTexturePriv&); // unimpl
|
|
||||||
|
|
||||||
// No taking addresses of this type.
|
|
||||||
const GrTexturePriv* operator&() const;
|
|
||||||
GrTexturePriv* operator&();
|
|
||||||
|
|
||||||
GrTexture* fTexture;
|
|
||||||
|
|
||||||
friend class GrTexture; // to construct/copy this type.
|
|
||||||
};
|
|
||||||
|
|
||||||
inline GrTexturePriv GrTexture::texturePriv() { return GrTexturePriv(this); }
|
|
||||||
|
|
||||||
inline const GrTexturePriv GrTexture::texturePriv () const {
|
|
||||||
return GrTexturePriv(const_cast<GrTexture*>(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
@ -151,10 +151,9 @@ SkGpuDevice::SkGpuDevice(GrSurface* surface, const SkSurfaceProps& props, unsign
|
|||||||
|
|
||||||
fRenderTarget = SkRef(surface->asRenderTarget());
|
fRenderTarget = SkRef(surface->asRenderTarget());
|
||||||
|
|
||||||
SkImageInfo info = surface->surfacePriv().info();
|
|
||||||
SkPixelRef* pr = SkNEW_ARGS(SkGrPixelRef,
|
SkPixelRef* pr = SkNEW_ARGS(SkGrPixelRef,
|
||||||
(info, surface, SkToBool(flags & kCached_Flag)));
|
(surface->info(), surface, SkToBool(flags & kCached_Flag)));
|
||||||
fLegacyBitmap.setInfo(info);
|
fLegacyBitmap.setInfo(surface->info());
|
||||||
fLegacyBitmap.setPixelRef(pr)->unref();
|
fLegacyBitmap.setPixelRef(pr)->unref();
|
||||||
|
|
||||||
this->setPixelGeometry(props.pixelGeometry());
|
this->setPixelGeometry(props.pixelGeometry());
|
||||||
@ -692,7 +691,7 @@ bool create_mask_GPU(GrContext* context,
|
|||||||
|
|
||||||
SkBitmap wrap_texture(GrTexture* texture) {
|
SkBitmap wrap_texture(GrTexture* texture) {
|
||||||
SkBitmap result;
|
SkBitmap result;
|
||||||
result.setInfo(texture->surfacePriv().info());
|
result.setInfo(texture->info());
|
||||||
result.setPixelRef(SkNEW_ARGS(SkGrPixelRef, (result.info(), texture)))->unref();
|
result.setPixelRef(SkNEW_ARGS(SkGrPixelRef, (result.info(), texture)))->unref();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
#include "SkPicture.h"
|
#include "SkPicture.h"
|
||||||
#include "SkRegion.h"
|
#include "SkRegion.h"
|
||||||
#include "GrContext.h"
|
#include "GrContext.h"
|
||||||
#include "GrSurfacePriv.h"
|
|
||||||
|
|
||||||
struct SkDrawProcs;
|
struct SkDrawProcs;
|
||||||
struct GrSkDrawProcs;
|
struct GrSkDrawProcs;
|
||||||
@ -62,7 +61,7 @@ public:
|
|||||||
virtual GrRenderTarget* accessRenderTarget() SK_OVERRIDE;
|
virtual GrRenderTarget* accessRenderTarget() SK_OVERRIDE;
|
||||||
|
|
||||||
virtual SkImageInfo imageInfo() const SK_OVERRIDE {
|
virtual SkImageInfo imageInfo() const SK_OVERRIDE {
|
||||||
return fRenderTarget ? fRenderTarget->surfacePriv().info() : SkImageInfo::MakeUnknown();
|
return fRenderTarget ? fRenderTarget->info() : SkImageInfo::MakeUnknown();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void clear(SkColor color) SK_OVERRIDE;
|
virtual void clear(SkColor color) SK_OVERRIDE;
|
||||||
|
@ -45,7 +45,7 @@ private:
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
class GrGLTexture : public GrTexture {
|
class GrGLTexture : public GrTextureImpl {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
struct TexParams {
|
struct TexParams {
|
||||||
@ -105,7 +105,7 @@ private:
|
|||||||
const Desc& textureDesc,
|
const Desc& textureDesc,
|
||||||
const GrGLRenderTarget::Desc* rtDesc);
|
const GrGLRenderTarget::Desc* rtDesc);
|
||||||
|
|
||||||
typedef GrTexture INHERITED;
|
typedef GrTextureImpl INHERITED;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -9,9 +9,7 @@
|
|||||||
#include "GrGpuGL.h"
|
#include "GrGpuGL.h"
|
||||||
#include "GrGLStencilBuffer.h"
|
#include "GrGLStencilBuffer.h"
|
||||||
#include "GrOptDrawState.h"
|
#include "GrOptDrawState.h"
|
||||||
#include "GrSurfacePriv.h"
|
|
||||||
#include "GrTemplates.h"
|
#include "GrTemplates.h"
|
||||||
#include "GrTexturePriv.h"
|
|
||||||
#include "GrTypes.h"
|
#include "GrTypes.h"
|
||||||
#include "SkStrokeRec.h"
|
#include "SkStrokeRec.h"
|
||||||
#include "SkTemplates.h"
|
#include "SkTemplates.h"
|
||||||
@ -495,7 +493,7 @@ bool GrGpuGL::onWriteTexturePixels(GrTexture* texture,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
texture->texturePriv().dirtyMipMaps(true);
|
texture->impl()->dirtyMipMaps(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1733,7 +1731,7 @@ void GrGpuGL::flushRenderTarget(GrGLRenderTarget* target, const SkIRect* bound)
|
|||||||
|
|
||||||
GrTexture *texture = target->asTexture();
|
GrTexture *texture = target->asTexture();
|
||||||
if (texture) {
|
if (texture) {
|
||||||
texture->texturePriv().dirtyMipMaps(true);
|
texture->impl()->dirtyMipMaps(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2055,9 +2053,9 @@ void GrGpuGL::bindTexture(int unitIdx, const GrTextureParams& params, GrGLTextur
|
|||||||
newTexParams.fMagFilter = glMagFilterModes[filterMode];
|
newTexParams.fMagFilter = glMagFilterModes[filterMode];
|
||||||
|
|
||||||
if (GrTextureParams::kMipMap_FilterMode == filterMode &&
|
if (GrTextureParams::kMipMap_FilterMode == filterMode &&
|
||||||
texture->texturePriv().mipMapsAreDirty() && !GrPixelConfigIsCompressed(texture->config())) {
|
texture->mipMapsAreDirty() && !GrPixelConfigIsCompressed(texture->config())) {
|
||||||
GL_CALL(GenerateMipmap(GR_GL_TEXTURE_2D));
|
GL_CALL(GenerateMipmap(GR_GL_TEXTURE_2D));
|
||||||
texture->texturePriv().dirtyMipMaps(false);
|
texture->dirtyMipMaps(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
newTexParams.fWrapS = tile_to_gl_wrap(params.getTileModeX());
|
newTexParams.fWrapS = tile_to_gl_wrap(params.getTileModeX());
|
||||||
@ -2471,7 +2469,7 @@ bool GrGpuGL::onCopySurface(GrSurface* dst,
|
|||||||
SkIRect dstRect = SkIRect::MakeXYWH(dstPoint.fX, dstPoint.fY,
|
SkIRect dstRect = SkIRect::MakeXYWH(dstPoint.fX, dstPoint.fY,
|
||||||
srcRect.width(), srcRect.height());
|
srcRect.width(), srcRect.height());
|
||||||
bool selfOverlap = false;
|
bool selfOverlap = false;
|
||||||
if (dst->surfacePriv().isSameAs(src)) {
|
if (dst->isSameAs(src)) {
|
||||||
selfOverlap = SkIRect::IntersectsNoEmptyCheck(dstRect, srcRect);
|
selfOverlap = SkIRect::IntersectsNoEmptyCheck(dstRect, srcRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2549,7 +2547,7 @@ bool GrGpuGL::onCanCopySurface(GrSurface* dst,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (can_blit_framebuffer(dst, src, this)) {
|
if (can_blit_framebuffer(dst, src, this)) {
|
||||||
if (dst->surfacePriv().isSameAs(src)) {
|
if (dst->isSameAs(src)) {
|
||||||
SkIRect dstRect = SkIRect::MakeXYWH(dstPoint.fX, dstPoint.fY,
|
SkIRect dstRect = SkIRect::MakeXYWH(dstPoint.fX, dstPoint.fY,
|
||||||
srcRect.width(), srcRect.height());
|
srcRect.width(), srcRect.height());
|
||||||
if(!SkIRect::IntersectsNoEmptyCheck(dstRect, srcRect)) {
|
if(!SkIRect::IntersectsNoEmptyCheck(dstRect, srcRect)) {
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
#include "GrContextFactory.h"
|
#include "GrContextFactory.h"
|
||||||
#include "GrRenderTarget.h"
|
#include "GrRenderTarget.h"
|
||||||
#include "GrTexture.h"
|
#include "GrTexture.h"
|
||||||
#include "GrSurfacePriv.h"
|
|
||||||
#include "SkTypes.h"
|
#include "SkTypes.h"
|
||||||
#include "Test.h"
|
#include "Test.h"
|
||||||
|
|
||||||
@ -29,14 +28,14 @@ DEF_GPUTEST(GrSurface, reporter, factory) {
|
|||||||
desc.fFlags = kNone_GrTextureFlags;
|
desc.fFlags = kNone_GrTextureFlags;
|
||||||
GrSurface* tex1 = context->createUncachedTexture(desc, NULL, 0);
|
GrSurface* tex1 = context->createUncachedTexture(desc, NULL, 0);
|
||||||
|
|
||||||
REPORTER_ASSERT(reporter, texRT1->surfacePriv().isSameAs(texRT1));
|
REPORTER_ASSERT(reporter, texRT1->isSameAs(texRT1));
|
||||||
REPORTER_ASSERT(reporter, texRT1->surfacePriv().isSameAs(texRT1->asRenderTarget()));
|
REPORTER_ASSERT(reporter, texRT1->isSameAs(texRT1->asRenderTarget()));
|
||||||
REPORTER_ASSERT(reporter, texRT1->asRenderTarget()->surfacePriv().isSameAs(texRT1));
|
REPORTER_ASSERT(reporter, texRT1->asRenderTarget()->isSameAs(texRT1));
|
||||||
REPORTER_ASSERT(reporter, !texRT2->surfacePriv().isSameAs(texRT1));
|
REPORTER_ASSERT(reporter, !texRT2->isSameAs(texRT1));
|
||||||
REPORTER_ASSERT(reporter, !texRT2->asRenderTarget()->surfacePriv().isSameAs(texRT1));
|
REPORTER_ASSERT(reporter, !texRT2->asRenderTarget()->isSameAs(texRT1));
|
||||||
REPORTER_ASSERT(reporter, !texRT2->surfacePriv().isSameAs(texRT1->asRenderTarget()));
|
REPORTER_ASSERT(reporter, !texRT2->isSameAs(texRT1->asRenderTarget()));
|
||||||
REPORTER_ASSERT(reporter, !texRT2->surfacePriv().isSameAs(tex1));
|
REPORTER_ASSERT(reporter, !texRT2->isSameAs(tex1));
|
||||||
REPORTER_ASSERT(reporter, !texRT2->asRenderTarget()->surfacePriv().isSameAs(tex1));
|
REPORTER_ASSERT(reporter, !texRT2->asRenderTarget()->isSameAs(tex1));
|
||||||
|
|
||||||
GrBackendTextureDesc backendDesc;
|
GrBackendTextureDesc backendDesc;
|
||||||
backendDesc.fConfig = kSkia8888_GrPixelConfig;
|
backendDesc.fConfig = kSkia8888_GrPixelConfig;
|
||||||
@ -46,13 +45,11 @@ DEF_GPUTEST(GrSurface, reporter, factory) {
|
|||||||
backendDesc.fSampleCnt = 0;
|
backendDesc.fSampleCnt = 0;
|
||||||
backendDesc.fTextureHandle = 5;
|
backendDesc.fTextureHandle = 5;
|
||||||
GrSurface* externalTexRT = context->wrapBackendTexture(backendDesc);
|
GrSurface* externalTexRT = context->wrapBackendTexture(backendDesc);
|
||||||
REPORTER_ASSERT(reporter, externalTexRT->surfacePriv().isSameAs(externalTexRT));
|
REPORTER_ASSERT(reporter, externalTexRT->isSameAs(externalTexRT));
|
||||||
REPORTER_ASSERT(reporter,
|
REPORTER_ASSERT(reporter, externalTexRT->isSameAs(externalTexRT->asRenderTarget()));
|
||||||
externalTexRT->surfacePriv().isSameAs(externalTexRT->asRenderTarget()));
|
REPORTER_ASSERT(reporter, externalTexRT->asRenderTarget()->isSameAs(externalTexRT));
|
||||||
REPORTER_ASSERT(reporter,
|
REPORTER_ASSERT(reporter, !externalTexRT->isSameAs(texRT1));
|
||||||
externalTexRT->asRenderTarget()->surfacePriv().isSameAs(externalTexRT));
|
REPORTER_ASSERT(reporter, !externalTexRT->asRenderTarget()->isSameAs(texRT1));
|
||||||
REPORTER_ASSERT(reporter, !externalTexRT->surfacePriv().isSameAs(texRT1));
|
|
||||||
REPORTER_ASSERT(reporter, !externalTexRT->asRenderTarget()->surfacePriv().isSameAs(texRT1));
|
|
||||||
|
|
||||||
texRT1->unref();
|
texRT1->unref();
|
||||||
texRT2->unref();
|
texRT2->unref();
|
||||||
|
Loading…
Reference in New Issue
Block a user