blob: e24a588d1d1258ea7092e707823a72f874f51faf [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 Phillipse2f7d182016-12-15 09:23:05 -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 Phillips31c26082016-12-14 15:12:15 -050031 sk_sp<GrSurfaceContext> makeWrappedSurfaceContext(sk_sp<GrSurfaceProxy> proxy);
32
Robert Phillipse305cc1f2016-12-14 12:19:05 -050033 sk_sp<GrSurfaceContext> makeDeferredSurfaceContext(const GrSurfaceDesc& dstDesc,
34 SkBackingFit dstFit,
35 SkBudgeted isDstBudgeted);
36
Brian Osman11052242016-10-27 14:47:55 -040037 sk_sp<GrRenderTargetContext> makeBackendTextureRenderTargetContext(
38 const GrBackendTextureDesc& desc,
39 sk_sp<SkColorSpace> colorSpace,
40 const SkSurfaceProps* = nullptr,
41 GrWrapOwnership = kBorrow_GrWrapOwnership);
robertphillips4fd74ae2016-08-03 14:26:53 -070042
Brian Osman11052242016-10-27 14:47:55 -040043 sk_sp<GrRenderTargetContext> makeBackendRenderTargetRenderTargetContext(
44 const GrBackendRenderTargetDesc& desc,
45 sk_sp<SkColorSpace> colorSpace,
46 const SkSurfaceProps* = nullptr);
robertphillips4fd74ae2016-08-03 14:26:53 -070047
Brian Osman11052242016-10-27 14:47:55 -040048 sk_sp<GrRenderTargetContext> makeBackendTextureAsRenderTargetRenderTargetContext(
robertphillips4fd74ae2016-08-03 14:26:53 -070049 const GrBackendTextureDesc& desc,
50 sk_sp<SkColorSpace> colorSpace,
51 const SkSurfaceProps* = nullptr);
52
53private:
54 explicit GrContextPriv(GrContext* context) : fContext(context) {}
55 GrContextPriv(const GrContextPriv&) {} // unimpl
56 GrContextPriv& operator=(const GrContextPriv&); // unimpl
57
58 // No taking addresses of this type.
59 const GrContextPriv* operator&() const;
60 GrContextPriv* operator&();
61
62 GrContext* fContext;
63
64 friend class GrContext; // to construct/copy this type.
65};
66
67inline GrContextPriv GrContext::contextPriv() { return GrContextPriv(this); }
68
69inline const GrContextPriv GrContext::contextPriv () const {
70 return GrContextPriv(const_cast<GrContext*>(this));
71}
72
73#endif