blob: bd7aa539f635f9043fd1041c17adbe1b5db96365 [file] [log] [blame]
bsalomonafbf2d62014-09-30 12:18:44 -07001/*
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
Mike Kleinc0bd9f92019-04-23 12:05:21 -050011#include "include/gpu/GrSurface.h"
bsalomonafbf2d62014-09-30 12:18:44 -070012
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). */
18class GrSurfacePriv {
19public:
Robert Phillipsfe0253f2018-03-16 16:47:25 -040020 GrInternalSurfaceFlags flags() const { return fSurface->fSurfaceFlags; }
21
bsalomonafbf2d62014-09-30 12:18:44 -070022private:
bsalomon6bc1b5f2015-02-23 09:06:38 -080023 explicit GrSurfacePriv(GrSurface* surface) : fSurface(surface) {}
24 GrSurfacePriv(const GrSurfacePriv&); // unimpl
25 GrSurfacePriv& operator=(const GrSurfacePriv&); // unimpl
bsalomonafbf2d62014-09-30 12:18:44 -070026
27 // No taking addresses of this type.
28 const GrSurfacePriv* operator&() const;
29 GrSurfacePriv* operator&();
30
31 GrSurface* fSurface;
32
33 friend class GrSurface; // to construct/copy this type.
34};
35
36inline GrSurfacePriv GrSurface::surfacePriv() { return GrSurfacePriv(this); }
37
38inline const GrSurfacePriv GrSurface::surfacePriv() const {
39 return GrSurfacePriv(const_cast<GrSurface*>(this));
40}
41
42#endif