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

Unified Diff: src/gpu/GrTexturePriv.h

Issue 596053002: Make "priv" classes for GrTexure and GrSurface. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/gpu/GrTexturePriv.h
diff --git a/src/gpu/GrTexturePriv.h b/src/gpu/GrTexturePriv.h
new file mode 100644
index 0000000000000000000000000000000000000000..2913cf62f96d626f43dc71776a8e422ff3e415e3
--- /dev/null
+++ b/src/gpu/GrTexturePriv.h
@@ -0,0 +1,75 @@
+/*
+ * 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"
+#include "SkRefCnt.h"
+
robertphillips 2014/09/29 13:34:28 // A wrapper class that grants access to GrTexture
bsalomon 2014/09/29 18:42:11 Done.
+class GrTexturePriv : SkNoncopyable {
+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);
+
+ 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);
+
+
robertphillips 2014/09/29 13:34:28 It seems like these two should be static functions
bsalomon 2014/09/29 18:42:11 Agreed, will mark as TODO.
+ 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) { }
+
+ // No taking addresses of this type.
+ const GrTexturePriv* operator&() const;
+ GrTexturePriv* operator&();
+
+ GrTexture* fTexture;
+
robertphillips 2014/09/29 13:34:28 // For access to ctor, ComputeScratchKey. ?
bsalomon 2014/09/29 18:42:10 first yes, CSK is already public.
+ friend class GrTexture;
+};
+
+inline GrTexturePriv GrTexture::texturePriv() { return GrTexturePriv(this); }
+
+inline const GrTexturePriv GrTexture::texturePriv () const {
+ return GrTexturePriv(const_cast<GrTexture*>(this));
+}
+
+#endif
« src/gpu/GrTexture.cpp ('K') | « src/gpu/GrTexture.cpp ('k') | src/gpu/SkGpuDevice.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698