Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Macros | Typedefs | Functions
GrDirectContext.cpp File Reference
#include "include/gpu/GrDirectContext.h"
#include "include/core/SkImageInfo.h"
#include "include/core/SkPixmap.h"
#include "include/core/SkSize.h"
#include "include/core/SkSurface.h"
#include "include/core/SkTextureCompressionType.h"
#include "include/core/SkTraceMemoryDump.h"
#include "include/gpu/GpuTypes.h"
#include "include/gpu/GrBackendSemaphore.h"
#include "include/gpu/GrBackendSurface.h"
#include "include/gpu/GrContextThreadSafeProxy.h"
#include "include/private/base/SingleOwner.h"
#include "include/private/base/SkTArray.h"
#include "include/private/base/SkTemplates.h"
#include "include/private/gpu/ganesh/GrTypesPriv.h"
#include "src/base/SkAutoMalloc.h"
#include "src/core/SkCompressedDataUtils.h"
#include "src/core/SkMipmap.h"
#include "src/core/SkTaskGroup.h"
#include "src/core/SkTraceEvent.h"
#include "src/gpu/DataUtils.h"
#include "src/gpu/GpuTypesPriv.h"
#include "src/gpu/RefCntedCallback.h"
#include "src/gpu/Swizzle.h"
#include "src/gpu/ganesh/Device.h"
#include "src/gpu/ganesh/GrBackendUtils.h"
#include "src/gpu/ganesh/GrCaps.h"
#include "src/gpu/ganesh/GrClientMappedBufferManager.h"
#include "src/gpu/ganesh/GrColorInfo.h"
#include "src/gpu/ganesh/GrContextThreadSafeProxyPriv.h"
#include "src/gpu/ganesh/GrDirectContextPriv.h"
#include "src/gpu/ganesh/GrDrawOpAtlas.h"
#include "src/gpu/ganesh/GrDrawingManager.h"
#include "src/gpu/ganesh/GrGpu.h"
#include "src/gpu/ganesh/GrPixmap.h"
#include "src/gpu/ganesh/GrProxyProvider.h"
#include "src/gpu/ganesh/GrRenderTargetProxy.h"
#include "src/gpu/ganesh/GrResourceCache.h"
#include "src/gpu/ganesh/GrResourceProvider.h"
#include "src/gpu/ganesh/GrSemaphore.h"
#include "src/gpu/ganesh/GrShaderCaps.h"
#include "src/gpu/ganesh/GrSurfaceProxy.h"
#include "src/gpu/ganesh/GrSurfaceProxyView.h"
#include "src/gpu/ganesh/GrThreadSafePipelineBuilder.h"
#include "src/gpu/ganesh/SurfaceContext.h"
#include "src/gpu/ganesh/image/SkImage_GaneshBase.h"
#include "src/gpu/ganesh/mock/GrMockGpu.h"
#include "src/gpu/ganesh/ops/SmallPathAtlasMgr.h"
#include "src/gpu/ganesh/surface/SkSurface_Ganesh.h"
#include "src/gpu/ganesh/text/GrAtlasManager.h"
#include "src/image/SkImage_Base.h"
#include "src/image/SkSurface_Base.h"
#include "src/text/gpu/StrikeCache.h"
#include "src/text/gpu/TextBlobRedrawCoordinator.h"
#include <array>
#include <atomic>
#include <forward_list>
#include <memory>
#include <utility>

Go to the source code of this file.

Macros

#define ASSERT_SINGLE_OWNER   SKGPU_ASSERT_SINGLE_OWNER(this->singleOwner())
 

Typedefs

using StrikeCache = sktext::gpu::StrikeCache
 

Functions

static GrBackendTexture create_and_clear_backend_texture (GrDirectContext *dContext, SkISize dimensions, const GrBackendFormat &backendFormat, skgpu::Mipmapped mipmapped, GrRenderable renderable, GrProtected isProtected, sk_sp< skgpu::RefCntedCallback > finishedCallback, std::array< float, 4 > color, std::string_view label)
 
static bool update_texture_with_pixmaps (GrDirectContext *context, const SkPixmap src[], int numLevels, const GrBackendTexture &backendTexture, GrSurfaceOrigin textureOrigin, sk_sp< skgpu::RefCntedCallback > finishedCallback)
 
static GrBackendTexture create_and_update_compressed_backend_texture (GrDirectContext *dContext, SkISize dimensions, const GrBackendFormat &backendFormat, skgpu::Mipmapped mipmapped, GrProtected isProtected, sk_sp< skgpu::RefCntedCallback > finishedCallback, const void *data, size_t size)
 

Macro Definition Documentation

◆ ASSERT_SINGLE_OWNER

#define ASSERT_SINGLE_OWNER   SKGPU_ASSERT_SINGLE_OWNER(this->singleOwner())

Definition at line 75 of file GrDirectContext.cpp.

Typedef Documentation

◆ StrikeCache

Definition at line 77 of file GrDirectContext.cpp.

Function Documentation

◆ create_and_clear_backend_texture()

static GrBackendTexture create_and_clear_backend_texture ( GrDirectContext dContext,
SkISize  dimensions,
const GrBackendFormat backendFormat,
skgpu::Mipmapped  mipmapped,
GrRenderable  renderable,
GrProtected  isProtected,
sk_sp< skgpu::RefCntedCallback finishedCallback,
std::array< float, 4 >  color,
std::string_view  label 
)
static

Definition at line 643 of file GrDirectContext.cpp.

652 {
653 GrGpu* gpu = dContext->priv().getGpu();
654 GrBackendTexture beTex = gpu->createBackendTexture(dimensions, backendFormat, renderable,
655 mipmapped, isProtected, label);
656 if (!beTex.isValid()) {
657 return {};
658 }
659
660 if (!dContext->priv().getGpu()->clearBackendTexture(beTex,
661 std::move(finishedCallback),
662 color)) {
663 dContext->deleteBackendTexture(beTex);
664 return {};
665 }
666 return beTex;
667}
SkColor4f color
void deleteBackendTexture(const GrBackendTexture &)
GrDirectContextPriv priv()
Definition GrGpu.h:62
GrBackendTexture createBackendTexture(SkISize dimensions, const GrBackendFormat &, GrRenderable, skgpu::Mipmapped, GrProtected, std::string_view label)
Definition GrGpu.cpp:868
bool clearBackendTexture(const GrBackendTexture &, sk_sp< skgpu::RefCntedCallback > finishedCallback, std::array< float, 4 > color)
Definition GrGpu.cpp:898

◆ create_and_update_compressed_backend_texture()

static GrBackendTexture create_and_update_compressed_backend_texture ( GrDirectContext dContext,
SkISize  dimensions,
const GrBackendFormat backendFormat,
skgpu::Mipmapped  mipmapped,
GrProtected  isProtected,
sk_sp< skgpu::RefCntedCallback finishedCallback,
const void *  data,
size_t  size 
)
static

Definition at line 910 of file GrDirectContext.cpp.

918 {
919 GrGpu* gpu = dContext->priv().getGpu();
920
921 GrBackendTexture beTex = gpu->createCompressedBackendTexture(dimensions, backendFormat,
922 mipmapped, isProtected);
923 if (!beTex.isValid()) {
924 return {};
925 }
926
927 if (!dContext->priv().getGpu()->updateCompressedBackendTexture(
928 beTex, std::move(finishedCallback), data, size)) {
929 dContext->deleteBackendTexture(beTex);
930 return {};
931 }
932 return beTex;
933}
GrBackendTexture createCompressedBackendTexture(SkISize dimensions, const GrBackendFormat &, skgpu::Mipmapped, GrProtected)
Definition GrGpu.cpp:912
bool updateCompressedBackendTexture(const GrBackendTexture &, sk_sp< skgpu::RefCntedCallback > finishedCallback, const void *data, size_t length)
Definition GrGpu.cpp:941

◆ update_texture_with_pixmaps()

static bool update_texture_with_pixmaps ( GrDirectContext context,
const SkPixmap  src[],
int  numLevels,
const GrBackendTexture backendTexture,
GrSurfaceOrigin  textureOrigin,
sk_sp< skgpu::RefCntedCallback finishedCallback 
)
static

Definition at line 669 of file GrDirectContext.cpp.

674 {
676 const GrBackendFormat& format = backendTexture.getBackendFormat();
677
678 if (!context->priv().caps()->areColorTypeAndFormatCompatible(ct, format)) {
679 return false;
680 }
681
682 auto proxy = context->priv().proxyProvider()->wrapBackendTexture(backendTexture,
686 std::move(finishedCallback));
687 if (!proxy) {
688 return false;
689 }
690
691 skgpu::Swizzle swizzle = context->priv().caps()->getReadSwizzle(format, ct);
692 GrSurfaceProxyView view(std::move(proxy), textureOrigin, swizzle);
693 skgpu::ganesh::SurfaceContext surfaceContext(
694 context, std::move(view), src[0].info().colorInfo());
695 AutoSTArray<15, GrCPixmap> tmpSrc(numLevels);
696 for (int i = 0; i < numLevels; ++i) {
697 tmpSrc[i] = src[i];
698 }
699 if (!surfaceContext.writePixels(context, tmpSrc.get(), numLevels)) {
700 return false;
701 }
702
703 GrSurfaceProxy* p = surfaceContext.asSurfaceProxy();
705 context->priv().drawingManager()->flushSurfaces(
707 return true;
708}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
@ kRW_GrIOType
@ kBorrow_GrWrapOwnership
Definition GrTypesPriv.h:78
GrColorType
static constexpr GrColorType SkColorTypeToGrColorType(SkColorType ct)
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
GrBackendFormat getBackendFormat() const
const GrCaps * caps() const
bool areColorTypeAndFormatCompatible(GrColorType grCT, const GrBackendFormat &format) const
Definition GrCaps.cpp:428
skgpu::Swizzle getReadSwizzle(const GrBackendFormat &format, GrColorType colorType) const
Definition GrCaps.cpp:443
GrSemaphoresSubmitted flushSurfaces(SkSpan< GrSurfaceProxy * >, SkSurfaces::BackendSurfaceAccess, const GrFlushInfo &, const skgpu::MutableTextureState *newState)
sk_sp< GrTextureProxy > wrapBackendTexture(const GrBackendTexture &, GrWrapOwnership, GrWrapCacheable, GrIOType, sk_sp< skgpu::RefCntedCallback >=nullptr)
GrDrawingManager * drawingManager()
GrProxyProvider * proxyProvider()
uint32_t uint32_t * format
@ kNoAccess
back-end surface will not be used by client