blob: 5c98e3f7736358aaf5453633372a9730a6d2494b [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
11#include "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). */
18class GrSurfacePriv {
19public:
Robert Phillips18166ee2017-06-01 12:55:44 -040020 /** Helpers used in read/write pixels implementations. The parameters are adjusted so that the
bsalomone8d21e82015-07-16 08:23:13 -070021 read/write respects the bounds of a surface. If the input *rowBytes is 0 it will be
22 the tight row bytes (based on width and bpp) on output. */
23 static bool AdjustReadPixelParams(int surfaceWidth,
24 int surfaceHeight,
25 size_t bpp,
26 int* left, int* top, int* width, int* height,
27 void** data,
28 size_t* rowBytes);
29 static bool AdjustWritePixelParams(int surfaceWidth,
30 int surfaceHeight,
31 size_t bpp,
32 int* left, int* top, int* width, int* height,
33 const void** data,
34 size_t* rowBytes);
bsalomonafbf2d62014-09-30 12:18:44 -070035
bsalomonafbf2d62014-09-30 12:18:44 -070036 bool hasPendingRead() const { return fSurface->hasPendingRead(); }
37 bool hasPendingWrite() const { return fSurface->hasPendingWrite(); }
38 bool hasPendingIO() const { return fSurface->hasPendingIO(); }
Eric Karl914a36b2017-10-12 12:44:50 -070039 bool hasUniqueRef() const { return fSurface->internalHasUniqueRef(); }
bsalomonafbf2d62014-09-30 12:18:44 -070040
Robert Phillipsfe0253f2018-03-16 16:47:25 -040041 GrInternalSurfaceFlags flags() const { return fSurface->fSurfaceFlags; }
42
Greg Daniel01422bc2018-06-08 22:01:16 +000043 bool doesNotSupportMipMaps() const { return fSurface->doesNotSupportMipMaps(); }
Greg Danielb73a9f82018-05-02 15:06:47 -040044 bool isGLTextureRectangleOrExternal() const {
45 return fSurface->isGLTextureRectangleOrExternal();
46 }
47 // We only support the clamp wrap mode with gl rectangle or external textures.
48 bool isClampOnly() const { return fSurface->isGLTextureRectangleOrExternal(); }
Robert Phillipsabf7b762018-03-21 12:13:37 -040049
bsalomonafbf2d62014-09-30 12:18:44 -070050private:
bsalomon6bc1b5f2015-02-23 09:06:38 -080051 explicit GrSurfacePriv(GrSurface* surface) : fSurface(surface) {}
52 GrSurfacePriv(const GrSurfacePriv&); // unimpl
53 GrSurfacePriv& operator=(const GrSurfacePriv&); // unimpl
bsalomonafbf2d62014-09-30 12:18:44 -070054
55 // No taking addresses of this type.
56 const GrSurfacePriv* operator&() const;
57 GrSurfacePriv* operator&();
58
59 GrSurface* fSurface;
60
61 friend class GrSurface; // to construct/copy this type.
62};
63
64inline GrSurfacePriv GrSurface::surfacePriv() { return GrSurfacePriv(this); }
65
66inline const GrSurfacePriv GrSurface::surfacePriv() const {
67 return GrSurfacePriv(const_cast<GrSurface*>(this));
68}
69
70#endif