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