blob: 2b2a39e00962c4a3dddd9b21f197c0220988fda1 [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"
Brian Osman45580d32016-11-23 09:37:01 -050012#include "GrSurfaceContext.h"
robertphillips4fd74ae2016-08-03 14:26:53 -070013
Robert Phillips4431de62016-12-13 09:01:40 -050014class GrSurfaceProxy;
15
robertphillips4fd74ae2016-08-03 14:26:53 -070016/** Class that adds methods to GrContext that are only intended for use internal to Skia.
17 This class is purely a privileged window into GrContext. It should never have additional
18 data members or virtual methods. */
19class GrContextPriv {
20public:
bungeman6bd52842016-10-27 09:30:08 -070021 GrDrawingManager* drawingManager() { return fContext->fDrawingManager.get(); }
csmartdaltonbde96c62016-08-31 12:54:46 -070022
Brian Osman11052242016-10-27 14:47:55 -040023 // Create a renderTargetContext that wraps an existing renderTarget
24 sk_sp<GrRenderTargetContext> makeWrappedRenderTargetContext(sk_sp<GrRenderTarget> rt,
25 sk_sp<SkColorSpace> colorSpace,
26 const SkSurfaceProps* = nullptr);
robertphillips4fd74ae2016-08-03 14:26:53 -070027
Brian Osman45580d32016-11-23 09:37:01 -050028 // Create a surfaceContext that wraps an existing texture or renderTarget
29 sk_sp<GrSurfaceContext> makeWrappedSurfaceContext(sk_sp<GrSurface> tex);
30
Robert Phillips4431de62016-12-13 09:01:40 -050031 sk_sp<GrSurfaceContext> makeDeferredSurfaceContext(const GrSurfaceDesc& dstDesc,
32 SkBudgeted isDstBudgeted);
33
34 sk_sp<GrSurfaceContext> makeTestSurfaceContext(sk_sp<GrSurfaceProxy> proxy);
35
Brian Osman11052242016-10-27 14:47:55 -040036 sk_sp<GrRenderTargetContext> makeBackendTextureRenderTargetContext(
37 const GrBackendTextureDesc& desc,
38 sk_sp<SkColorSpace> colorSpace,
39 const SkSurfaceProps* = nullptr,
40 GrWrapOwnership = kBorrow_GrWrapOwnership);
robertphillips4fd74ae2016-08-03 14:26:53 -070041
Brian Osman11052242016-10-27 14:47:55 -040042 sk_sp<GrRenderTargetContext> makeBackendRenderTargetRenderTargetContext(
43 const GrBackendRenderTargetDesc& desc,
44 sk_sp<SkColorSpace> colorSpace,
45 const SkSurfaceProps* = nullptr);
robertphillips4fd74ae2016-08-03 14:26:53 -070046
Brian Osman11052242016-10-27 14:47:55 -040047 sk_sp<GrRenderTargetContext> makeBackendTextureAsRenderTargetRenderTargetContext(
robertphillips4fd74ae2016-08-03 14:26:53 -070048 const GrBackendTextureDesc& desc,
49 sk_sp<SkColorSpace> colorSpace,
50 const SkSurfaceProps* = nullptr);
51
52private:
53 explicit GrContextPriv(GrContext* context) : fContext(context) {}
54 GrContextPriv(const GrContextPriv&) {} // unimpl
55 GrContextPriv& operator=(const GrContextPriv&); // unimpl
56
57 // No taking addresses of this type.
58 const GrContextPriv* operator&() const;
59 GrContextPriv* operator&();
60
61 GrContext* fContext;
62
63 friend class GrContext; // to construct/copy this type.
64};
65
66inline GrContextPriv GrContext::contextPriv() { return GrContextPriv(this); }
67
68inline const GrContextPriv GrContext::contextPriv () const {
69 return GrContextPriv(const_cast<GrContext*>(this));
70}
71
72#endif