• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "include/gpu/GrSurface.h"
12 
13 /** Class that adds methods to GrSurface that are only intended for use internal to Skia.
14     This class is purely a privileged window into GrSurface. It should never have additional data
15     members or virtual methods.
16     Non-static methods that are not trivial inlines should be spring-boarded (e.g. declared and
17     implemented privately in GrSurface with a inline public method here). */
18 class GrSurfacePriv {
19 public:
hasPendingRead()20     bool hasPendingRead() const { return fSurface->hasPendingRead(); }
hasPendingWrite()21     bool hasPendingWrite() const { return fSurface->hasPendingWrite(); }
hasPendingIO()22     bool hasPendingIO() const { return fSurface->hasPendingIO(); }
hasUniqueRef()23     bool hasUniqueRef() const { return fSurface->internalHasUniqueRef(); }
24 
flags()25     GrInternalSurfaceFlags flags() const { return fSurface->fSurfaceFlags; }
26 
27 private:
GrSurfacePriv(GrSurface * surface)28     explicit GrSurfacePriv(GrSurface* surface) : fSurface(surface) {}
29     GrSurfacePriv(const GrSurfacePriv&); // unimpl
30     GrSurfacePriv& operator=(const GrSurfacePriv&); // unimpl
31 
32     // No taking addresses of this type.
33     const GrSurfacePriv* operator&() const;
34     GrSurfacePriv* operator&();
35 
36     GrSurface* fSurface;
37 
38     friend class GrSurface; // to construct/copy this type.
39 };
40 
surfacePriv()41 inline GrSurfacePriv GrSurface::surfacePriv() { return GrSurfacePriv(this); }
42 
surfacePriv()43 inline const GrSurfacePriv GrSurface::surfacePriv() const {
44     return GrSurfacePriv(const_cast<GrSurface*>(this));
45 }
46 
47 #endif
48