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

Unified Diff: src/gpu/GrSurfacePriv.h

Issue 596053002: Make "priv" classes for GrTexure and GrSurface. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add SK_API 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
« no previous file with comments | « src/gpu/GrSurface.cpp ('k') | src/gpu/GrTextStrike.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrSurfacePriv.h
diff --git a/src/gpu/GrSurfacePriv.h b/src/gpu/GrSurfacePriv.h
new file mode 100644
index 0000000000000000000000000000000000000000..3203671fadc4b806a6f9b639f87b46354152519a
--- /dev/null
+++ b/src/gpu/GrSurfacePriv.h
@@ -0,0 +1,63 @@
+/*
+ * 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
« no previous file with comments | « src/gpu/GrSurface.cpp ('k') | src/gpu/GrTextStrike.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698