skia2/include/gpu/GrDirectContext.h
Adlai Holler 0ce2c54094 Reland "Reland "Take GrContext private, GrDDLContext inherit from GrRecordingContext""
This reverts commit cf43fc6768.

Reason for revert: Fixed g3

Original change's description:
> Revert "Reland "Take GrContext private, GrDDLContext inherit from GrRecordingContext""
>
> This reverts commit ff13ffbeac.
>
> Reason for revert: Blink in g3
>
> Original change's description:
> > Reland "Take GrContext private, GrDDLContext inherit from GrRecordingContext"
> >
> > This reverts commit 89bdc90ac8.
> >
> > Reason for revert: Fix metal
> >
> > Original change's description:
> > > Revert "Take GrContext private, GrDDLContext inherit from GrRecordingContext"
> > >
> > > This reverts commit d2daa94ede.
> > >
> > > Reason for revert: Metaru
> > >
> > > Original change's description:
> > > > Take GrContext private, GrDDLContext inherit from GrRecordingContext
> > > >
> > > > Woo!
> > > >
> > > > Change-Id: I8d201b709343dc18cad31ea740575285dd035f35
> > > > Docs-Preview: https://skia.org/?cl=317436
> > > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/317436
> > > > Reviewed-by: Robert Phillips <robertphillips@google.com>
> > > > Reviewed-by: Brian Salomon <bsalomon@google.com>
> > > > Commit-Queue: Adlai Holler <adlai@google.com>
> > >
> > > TBR=bsalomon@google.com,robertphillips@google.com,adlai@google.com
> > >
> > > Change-Id: I9b58dee285fbdc49ebc8e76df5da0fe224cf9787
> > > No-Presubmit: true
> > > No-Tree-Checks: true
> > > No-Try: true
> > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/318758
> > > Reviewed-by: Adlai Holler <adlai@google.com>
> > > Commit-Queue: Adlai Holler <adlai@google.com>
> >
> > TBR=bsalomon@google.com,robertphillips@google.com,adlai@google.com
> >
> >
> > Change-Id: Id4b10795193a904cd4ed8c36e60e74abe3b6702a
> > Docs-Preview: https://skia.org/?cl=318759
> > Cq-Include-Trybots: luci.skia.skia.primary:Build-Mac10.15.5-Clang-arm64-Debug-iOS_Metal,Build-Mac-Clang-x86_64-Debug-Metal
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/318759
> > Commit-Queue: Adlai Holler <adlai@google.com>
> > Reviewed-by: Adlai Holler <adlai@google.com>
>
> TBR=bsalomon@google.com,robertphillips@google.com,adlai@google.com
>
> Change-Id: Ib20fe933120d56b72efaec73a0bedec60bc28def
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/319184
> Commit-Queue: Adlai Holler <adlai@google.com>
> Reviewed-by: Adlai Holler <adlai@google.com>

TBR=bsalomon@google.com,robertphillips@google.com,adlai@google.com


Change-Id: I4f01291f4b3bfbb8fd7dd8cf2bf8415430c3392e
Docs-Preview: https://skia.org/?cl=322437
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/322437
Reviewed-by: Adlai Holler <adlai@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Adlai Holler <adlai@google.com>
Auto-Submit: Adlai Holler <adlai@google.com>
2020-10-06 18:59:11 +00:00

98 lines
3.4 KiB
C++

/*
* Copyright 2020 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef GrDirectContext_DEFINED
#define GrDirectContext_DEFINED
#include "include/private/GrContext.h"
class GrAtlasManager;
class GrSmallPathAtlasMgr;
class SK_API GrDirectContext : public GrContext {
public:
#ifdef SK_GL
/**
* Creates a GrDirectContext for a backend context. If no GrGLInterface is provided then the
* result of GrGLMakeNativeInterface() is used if it succeeds.
*/
static sk_sp<GrDirectContext> MakeGL(sk_sp<const GrGLInterface>, const GrContextOptions&);
static sk_sp<GrDirectContext> MakeGL(sk_sp<const GrGLInterface>);
static sk_sp<GrDirectContext> MakeGL(const GrContextOptions&);
static sk_sp<GrDirectContext> MakeGL();
#endif
#ifdef SK_VULKAN
/**
* The Vulkan context (VkQueue, VkDevice, VkInstance) must be kept alive until the returned
* GrDirectContext is destroyed. This also means that any objects created with this
* GrDirectContext (e.g. SkSurfaces, SkImages, etc.) must also be released as they may hold
* refs on the GrDirectContext. Once all these objects and the GrDirectContext are released,
* then it is safe to delete the vulkan objects.
*/
static sk_sp<GrDirectContext> MakeVulkan(const GrVkBackendContext&, const GrContextOptions&);
static sk_sp<GrDirectContext> MakeVulkan(const GrVkBackendContext&);
#endif
#ifdef SK_METAL
/**
* Makes a GrDirectContext which uses Metal as the backend. The device parameter is an
* MTLDevice and queue is an MTLCommandQueue which should be used by the backend. These objects
* must have a ref on them which can be transferred to Ganesh which will release the ref
* when the GrDirectContext is destroyed.
*/
static sk_sp<GrDirectContext> MakeMetal(void* device, void* queue, const GrContextOptions&);
static sk_sp<GrDirectContext> MakeMetal(void* device, void* queue);
#endif
#ifdef SK_DIRECT3D
/**
* Makes a GrDirectContext which uses Direct3D as the backend. The Direct3D context
* must be kept alive until the returned GrDirectContext is first destroyed or abandoned.
*/
static sk_sp<GrDirectContext> MakeDirect3D(const GrD3DBackendContext&, const GrContextOptions&);
static sk_sp<GrDirectContext> MakeDirect3D(const GrD3DBackendContext&);
#endif
#ifdef SK_DAWN
static sk_sp<GrDirectContext> MakeDawn(const wgpu::Device&,
const GrContextOptions&);
static sk_sp<GrDirectContext> MakeDawn(const wgpu::Device&);
#endif
static sk_sp<GrDirectContext> MakeMock(const GrMockOptions*, const GrContextOptions&);
static sk_sp<GrDirectContext> MakeMock(const GrMockOptions*);
~GrDirectContext() override;
void abandonContext() override;
void releaseResourcesAndAbandonContext() override;
void freeGpuResources() override;
protected:
GrDirectContext(GrBackendApi backend, const GrContextOptions& options);
bool init() override;
GrAtlasManager* onGetAtlasManager() override { return fAtlasManager.get(); }
GrSmallPathAtlasMgr* onGetSmallPathAtlasMgr() override;
GrDirectContext* asDirectContext() override { return this; }
private:
std::unique_ptr<GrAtlasManager> fAtlasManager;
std::unique_ptr<GrSmallPathAtlasMgr> fSmallPathAtlasMgr;
using INHERITED = GrContext;
};
#endif