aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2014-09-30 06:58:20 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-09-30 06:58:20 -0700
commitb06e5a2f558133b865cb0c3cc0b36e9bd2e594e2 (patch)
tree52a68d8103a78776d05f5c933b4f715dd7828633 /src
parentdbe6074a06efc5fb6883bb5e4f251ed67c8c0ab4 (diff)
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
Diffstat (limited to 'src')
-rwxr-xr-xsrc/gpu/GrBitmapTextContext.cpp17
-rwxr-xr-xsrc/gpu/GrContext.cpp41
-rwxr-xr-xsrc/gpu/GrDistanceFieldTextContext.cpp14
-rw-r--r--src/gpu/GrDrawTarget.cpp3
-rw-r--r--src/gpu/GrSurface.cpp18
-rw-r--r--src/gpu/GrSurfacePriv.h63
-rw-r--r--src/gpu/GrTextStrike.cpp3
-rw-r--r--src/gpu/GrTexture.cpp36
-rw-r--r--src/gpu/GrTexturePriv.h82
-rw-r--r--src/gpu/SkGpuDevice.cpp7
-rw-r--r--src/gpu/SkGpuDevice.h3
-rw-r--r--src/gpu/gl/GrGLTexture.h4
-rw-r--r--src/gpu/gl/GrGpuGL.cpp14
13 files changed, 56 insertions, 249 deletions
diff --git a/src/gpu/GrBitmapTextContext.cpp b/src/gpu/GrBitmapTextContext.cpp
index 422a7e0179..0f6d1b62a9 100755
--- a/src/gpu/GrBitmapTextContext.cpp
+++ b/src/gpu/GrBitmapTextContext.cpp
@@ -11,21 +11,20 @@
#include "GrFontScaler.h"
#include "GrIndexBuffer.h"
#include "GrStrokeInfo.h"
-#include "GrTexturePriv.h"
#include "GrTextStrike.h"
#include "GrTextStrike_impl.h"
+#include "SkColorPriv.h"
+#include "SkPath.h"
+#include "SkRTConf.h"
+#include "SkStrokeRec.h"
#include "effects/GrCustomCoordsTextureEffect.h"
#include "SkAutoKern.h"
-#include "SkColorPriv.h"
#include "SkDraw.h"
#include "SkDrawProcs.h"
#include "SkGlyphCache.h"
#include "SkGpuDevice.h"
#include "SkGr.h"
-#include "SkPath.h"
-#include "SkRTConf.h"
-#include "SkStrokeRec.h"
#include "SkTextMapStateProc.h"
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.
SkPoint* textureCoords = reinterpret_cast<SkPoint*>(
reinterpret_cast<intptr_t>(positions) + vertSize - sizeof(SkPoint));
- textureCoords->setRectFan(SkFixedToFloat(texture->texturePriv().normalizeFixedX(tx)),
- SkFixedToFloat(texture->texturePriv().normalizeFixedY(ty)),
- SkFixedToFloat(texture->texturePriv().normalizeFixedX(tx + width)),
- SkFixedToFloat(texture->texturePriv().normalizeFixedY(ty + height)),
+ textureCoords->setRectFan(SkFixedToFloat(texture->normalizeFixedX(tx)),
+ SkFixedToFloat(texture->normalizeFixedY(ty)),
+ SkFixedToFloat(texture->normalizeFixedX(tx + width)),
+ SkFixedToFloat(texture->normalizeFixedY(ty + height)),
vertSize);
if (useColorVerts) {
if (0xFF == GrColorUnpackA(fPaint.getColor())) {
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 46a5576b11..d55aed92f5 100755
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -30,9 +30,7 @@
#include "GrStencilBuffer.h"
#include "GrStencilAndCoverTextContext.h"
#include "GrStrokeInfo.h"
-#include "GrSurfacePriv.h"
#include "GrTextStrike.h"
-#include "GrTexturePriv.h"
#include "GrTraceMarker.h"
#include "GrTracing.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)
-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
class GrContext::AutoRestoreEffects : public GrDrawState::AutoRestoreEffects {};
@@ -283,7 +262,7 @@ GrTextContext* GrContext::createTextContext(GrRenderTarget* renderTarget,
GrTexture* GrContext::findAndRefTexture(const GrTextureDesc& desc,
const GrCacheID& cacheID,
const GrTextureParams* params) {
- GrResourceKey resourceKey = GrTexturePriv::ComputeKey(fGpu, params, desc, cacheID);
+ GrResourceKey resourceKey = GrTextureImpl::ComputeKey(fGpu, params, desc, cacheID);
GrGpuResource* resource = fResourceCache->find(resourceKey);
SkSafeRef(resource);
return static_cast<GrTexture*>(resource);
@@ -292,7 +271,7 @@ GrTexture* GrContext::findAndRefTexture(const GrTextureDesc& desc,
bool GrContext::isTextureInCache(const GrTextureDesc& desc,
const GrCacheID& cacheID,
const GrTextureParams* params) const {
- GrResourceKey resourceKey = GrTexturePriv::ComputeKey(fGpu, params, desc, cacheID);
+ GrResourceKey resourceKey = GrTextureImpl::ComputeKey(fGpu, params, desc, cacheID);
return fResourceCache->hasKey(resourceKey);
}
@@ -431,16 +410,16 @@ GrTexture* GrContext::createTexture(const GrTextureParams* params,
const void* srcData,
size_t rowBytes,
GrResourceKey* cacheKey) {
- GrResourceKey resourceKey = GrTexturePriv::ComputeKey(fGpu, params, desc, cacheID);
+ GrResourceKey resourceKey = GrTextureImpl::ComputeKey(fGpu, params, desc, cacheID);
GrTexture* texture;
- if (GrTexturePriv::NeedsResizing(resourceKey)) {
+ if (GrTextureImpl::NeedsResizing(resourceKey)) {
// We do not know how to resize compressed textures.
SkASSERT(!GrPixelConfigIsCompressed(desc.fConfig));
texture = this->createResizedTexture(desc, cacheID,
srcData, rowBytes,
- GrTexturePriv::NeedsBilerp(resourceKey));
+ GrTextureImpl::NeedsBilerp(resourceKey));
} else {
texture = fGpu->createTexture(desc, srcData, rowBytes);
}
@@ -464,7 +443,7 @@ static GrTexture* create_scratch_texture(GrGpu* gpu,
const GrTextureDesc& desc) {
GrTexture* texture = gpu->createTexture(desc, NULL, 0);
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
// necessary space before adding it.
resourceCache->purgeAsNeeded(1, texture->gpuMemorySize());
@@ -504,7 +483,7 @@ GrTexture* GrContext::lockAndRefScratchTexture(const GrTextureDesc& inDesc, Scra
int origHeight = desc.fHeight;
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
resource = fResourceCache->find(key, GrResourceCache::kHide_OwnershipFlag);
if (resource) {
@@ -599,7 +578,7 @@ void GrContext::unlockScratchTexture(GrTexture* texture) {
// Instead, give up the cache's ref and leave the decision up to
// addExistingTextureToCache once its ref count reaches 0. For
// 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
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();
}
@@ -1439,7 +1418,7 @@ bool GrContext::readRenderTargetPixels(GrRenderTarget* target,
}
}
- if (!(kDontFlush_PixelOpsFlag & flags) && target->surfacePriv().hasPendingWrite()) {
+ if (!(kDontFlush_PixelOpsFlag & flags) && target->hasPendingWrite()) {
this->flush();
}
diff --git a/src/gpu/GrDistanceFieldTextContext.cpp b/src/gpu/GrDistanceFieldTextContext.cpp
index 07e9a2e21d..e2bd6e9f9c 100755
--- a/src/gpu/GrDistanceFieldTextContext.cpp
+++ b/src/gpu/GrDistanceFieldTextContext.cpp
@@ -7,20 +7,18 @@
#include "GrDistanceFieldTextContext.h"
#include "GrAtlas.h"
+#include "SkColorFilter.h"
#include "GrDrawTarget.h"
#include "GrDrawTargetCaps.h"
#include "GrFontScaler.h"
+#include "SkGlyphCache.h"
#include "GrGpu.h"
#include "GrIndexBuffer.h"
#include "GrStrokeInfo.h"
-#include "GrTexturePriv.h"
#include "GrTextStrike.h"
#include "GrTextStrike_impl.h"
-
-#include "SkColorFilter.h"
#include "SkDistanceFieldGen.h"
#include "SkDraw.h"
-#include "SkGlyphCache.h"
#include "SkGpuDevice.h"
#include "SkPath.h"
#include "SkRTConf.h"
@@ -425,10 +423,10 @@ HAS_ATLAS:
// The texture coords are last in both the with and without color vertex layouts.
SkPoint* textureCoords = reinterpret_cast<SkPoint*>(
reinterpret_cast<intptr_t>(positions) + vertSize - sizeof(SkPoint));
- textureCoords->setRectFan(SkFixedToFloat(texture->texturePriv().normalizeFixedX(tx)),
- SkFixedToFloat(texture->texturePriv().normalizeFixedY(ty)),
- SkFixedToFloat(texture->texturePriv().normalizeFixedX(tx + tw)),
- SkFixedToFloat(texture->texturePriv().normalizeFixedY(ty + th)),
+ textureCoords->setRectFan(SkFixedToFloat(texture->normalizeFixedX(tx)),
+ SkFixedToFloat(texture->normalizeFixedY(ty)),
+ SkFixedToFloat(texture->normalizeFixedX(tx + tw)),
+ SkFixedToFloat(texture->normalizeFixedY(ty + th)),
vertSize);
if (useColorVerts) {
if (0xFF == GrColorUnpackA(fPaint.getColor())) {
diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp
index d8848bc4d5..eb8991519d 100644
--- a/src/gpu/GrDrawTarget.cpp
+++ b/src/gpu/GrDrawTarget.cpp
@@ -13,7 +13,6 @@
#include "GrDrawTargetCaps.h"
#include "GrPath.h"
#include "GrRenderTarget.h"
-#include "GrSurfacePriv.h"
#include "GrTemplates.h"
#include "GrTexture.h"
#include "GrVertexBuffer.h"
@@ -965,7 +964,7 @@ bool GrDrawTarget::onCanCopySurface(GrSurface* dst,
SkASSERT(dstPoint.fX + srcRect.width() <= dst->width() &&
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,
diff --git a/src/gpu/GrSurface.cpp b/src/gpu/GrSurface.cpp
index 37fd73f4f4..d15cbdf6e2 100644
--- a/src/gpu/GrSurface.cpp
+++ b/src/gpu/GrSurface.cpp
@@ -6,7 +6,6 @@
*/
#include "GrSurface.h"
-#include "GrSurfacePriv.h"
#include "SkBitmap.h"
#include "SkGr.h"
@@ -21,16 +20,14 @@ SkImageInfo GrSurface::info() const {
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) {
SkBitmap bm;
if (!bm.tryAllocPixels(SkImageInfo::MakeN32Premul(this->width(), this->height()))) {
return false;
}
- bool result = this->readPixels(0, 0, this->width(), this->height(), kSkia8888_GrPixelConfig,
- bm.getPixels());
+ bool result = readPixels(0, 0, this->width(), this->height(), kSkia8888_GrPixelConfig,
+ bm.getPixels());
if (!result) {
SkDebugf("------ failed to read pixels for %s\n", filename);
return false;
@@ -83,14 +80,3 @@ bool GrSurface::hasPendingIO() const {
}
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();
- }
-}
diff --git a/src/gpu/GrSurfacePriv.h b/src/gpu/GrSurfacePriv.h
deleted file mode 100644
index 3203671fad..0000000000
--- a/src/gpu/GrSurfacePriv.h
+++ /dev/null
@@ -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
diff --git a/src/gpu/GrTextStrike.cpp b/src/gpu/GrTextStrike.cpp
index 8ae10cc8dd..fa97f73f05 100644
--- a/src/gpu/GrTextStrike.cpp
+++ b/src/gpu/GrTextStrike.cpp
@@ -7,7 +7,6 @@
#include "GrGpu.h"
#include "GrRectanizer.h"
-#include "GrSurfacePriv.h"
#include "GrTextStrike.h"
#include "GrTextStrike_impl.h"
#include "SkString.h"
@@ -207,7 +206,7 @@ void GrFontCache::dump() const {
#else
filename.printf("fontcache_%d%d.png", gDumpCount, i);
#endif
- texture->surfacePriv().savePixels(filename.c_str());
+ texture->savePixels(filename.c_str());
}
}
}
diff --git a/src/gpu/GrTexture.cpp b/src/gpu/GrTexture.cpp
index e1188f961b..667ddd1e51 100644
--- a/src/gpu/GrTexture.cpp
+++ b/src/gpu/GrTexture.cpp
@@ -7,13 +7,13 @@
*/
+#include "GrTexture.h"
+
#include "GrContext.h"
#include "GrDrawTargetCaps.h"
#include "GrGpu.h"
#include "GrRenderTarget.h"
#include "GrResourceCache.h"
-#include "GrTexture.h"
-#include "GrTexturePriv.h"
GrTexture::~GrTexture() {
if (fRenderTarget.get()) {
@@ -26,12 +26,12 @@ GrTexture::~GrTexture() {
* textures back in the texture cache when their ref count goes to zero.
*/
void GrTexture::internal_dispose() const {
- if (this->texturePriv().isSetFlag((GrTextureFlags) GrTexture::kReturnToCache_FlagBit) &&
+ if (this->impl()->isSetFlag((GrTextureFlags) GrTextureImpl::kReturnToCache_FlagBit) &&
this->INHERITED::getContext()) {
GrTexture* nonConstThis = const_cast<GrTexture *>(this);
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);
// Note: "this" texture might be freed inside addExistingTextureToCache
@@ -42,10 +42,10 @@ void GrTexture::internal_dispose() const {
this->INHERITED::internal_dispose();
}
-void GrTexture::dirtyMipMaps(bool mipMapsDirty) {
+void GrTextureImpl::dirtyMipMaps(bool mipMapsDirty) {
if (mipMapsDirty) {
if (kValid_MipMapsStatus == fMipMapsStatus) {
- fMipMapsStatus = kAllocated_MipMapsStatus;
+ fMipMapsStatus = kAllocated_MipMapsStatus;
}
} else {
const bool sizeChanged = kNotAllocated_MipMapsStatus == fMipMapsStatus;
@@ -66,7 +66,7 @@ size_t GrTexture::gpuMemorySize() const {
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'd expect because we never change fDesc.fWidth/fHeight.
textureSize *= 2;
@@ -107,17 +107,17 @@ void GrTexture::abandonReleaseCommon() {
// 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
// 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());
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);
}
}
void GrTexture::onRelease() {
this->abandonReleaseCommon();
- SkASSERT(!this->texturePriv().isSetFlag((GrTextureFlags) kReturnToCache_FlagBit));
+ SkASSERT(!this->impl()->isSetFlag((GrTextureFlags) GrTextureImpl::kReturnToCache_FlagBit));
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)
- , fRenderTarget(NULL)
, fMipMapsStatus(kNotAllocated_MipMapsStatus) {
- this->setScratchKey(GrTexturePriv::ComputeScratchKey(desc));
- // only make sense if alloc size is pow2
- fShiftFixedX = 31 - SkCLZ(fDesc.fWidth);
- fShiftFixedY = 31 - SkCLZ(fDesc.fHeight);
+ this->setScratchKey(ComputeScratchKey(desc));
}
-GrResourceKey GrTexturePriv::ComputeKey(const GrGpu* gpu,
+GrResourceKey GrTextureImpl::ComputeKey(const GrGpu* gpu,
const GrTextureParams* params,
const GrTextureDesc& desc,
const GrCacheID& cacheID) {
@@ -225,7 +221,7 @@ GrResourceKey GrTexturePriv::ComputeKey(const GrGpu* gpu,
return GrResourceKey(cacheID, texture_resource_type(), flags);
}
-GrResourceKey GrTexturePriv::ComputeScratchKey(const GrTextureDesc& desc) {
+GrResourceKey GrTextureImpl::ComputeScratchKey(const GrTextureDesc& desc) {
GrCacheID::Key idKey;
// Instead of a client-provided key of the texture contents we create a key from the
// descriptor.
@@ -244,10 +240,10 @@ GrResourceKey GrTexturePriv::ComputeScratchKey(const GrTextureDesc& desc) {
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);
}
-bool GrTexturePriv::NeedsBilerp(const GrResourceKey& key) {
+bool GrTextureImpl::NeedsBilerp(const GrResourceKey& key) {
return SkToBool(key.getResourceFlags() & kBilerp_TextureFlag);
}
diff --git a/src/gpu/GrTexturePriv.h b/src/gpu/GrTexturePriv.h
deleted file mode 100644
index 9a3e0e215b..0000000000
--- a/src/gpu/GrTexturePriv.h
+++ /dev/null
@@ -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
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 792ce6d30d..30b3668d6b 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -151,10 +151,9 @@ SkGpuDevice::SkGpuDevice(GrSurface* surface, const SkSurfaceProps& props, unsign
fRenderTarget = SkRef(surface->asRenderTarget());
- SkImageInfo info = surface->surfacePriv().info();
SkPixelRef* pr = SkNEW_ARGS(SkGrPixelRef,
- (info, surface, SkToBool(flags & kCached_Flag)));
- fLegacyBitmap.setInfo(info);
+ (surface->info(), surface, SkToBool(flags & kCached_Flag)));
+ fLegacyBitmap.setInfo(surface->info());
fLegacyBitmap.setPixelRef(pr)->unref();
this->setPixelGeometry(props.pixelGeometry());
@@ -692,7 +691,7 @@ bool create_mask_GPU(GrContext* context,
SkBitmap wrap_texture(GrTexture* texture) {
SkBitmap result;
- result.setInfo(texture->surfacePriv().info());
+ result.setInfo(texture->info());
result.setPixelRef(SkNEW_ARGS(SkGrPixelRef, (result.info(), texture)))->unref();
return result;
}
diff --git a/src/gpu/SkGpuDevice.h b/src/gpu/SkGpuDevice.h
index 285a73745c..f19d2cb62b 100644
--- a/src/gpu/SkGpuDevice.h
+++ b/src/gpu/SkGpuDevice.h
@@ -17,7 +17,6 @@
#include "SkPicture.h"
#include "SkRegion.h"
#include "GrContext.h"
-#include "GrSurfacePriv.h"
struct SkDrawProcs;
struct GrSkDrawProcs;
@@ -62,7 +61,7 @@ public:
virtual GrRenderTarget* accessRenderTarget() 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;
diff --git a/src/gpu/gl/GrGLTexture.h b/src/gpu/gl/GrGLTexture.h
index 05acaa82dc..23ae3fa31f 100644
--- a/src/gpu/gl/GrGLTexture.h
+++ b/src/gpu/gl/GrGLTexture.h
@@ -45,7 +45,7 @@ private:
////////////////////////////////////////////////////////////////////////////////
-class GrGLTexture : public GrTexture {
+class GrGLTexture : public GrTextureImpl {
public:
struct TexParams {
@@ -105,7 +105,7 @@ private:
const Desc& textureDesc,
const GrGLRenderTarget::Desc* rtDesc);
- typedef GrTexture INHERITED;
+ typedef GrTextureImpl INHERITED;
};
#endif
diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp
index 8be1118d64..be385110c9 100644
--- a/src/gpu/gl/GrGpuGL.cpp
+++ b/src/gpu/gl/GrGpuGL.cpp
@@ -9,9 +9,7 @@
#include "GrGpuGL.h"
#include "GrGLStencilBuffer.h"
#include "GrOptDrawState.h"
-#include "GrSurfacePriv.h"
#include "GrTemplates.h"
-#include "GrTexturePriv.h"
#include "GrTypes.h"
#include "SkStrokeRec.h"
#include "SkTemplates.h"
@@ -495,7 +493,7 @@ bool GrGpuGL::onWriteTexturePixels(GrTexture* texture,
}
if (success) {
- texture->texturePriv().dirtyMipMaps(true);
+ texture->impl()->dirtyMipMaps(true);
return true;
}
@@ -1733,7 +1731,7 @@ void GrGpuGL::flushRenderTarget(GrGLRenderTarget* target, const SkIRect* bound)
GrTexture *texture = target->asTexture();
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];
if (GrTextureParams::kMipMap_FilterMode == filterMode &&
- texture->texturePriv().mipMapsAreDirty() && !GrPixelConfigIsCompressed(texture->config())) {
+ texture->mipMapsAreDirty() && !GrPixelConfigIsCompressed(texture->config())) {
GL_CALL(GenerateMipmap(GR_GL_TEXTURE_2D));
- texture->texturePriv().dirtyMipMaps(false);
+ texture->dirtyMipMaps(false);
}
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,
srcRect.width(), srcRect.height());
bool selfOverlap = false;
- if (dst->surfacePriv().isSameAs(src)) {
+ if (dst->isSameAs(src)) {
selfOverlap = SkIRect::IntersectsNoEmptyCheck(dstRect, srcRect);
}
@@ -2549,7 +2547,7 @@ bool GrGpuGL::onCanCopySurface(GrSurface* dst,
return true;
}
if (can_blit_framebuffer(dst, src, this)) {
- if (dst->surfacePriv().isSameAs(src)) {
+ if (dst->isSameAs(src)) {
SkIRect dstRect = SkIRect::MakeXYWH(dstPoint.fX, dstPoint.fY,
srcRect.width(), srcRect.height());
if(!SkIRect::IntersectsNoEmptyCheck(dstRect, srcRect)) {