Line data Source code
1 : /*
2 : * Copyright 2017 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 GrSurfaceProxyPriv_DEFINED
9 : #define GrSurfaceProxyPriv_DEFINED
10 :
11 : #include "GrSurfaceProxy.h"
12 :
13 : /** Class that adds methods to GrSurfaceProxy that are only intended for use internal to Skia.
14 : This class is purely a privileged window into GrSurfaceProxy. It should never have additional
15 : data members or virtual methods. */
16 : class GrSurfaceProxyPriv {
17 : public:
18 : // If the proxy is already instantiated, return its backing GrTexture; if not,
19 : // return null
20 0 : const GrTexture* peekTexture() const {
21 0 : return fProxy->fTarget ? fProxy->fTarget->asTexture() : nullptr;
22 : }
23 :
24 : // Beware! This call is only guaranteed to tell you if the proxy in question has
25 : // any pending IO in its current state. It won't tell you about the IO state in the
26 : // future when the proxy is actually used/instantiated.
27 0 : bool hasPendingIO() const { return fProxy->hasPendingIO(); }
28 :
29 : // Beware! This call is only guaranteed to tell you if the proxy in question has
30 : // any pending writes in its current state. It won't tell you about the IO state in the
31 : // future when the proxy is actually used/instantiated.
32 0 : bool hasPendingWrite() const { return fProxy->hasPendingWrite(); }
33 :
34 : // Don't abuse this call!!!!!!!
35 0 : bool isExact() const { return SkBackingFit::kExact == fProxy->fFit; }
36 :
37 : // Don't. Just don't.
38 : void exactify();
39 :
40 : private:
41 0 : explicit GrSurfaceProxyPriv(GrSurfaceProxy* proxy) : fProxy(proxy) {}
42 : GrSurfaceProxyPriv(const GrSurfaceProxyPriv&) {} // unimpl
43 : GrSurfaceProxyPriv& operator=(const GrSurfaceProxyPriv&); // unimpl
44 :
45 : // No taking addresses of this type.
46 : const GrSurfaceProxyPriv* operator&() const;
47 : GrSurfaceProxyPriv* operator&();
48 :
49 : GrSurfaceProxy* fProxy;
50 :
51 : friend class GrSurfaceProxy; // to construct/copy this type.
52 : };
53 :
54 0 : inline GrSurfaceProxyPriv GrSurfaceProxy::priv() { return GrSurfaceProxyPriv(this); }
55 :
56 0 : inline const GrSurfaceProxyPriv GrSurfaceProxy::priv () const {
57 0 : return GrSurfaceProxyPriv(const_cast<GrSurfaceProxy*>(this));
58 : }
59 :
60 : #endif
|