OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2014 Google Inc. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. |
| 6 */ |
| 7 |
| 8 #ifndef GrSurfacePriv_DEFINED |
| 9 #define GrSurfacePriv_DEFINED |
| 10 |
| 11 #include "GrSurface.h" |
| 12 #include "SkRefCnt.h" |
| 13 |
| 14 /** Class that adds methods to GrSurface that are only intended for use internal
to Skia. |
| 15 This class is purely a privileged window into GrSurface. It should never hav
e additional data |
| 16 members or virtual methods. |
| 17 Non-static methods that are not trivial inlines should be spring-boarded (e.
g. declared and |
| 18 implemented privately in GrSurface with a inline public method here). */ |
| 19 class GrSurfacePriv : SkNoncopyable { |
| 20 public: |
| 21 /** |
| 22 * Derive a SkImageInfo from the surface's descriptor. This is lossy as Imag
eInfo has fields not |
| 23 * known to GrSurface (e.g. alphaType). |
| 24 */ |
| 25 SkImageInfo info() const { return fSurface->info(); } |
| 26 |
| 27 /** |
| 28 * Checks whether this GrSurface refers to the same GPU object as other. Thi
s |
| 29 * catches the case where a GrTexture and GrRenderTarget refer to the same |
| 30 * GPU memory. |
| 31 */ |
| 32 bool isSameAs(const GrSurface* other) const { return fSurface->isSameAs(othe
r); } |
| 33 |
| 34 /** |
| 35 * Write the contents of the surface to a PNG. Returns true if successful. |
| 36 * @param filename Full path to desired file |
| 37 */ |
| 38 bool savePixels(const char* filename) { return fSurface->savePixels(filename
); } |
| 39 |
| 40 bool hasPendingRead() const { return fSurface->hasPendingRead(); } |
| 41 bool hasPendingWrite() const { return fSurface->hasPendingWrite(); } |
| 42 bool hasPendingIO() const { return fSurface->hasPendingIO(); } |
| 43 |
| 44 private: |
| 45 GrSurfacePriv(GrSurface* surface) : fSurface(surface) { } |
| 46 |
| 47 // No taking addresses of this type. |
| 48 const GrSurfacePriv* operator&() const; |
| 49 GrSurfacePriv* operator&(); |
| 50 |
| 51 GrSurface* fSurface; |
| 52 |
| 53 friend class GrSurface; // to construct this type. |
| 54 }; |
| 55 |
| 56 inline GrSurfacePriv GrSurface::surfacePriv() { return GrSurfacePriv(this); } |
| 57 |
| 58 inline const GrSurfacePriv GrSurface::surfacePriv() const { |
| 59 return GrSurfacePriv(const_cast<GrSurface*>(this)); |
| 60 } |
| 61 |
| 62 #endif |
OLD | NEW |