Chromium Code Reviews| Index: src/gpu/GrSurfacePriv.h |
| diff --git a/src/gpu/GrSurfacePriv.h b/src/gpu/GrSurfacePriv.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..5f96d139de754a733797cda2e9365d2f63b999b6 |
| --- /dev/null |
| +++ b/src/gpu/GrSurfacePriv.h |
| @@ -0,0 +1,58 @@ |
| +/* |
| + * 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" |
| +#include "SkRefCnt.h" |
| + |
| +/** Class that adds methods to GrSurface that are only intended for use internal to Skia. */ |
|
robertphillips
2014/09/29 13:34:27
// It should never get additional member variables
bsalomon
2014/09/29 18:42:10
Done.
|
| +class GrSurfacePriv : SkNoncopyable { |
| +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); } |
| + |
|
robertphillips
2014/09/29 13:34:28
Should this be DEVELOPER only ?
bsalomon
2014/09/29 18:42:10
Maybe, let's leave that to a future CL. Added a co
|
| + /** |
| + * 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) { } |
| + |
| + // No taking addresses of this type. |
| + const GrSurfacePriv* operator&() const; |
| + GrSurfacePriv* operator&(); |
| + |
| + GrSurface* fSurface; |
| + |
|
robertphillips
2014/09/29 13:34:27
// For access to ctor. ?
bsalomon
2014/09/29 18:42:10
Done.
|
| + friend class GrSurface; |
| +}; |
| + |
| +inline GrSurfacePriv GrSurface::surfacePriv() { return GrSurfacePriv(this); } |
| + |
| +inline const GrSurfacePriv GrSurface::surfacePriv() const { |
| + return GrSurfacePriv(const_cast<GrSurface*>(this)); |
| +} |
| + |
| +#endif |