2019-01-30 18:08:28 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2019 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GrContext_Base_DEFINED
|
|
|
|
#define GrContext_Base_DEFINED
|
|
|
|
|
|
|
|
#include "SkRefCnt.h"
|
2019-02-04 17:05:37 +00:00
|
|
|
#include "GrContextOptions.h"
|
2019-01-30 18:08:28 +00:00
|
|
|
#include "GrTypes.h"
|
|
|
|
|
|
|
|
class GrBaseContextPriv;
|
2019-02-04 22:50:57 +00:00
|
|
|
class GrCaps;
|
2019-01-30 18:08:28 +00:00
|
|
|
class GrContext;
|
|
|
|
class GrImageContext;
|
|
|
|
class GrRecordingContext;
|
2019-02-04 22:50:57 +00:00
|
|
|
class GrSkSLFPFactoryCache;
|
2019-01-30 18:08:28 +00:00
|
|
|
|
|
|
|
class SK_API GrContext_Base : public SkRefCnt {
|
|
|
|
public:
|
|
|
|
virtual ~GrContext_Base();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The 3D API backing this context
|
|
|
|
*/
|
|
|
|
GrBackendApi backend() const { return fBackend; }
|
|
|
|
|
|
|
|
// Provides access to functions that aren't part of the public API.
|
|
|
|
GrBaseContextPriv priv();
|
|
|
|
const GrBaseContextPriv priv() const;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
friend class GrBaseContextPriv; // for hidden functions
|
|
|
|
|
2019-02-04 17:05:37 +00:00
|
|
|
GrContext_Base(GrBackendApi backend, const GrContextOptions& options, uint32_t uniqueID);
|
2019-01-30 18:08:28 +00:00
|
|
|
|
2019-02-01 15:19:42 +00:00
|
|
|
/**
|
|
|
|
* An identifier for this context. The id is used by all compatible contexts. For example,
|
|
|
|
* if SkImages are created on one thread using an image creation context, then fed into a
|
|
|
|
* DDL Recorder on second thread (which has a recording context) and finally replayed on
|
|
|
|
* a third thread with a direct context, then all three contexts will report the same id.
|
|
|
|
* It is an error for an image to be used with contexts that report different ids.
|
|
|
|
*/
|
|
|
|
uint32_t contextID() const { return fContextID; }
|
|
|
|
|
2019-02-04 17:05:37 +00:00
|
|
|
/*
|
|
|
|
* The options in effect for this context
|
|
|
|
*/
|
|
|
|
const GrContextOptions& options() const { return fOptions; }
|
|
|
|
|
2019-02-04 22:50:57 +00:00
|
|
|
const GrCaps* caps() const;
|
|
|
|
sk_sp<const GrCaps> refCaps() const;
|
|
|
|
|
|
|
|
sk_sp<GrSkSLFPFactoryCache> fpFactoryCache();
|
|
|
|
|
2019-01-30 18:08:28 +00:00
|
|
|
GrContext_Base* asBaseContext() { return this; }
|
|
|
|
virtual GrImageContext* asImageContext() { return nullptr; }
|
|
|
|
virtual GrRecordingContext* asRecordingContext() { return nullptr; }
|
|
|
|
virtual GrContext* asDirectContext() { return nullptr; }
|
|
|
|
|
2019-02-04 22:50:57 +00:00
|
|
|
virtual bool init(sk_sp<const GrCaps>, sk_sp<GrSkSLFPFactoryCache>);
|
|
|
|
|
2019-01-30 18:08:28 +00:00
|
|
|
private:
|
2019-02-04 22:50:57 +00:00
|
|
|
const GrBackendApi fBackend;
|
|
|
|
const GrContextOptions fOptions;
|
|
|
|
const uint32_t fContextID;
|
|
|
|
sk_sp<const GrCaps> fCaps;
|
|
|
|
sk_sp<GrSkSLFPFactoryCache> fFPFactoryCache;
|
2019-01-30 18:08:28 +00:00
|
|
|
|
|
|
|
typedef SkRefCnt INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|