Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Namespaces | Functions
SkSurface_Ganesh.cpp File Reference
#include "src/gpu/ganesh/surface/SkSurface_Ganesh.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkColorSpace.h"
#include "include/core/SkColorType.h"
#include "include/core/SkImage.h"
#include "include/core/SkRect.h"
#include "include/core/SkSize.h"
#include "include/core/SkSurface.h"
#include "include/core/SkSurfaceProps.h"
#include "include/gpu/GpuTypes.h"
#include "include/gpu/GrBackendSurface.h"
#include "include/gpu/GrContextThreadSafeProxy.h"
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/GrRecordingContext.h"
#include "include/gpu/GrTypes.h"
#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "include/private/base/SkTo.h"
#include "include/private/chromium/GrDeferredDisplayList.h"
#include "include/private/chromium/GrSurfaceCharacterization.h"
#include "include/private/gpu/ganesh/GrTypesPriv.h"
#include "src/core/SkDevice.h"
#include "src/core/SkSurfacePriv.h"
#include "src/gpu/RefCntedCallback.h"
#include "src/gpu/SkBackingFit.h"
#include "src/gpu/SkRenderEngineAbortf.h"
#include "src/gpu/ganesh/Device.h"
#include "src/gpu/ganesh/GrCaps.h"
#include "src/gpu/ganesh/GrContextThreadSafeProxyPriv.h"
#include "src/gpu/ganesh/GrDirectContextPriv.h"
#include "src/gpu/ganesh/GrGpuResourcePriv.h"
#include "src/gpu/ganesh/GrProxyProvider.h"
#include "src/gpu/ganesh/GrRecordingContextPriv.h"
#include "src/gpu/ganesh/GrRenderTarget.h"
#include "src/gpu/ganesh/GrRenderTargetProxy.h"
#include "src/gpu/ganesh/GrSurfaceProxy.h"
#include "src/gpu/ganesh/GrSurfaceProxyPriv.h"
#include "src/gpu/ganesh/GrSurfaceProxyView.h"
#include "src/gpu/ganesh/GrTexture.h"
#include "src/gpu/ganesh/GrTextureProxy.h"
#include "src/gpu/ganesh/image/SkImage_Ganesh.h"
#include "src/image/SkImage_Base.h"
#include <algorithm>
#include <cstddef>
#include <utility>

Go to the source code of this file.

Namespaces

namespace  SkSurfaces
 
namespace  skgpu
 
namespace  skgpu::ganesh
 

Functions

static GrRenderTargetprepare_rt_for_external_access (SkSurface_Ganesh *surface, SkSurfaces::BackendHandleAccess access)
 
static bool validate_backend_texture (const GrCaps *caps, const GrBackendTexture &tex, int sampleCnt, GrColorType grCT, bool texturable)
 
bool validate_backend_render_target (const GrCaps *caps, const GrBackendRenderTarget &rt, GrColorType grCT)
 
SK_API sk_sp< SkSurfaceSkSurfaces::RenderTarget (GrRecordingContext *context, const GrSurfaceCharacterization &characterization, skgpu::Budgeted budgeted)
 
SK_API sk_sp< SkSurfaceSkSurfaces::RenderTarget (GrRecordingContext *context, skgpu::Budgeted budgeted, const SkImageInfo &imageInfo, int sampleCount, GrSurfaceOrigin surfaceOrigin, const SkSurfaceProps *surfaceProps, bool shouldCreateWithMips=false, bool isProtected=false)
 
SK_API sk_sp< SkSurfaceSkSurfaces::WrapBackendTexture (GrRecordingContext *context, const GrBackendTexture &backendTexture, GrSurfaceOrigin origin, int sampleCnt, SkColorType colorType, sk_sp< SkColorSpace > colorSpace, const SkSurfaceProps *surfaceProps, TextureReleaseProc textureReleaseProc=nullptr, ReleaseContext releaseContext=nullptr)
 
SK_API sk_sp< SkSurfaceSkSurfaces::WrapBackendRenderTarget (GrRecordingContext *context, const GrBackendRenderTarget &backendRenderTarget, GrSurfaceOrigin origin, SkColorType colorType, sk_sp< SkColorSpace > colorSpace, const SkSurfaceProps *surfaceProps, RenderTargetReleaseProc releaseProc=nullptr, ReleaseContext releaseContext=nullptr)
 
SK_API GrBackendTexture SkSurfaces::GetBackendTexture (SkSurface *, BackendHandleAccess)
 
SK_API GrBackendRenderTarget SkSurfaces::GetBackendRenderTarget (SkSurface *, BackendHandleAccess)
 
SK_API void SkSurfaces::ResolveMSAA (SkSurface *surface)
 
SK_API GrSemaphoresSubmitted skgpu::ganesh::Flush (SkSurface *)
 
SK_API GrSemaphoresSubmitted skgpu::ganesh::Flush (sk_sp< SkSurface >)
 
SK_API void skgpu::ganesh::FlushAndSubmit (SkSurface *)
 
SK_API void skgpu::ganesh::FlushAndSubmit (sk_sp< SkSurface >)
 

Function Documentation

◆ prepare_rt_for_external_access()

static GrRenderTarget * prepare_rt_for_external_access ( SkSurface_Ganesh surface,
SkSurfaces::BackendHandleAccess  access 
)
static

Definition at line 85 of file SkSurface_Ganesh.cpp.

86 {
87 auto dContext = surface->recordingContext()->asDirectContext();
88 if (!dContext) {
89 return nullptr;
90 }
91 if (dContext->abandoned()) {
92 return nullptr;
93 }
94
95 switch (access) {
96 case SkSurfaces::BackendHandleAccess::kFlushRead:
97 break;
98 case SkSurfaces::BackendHandleAccess::kFlushWrite:
99 case SkSurfaces::BackendHandleAccess::kDiscardWrite:
100 // for now we don't special-case on Discard, but we may in the future.
101 surface->notifyContentWillChange(SkSurface::kRetain_ContentChangeMode);
102 break;
103 }
104
105 dContext->priv().flushSurface(surface->getDevice()->targetProxy());
106
107 // Grab the render target *after* firing notifications, as it may get switched if CoW kicks in.
108 return surface->getDevice()->targetProxy()->peekRenderTarget();
109}
@ kRetain_ContentChangeMode
preserves surface on change
Definition SkSurface.h:205
VkSurfaceKHR surface
Definition main.cc:49

◆ validate_backend_render_target()

bool validate_backend_render_target ( const GrCaps caps,
const GrBackendRenderTarget rt,
GrColorType  grCT 
)

Definition at line 532 of file SkSurface_Ganesh.cpp.

534 {
535 if (!caps->areColorTypeAndFormatCompatible(grCT, rt.getBackendFormat())) {
536 return false;
537 }
538
539 if (!caps->isFormatAsColorTypeRenderable(grCT, rt.getBackendFormat(), rt.sampleCnt())) {
540 return false;
541 }
542
543 // We require the stencil bits to be either 0, 8, or 16.
544 int stencilBits = rt.stencilBits();
545 if (stencilBits != 0 && stencilBits != 8 && stencilBits != 16) {
546 return false;
547 }
548
549 return true;
550}
GrBackendFormat getBackendFormat() const
bool areColorTypeAndFormatCompatible(GrColorType grCT, const GrBackendFormat &format) const
Definition GrCaps.cpp:428
virtual bool isFormatAsColorTypeRenderable(GrColorType ct, const GrBackendFormat &format, int sampleCount=1) const =0

◆ validate_backend_texture()

static bool validate_backend_texture ( const GrCaps caps,
const GrBackendTexture tex,
int  sampleCnt,
GrColorType  grCT,
bool  texturable 
)
static

Definition at line 428 of file SkSurface_Ganesh.cpp.

432 {
433 if (!tex.isValid()) {
434 return false;
435 }
436
437 GrBackendFormat backendFormat = tex.getBackendFormat();
438 if (!backendFormat.isValid()) {
439 RENDERENGINE_ABORTF("%s failed due to an invalid format", __func__);
440 return false;
441 }
442
443 if (!caps->areColorTypeAndFormatCompatible(grCT, backendFormat)) {
444 RENDERENGINE_ABORTF("%s failed due to an invalid format and colorType combination",
445 __func__);
446 return false;
447 }
448
449 if (!caps->isFormatAsColorTypeRenderable(grCT, backendFormat, sampleCnt)) {
451 "%s failed due to no supported rendering path for the selected "
452 "format and colorType",
453 __func__);
454 return false;
455 }
456
457 if (texturable && !caps->isFormatTexturable(backendFormat, tex.textureType())) {
459 "%s failed due to no texturing support for the selected format and "
460 "colorType",
461 __func__);
462 return false;
463 }
464
465 return true;
466}
#define RENDERENGINE_ABORTF(...)
bool isValid() const
GrBackendFormat getBackendFormat() const
GrTextureType textureType() const
virtual bool isFormatTexturable(const GrBackendFormat &, GrTextureType) const =0