blob: dcf08075071b3906e591ad4ae8b8fe7f05223651 [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
Brian Osman11052242016-10-27 14:47:55 -040029 sk_sp<GrRenderTargetContext> makeBackendTextureRenderTargetContext(
30 const GrBackendTextureDesc& desc,
31 sk_sp<SkColorSpace> colorSpace,
32 const SkSurfaceProps* = nullptr,
33 GrWrapOwnership = kBorrow_GrWrapOwnership);
robertphillips4fd74ae2016-08-03 14:26:53 -070034
Brian Osman11052242016-10-27 14:47:55 -040035 sk_sp<GrRenderTargetContext> makeBackendRenderTargetRenderTargetContext(
36 const GrBackendRenderTargetDesc& desc,
37 sk_sp<SkColorSpace> colorSpace,
38 const SkSurfaceProps* = nullptr);
robertphillips4fd74ae2016-08-03 14:26:53 -070039
Brian Osman11052242016-10-27 14:47:55 -040040 sk_sp<GrRenderTargetContext> makeBackendTextureAsRenderTargetRenderTargetContext(
robertphillips4fd74ae2016-08-03 14:26:53 -070041 const GrBackendTextureDesc& desc,
42 sk_sp<SkColorSpace> colorSpace,
43 const SkSurfaceProps* = nullptr);
44
45private:
46 explicit GrContextPriv(GrContext* context) : fContext(context) {}
47 GrContextPriv(const GrContextPriv&) {} // unimpl
48 GrContextPriv& operator=(const GrContextPriv&); // unimpl
49
50 // No taking addresses of this type.
51 const GrContextPriv* operator&() const;
52 GrContextPriv* operator&();
53
54 GrContext* fContext;
55
56 friend class GrContext; // to construct/copy this type.
57};
58
59inline GrContextPriv GrContext::contextPriv() { return GrContextPriv(this); }
60
61inline const GrContextPriv GrContext::contextPriv () const {
62 return GrContextPriv(const_cast<GrContext*>(this));
63}
64
65#endif