blob: 398fc8a54915ce98d306beba81f7845869011532 [file] [log] [blame]
robertphillips4fd74ae2016-08-03 14:26:53 -07001/*
2 * Copyright 2016 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 GrContextPriv_DEFINED
9#define GrContextPriv_DEFINED
10
11#include "GrContext.h"
12
13/** Class that adds methods to GrContext that are only intended for use internal to Skia.
14 This class is purely a privileged window into GrContext. It should never have additional
15 data members or virtual methods. */
16class GrContextPriv {
17public:
bungeman6bd52842016-10-27 09:30:08 -070018 GrDrawingManager* drawingManager() { return fContext->fDrawingManager.get(); }
csmartdaltonbde96c62016-08-31 12:54:46 -070019
robertphillips4fd74ae2016-08-03 14:26:53 -070020 // Create a drawContext that wraps an existing renderTarget
21 sk_sp<GrDrawContext> makeWrappedDrawContext(sk_sp<GrRenderTarget> rt,
22 sk_sp<SkColorSpace> colorSpace,
23 const SkSurfaceProps* = nullptr);
24
25 sk_sp<GrDrawContext> makeBackendTextureDrawContext(const GrBackendTextureDesc& desc,
26 sk_sp<SkColorSpace> colorSpace,
27 const SkSurfaceProps* = nullptr,
28 GrWrapOwnership = kBorrow_GrWrapOwnership);
29
30 sk_sp<GrDrawContext> makeBackendRenderTargetDrawContext(const GrBackendRenderTargetDesc& desc,
31 sk_sp<SkColorSpace> colorSpace,
32 const SkSurfaceProps* = nullptr);
33
34 sk_sp<GrDrawContext> makeBackendTextureAsRenderTargetDrawContext(
35 const GrBackendTextureDesc& desc,
36 sk_sp<SkColorSpace> colorSpace,
37 const SkSurfaceProps* = nullptr);
38
39private:
40 explicit GrContextPriv(GrContext* context) : fContext(context) {}
41 GrContextPriv(const GrContextPriv&) {} // unimpl
42 GrContextPriv& operator=(const GrContextPriv&); // unimpl
43
44 // No taking addresses of this type.
45 const GrContextPriv* operator&() const;
46 GrContextPriv* operator&();
47
48 GrContext* fContext;
49
50 friend class GrContext; // to construct/copy this type.
51};
52
53inline GrContextPriv GrContext::contextPriv() { return GrContextPriv(this); }
54
55inline const GrContextPriv GrContext::contextPriv () const {
56 return GrContextPriv(const_cast<GrContext*>(this));
57}
58
59#endif