blob: 75effa3848cdd42296b126c7f3dd00b5a67331b2 [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
14/** Class that adds methods to GrContext that are only intended for use internal to Skia.
15 This class is purely a privileged window into GrContext. It should never have additional
16 data members or virtual methods. */
17class GrContextPriv {
18public:
bungeman6bd52842016-10-27 09:30:08 -070019 GrDrawingManager* drawingManager() { return fContext->fDrawingManager.get(); }
csmartdaltonbde96c62016-08-31 12:54:46 -070020
Brian Osman11052242016-10-27 14:47:55 -040021 // Create a renderTargetContext that wraps an existing renderTarget
22 sk_sp<GrRenderTargetContext> makeWrappedRenderTargetContext(sk_sp<GrRenderTarget> rt,
23 sk_sp<SkColorSpace> colorSpace,
24 const SkSurfaceProps* = nullptr);
robertphillips4fd74ae2016-08-03 14:26:53 -070025
Brian Osman45580d32016-11-23 09:37:01 -050026 // Create a surfaceContext that wraps an existing texture or renderTarget
27 sk_sp<GrSurfaceContext> makeWrappedSurfaceContext(sk_sp<GrSurface> tex);
28
Robert Phillips31c26082016-12-14 15:12:15 -050029 sk_sp<GrSurfaceContext> makeWrappedSurfaceContext(sk_sp<GrSurfaceProxy> proxy);
30
Robert Phillipse305cc1f2016-12-14 12:19:05 -050031 sk_sp<GrSurfaceContext> makeDeferredSurfaceContext(const GrSurfaceDesc& dstDesc,
32 SkBackingFit dstFit,
33 SkBudgeted isDstBudgeted);
34
Brian Osman11052242016-10-27 14:47:55 -040035 sk_sp<GrRenderTargetContext> makeBackendTextureRenderTargetContext(
36 const GrBackendTextureDesc& desc,
37 sk_sp<SkColorSpace> colorSpace,
38 const SkSurfaceProps* = nullptr,
39 GrWrapOwnership = kBorrow_GrWrapOwnership);
robertphillips4fd74ae2016-08-03 14:26:53 -070040
Brian Osman11052242016-10-27 14:47:55 -040041 sk_sp<GrRenderTargetContext> makeBackendRenderTargetRenderTargetContext(
42 const GrBackendRenderTargetDesc& desc,
43 sk_sp<SkColorSpace> colorSpace,
44 const SkSurfaceProps* = nullptr);
robertphillips4fd74ae2016-08-03 14:26:53 -070045
Brian Osman11052242016-10-27 14:47:55 -040046 sk_sp<GrRenderTargetContext> makeBackendTextureAsRenderTargetRenderTargetContext(
robertphillips4fd74ae2016-08-03 14:26:53 -070047 const GrBackendTextureDesc& desc,
48 sk_sp<SkColorSpace> colorSpace,
49 const SkSurfaceProps* = nullptr);
50
51private:
52 explicit GrContextPriv(GrContext* context) : fContext(context) {}
53 GrContextPriv(const GrContextPriv&) {} // unimpl
54 GrContextPriv& operator=(const GrContextPriv&); // unimpl
55
56 // No taking addresses of this type.
57 const GrContextPriv* operator&() const;
58 GrContextPriv* operator&();
59
60 GrContext* fContext;
61
62 friend class GrContext; // to construct/copy this type.
63};
64
65inline GrContextPriv GrContext::contextPriv() { return GrContextPriv(this); }
66
67inline const GrContextPriv GrContext::contextPriv () const {
68 return GrContextPriv(const_cast<GrContext*>(this));
69}
70
71#endif