Remove more GrContext imports & usage

Sanity is coming soon!

Change-Id: I109ebeef9efd7dbf4d76a13e1c05df36d59affbc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/303661
Commit-Queue: Adlai Holler <adlai@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Adlai Holler 2020-07-20 10:27:41 -04:00 committed by Skia Commit-Bot
parent c59916a5cc
commit dd1395526d
41 changed files with 73 additions and 91 deletions

View File

@ -20,7 +20,6 @@
#include "include/core/SkSize.h" #include "include/core/SkSize.h"
#include "include/core/SkString.h" #include "include/core/SkString.h"
#include "include/core/SkTypes.h" #include "include/core/SkTypes.h"
#include "include/gpu/GrContext.h"
#include "include/gpu/GrRecordingContext.h" #include "include/gpu/GrRecordingContext.h"
#include "include/private/GrSharedEnums.h" #include "include/private/GrSharedEnums.h"
#include "include/private/GrTypesPriv.h" #include "include/private/GrTypesPriv.h"

View File

@ -17,7 +17,6 @@
#include "include/core/SkSize.h" #include "include/core/SkSize.h"
#include "include/core/SkString.h" #include "include/core/SkString.h"
#include "include/core/SkTypes.h" #include "include/core/SkTypes.h"
#include "include/gpu/GrContext.h"
#include "include/private/GrSharedEnums.h" #include "include/private/GrSharedEnums.h"
#include "include/private/GrTypesPriv.h" #include "include/private/GrTypesPriv.h"
#include "src/gpu/GrCaps.h" #include "src/gpu/GrCaps.h"

View File

@ -11,7 +11,6 @@
#include "include/core/SkColor.h" #include "include/core/SkColor.h"
#include "include/core/SkRect.h" #include "include/core/SkRect.h"
#include "include/core/SkTypes.h" #include "include/core/SkTypes.h"
#include "include/gpu/GrContext.h"
#include "include/gpu/GrDirectContext.h" #include "include/gpu/GrDirectContext.h"
#include "include/gpu/GrRecordingContext.h" #include "include/gpu/GrRecordingContext.h"

View File

@ -16,7 +16,6 @@
#include "include/core/SkSize.h" #include "include/core/SkSize.h"
#include "include/core/SkString.h" #include "include/core/SkString.h"
#include "include/core/SkTypes.h" #include "include/core/SkTypes.h"
#include "include/gpu/GrContext.h"
#include "include/gpu/GrRecordingContext.h" #include "include/gpu/GrRecordingContext.h"
#include "include/gpu/GrTypes.h" #include "include/gpu/GrTypes.h"
#include "include/private/GrTypesPriv.h" #include "include/private/GrTypesPriv.h"

View File

@ -26,7 +26,6 @@
#include "include/core/SkTypes.h" #include "include/core/SkTypes.h"
#include "include/effects/SkGradientShader.h" #include "include/effects/SkGradientShader.h"
#include "include/gpu/GrConfig.h" #include "include/gpu/GrConfig.h"
#include "include/gpu/GrContext.h"
#include "include/private/GrTypesPriv.h" #include "include/private/GrTypesPriv.h"
#include "include/private/SkColorData.h" #include "include/private/SkColorData.h"
#include "src/core/SkMatrixProvider.h" #include "src/core/SkMatrixProvider.h"

View File

@ -18,7 +18,6 @@
#include "include/core/SkScalar.h" #include "include/core/SkScalar.h"
#include "include/core/SkSize.h" #include "include/core/SkSize.h"
#include "include/core/SkString.h" #include "include/core/SkString.h"
#include "include/gpu/GrContext.h"
#include "include/private/GrSharedEnums.h" #include "include/private/GrSharedEnums.h"
#include "include/private/GrTypesPriv.h" #include "include/private/GrTypesPriv.h"
#include "src/core/SkTLList.h" #include "src/core/SkTLList.h"

View File

@ -16,7 +16,6 @@
#include "include/core/SkString.h" #include "include/core/SkString.h"
#include "include/core/SkSurface.h" #include "include/core/SkSurface.h"
#include "include/core/SkTypes.h" #include "include/core/SkTypes.h"
#include "include/gpu/GrContext.h"
#include "include/gpu/GrDirectContext.h" #include "include/gpu/GrDirectContext.h"
#include "include/gpu/GrRecordingContext.h" #include "include/gpu/GrRecordingContext.h"
#include "include/utils/SkRandom.h" #include "include/utils/SkRandom.h"

View File

@ -28,7 +28,6 @@
#include "include/core/SkTextBlob.h" #include "include/core/SkTextBlob.h"
#include "include/core/SkTypeface.h" #include "include/core/SkTypeface.h"
#include "include/core/SkTypes.h" #include "include/core/SkTypes.h"
#include "include/gpu/GrContext.h"
#include "include/gpu/GrContextOptions.h" #include "include/gpu/GrContextOptions.h"
#include "include/gpu/GrDirectContext.h" #include "include/gpu/GrDirectContext.h"
#include "include/gpu/GrRecordingContext.h" #include "include/gpu/GrRecordingContext.h"

View File

@ -17,7 +17,6 @@
#include "include/core/SkString.h" #include "include/core/SkString.h"
#include "include/core/SkTileMode.h" #include "include/core/SkTileMode.h"
#include "include/core/SkTypes.h" #include "include/core/SkTypes.h"
#include "include/gpu/GrContext.h"
#include "src/gpu/GrBitmapTextureMaker.h" #include "src/gpu/GrBitmapTextureMaker.h"
#include "src/gpu/GrCaps.h" #include "src/gpu/GrCaps.h"
#include "src/gpu/GrContextPriv.h" #include "src/gpu/GrContextPriv.h"

View File

@ -14,7 +14,6 @@
#include "include/core/SkRect.h" #include "include/core/SkRect.h"
#include "include/core/SkRefCnt.h" #include "include/core/SkRefCnt.h"
#include "include/core/SkString.h" #include "include/core/SkString.h"
#include "include/gpu/GrContext.h"
#include "include/gpu/GrRecordingContext.h" #include "include/gpu/GrRecordingContext.h"
#include "include/private/GrTypesPriv.h" #include "include/private/GrTypesPriv.h"
#include "src/gpu/GrBuffer.h" #include "src/gpu/GrBuffer.h"

View File

@ -25,7 +25,7 @@
#include "include/core/SkString.h" #include "include/core/SkString.h"
#include "include/core/SkSurface.h" #include "include/core/SkSurface.h"
#include "include/core/SkTypes.h" #include "include/core/SkTypes.h"
#include "include/gpu/GrContext.h" #include "include/gpu/GrDirectContext.h"
#include "include/gpu/GrRecordingContext.h" #include "include/gpu/GrRecordingContext.h"
#include "include/gpu/GrTypes.h" #include "include/gpu/GrTypes.h"
#include "include/private/GrTypesPriv.h" #include "include/private/GrTypesPriv.h"
@ -289,11 +289,10 @@ protected:
return; return;
} }
// CONTEXT TODO: remove this use of the 'backdoor' to create an image auto dContext = GrAsDirectContext(canvas->recordingContext());
GrContext* tmp = canvas->recordingContext()->priv().backdoor();
// No API to draw a GrTexture directly, so we cheat and create a private image subclass // No API to draw a GrTexture directly, so we cheat and create a private image subclass
sk_sp<SkImage> texImage(new SkImage_Gpu(sk_ref_sp(tmp), sk_sp<SkImage> texImage(new SkImage_Gpu(sk_ref_sp(dContext),
image->uniqueID(), std::move(view), image->uniqueID(), std::move(view),
image->colorType(), image->alphaType(), image->colorType(), image->alphaType(),
image->refColorSpace())); image->refColorSpace()));

View File

@ -8,7 +8,6 @@
#include "gm/gm.h" #include "gm/gm.h"
#include "include/core/SkPath.h" #include "include/core/SkPath.h"
#include "include/gpu/GrContext.h"
#include "include/gpu/GrContextOptions.h" #include "include/gpu/GrContextOptions.h"
#include "include/gpu/GrRecordingContext.h" #include "include/gpu/GrRecordingContext.h"
#include "src/gpu/GrContextPriv.h" #include "src/gpu/GrContextPriv.h"

View File

@ -15,7 +15,6 @@
#include "include/core/SkSize.h" #include "include/core/SkSize.h"
#include "include/core/SkString.h" #include "include/core/SkString.h"
#include "include/core/SkTypes.h" #include "include/core/SkTypes.h"
#include "include/gpu/GrContext.h"
#include "include/gpu/GrRecordingContext.h" #include "include/gpu/GrRecordingContext.h"
#include "include/gpu/GrTypes.h" #include "include/gpu/GrTypes.h"
#include "include/private/GrTypesPriv.h" #include "include/private/GrTypesPriv.h"

View File

@ -11,7 +11,6 @@
#include "include/core/SkMatrix.h" #include "include/core/SkMatrix.h"
#include "include/core/SkRect.h" #include "include/core/SkRect.h"
#include "include/core/SkTypes.h" #include "include/core/SkTypes.h"
#include "include/gpu/GrContext.h"
#include "src/gpu/GrBitmapTextureMaker.h" #include "src/gpu/GrBitmapTextureMaker.h"
#include "src/gpu/GrContextPriv.h" #include "src/gpu/GrContextPriv.h"
#include "src/gpu/GrFragmentProcessor.h" #include "src/gpu/GrFragmentProcessor.h"

View File

@ -21,7 +21,6 @@
#include "include/core/SkString.h" #include "include/core/SkString.h"
#include "include/core/SkTypes.h" #include "include/core/SkTypes.h"
#include "include/core/SkYUVAIndex.h" #include "include/core/SkYUVAIndex.h"
#include "include/gpu/GrContext.h"
#include "include/private/GrTypesPriv.h" #include "include/private/GrTypesPriv.h"
#include "src/gpu/GrBitmapTextureMaker.h" #include "src/gpu/GrBitmapTextureMaker.h"
#include "src/gpu/GrContextPriv.h" #include "src/gpu/GrContextPriv.h"

View File

@ -50,7 +50,6 @@
#include <new> #include <new>
#if SK_SUPPORT_GPU #if SK_SUPPORT_GPU
#include "include/gpu/GrContext.h"
#include "src/gpu/SkGr.h" #include "src/gpu/SkGr.h"
#endif #endif

View File

@ -22,7 +22,6 @@
#include "src/core/SkValidationUtils.h" #include "src/core/SkValidationUtils.h"
#include "src/core/SkWriteBuffer.h" #include "src/core/SkWriteBuffer.h"
#if SK_SUPPORT_GPU #if SK_SUPPORT_GPU
#include "include/gpu/GrContext.h"
#include "include/gpu/GrRecordingContext.h" #include "include/gpu/GrRecordingContext.h"
#include "src/gpu/GrColorSpaceXform.h" #include "src/gpu/GrColorSpaceXform.h"
#include "src/gpu/GrContextPriv.h" #include "src/gpu/GrContextPriv.h"

View File

@ -73,7 +73,7 @@ extern const SkPixelRef* SkBitmapImageGetPixelRef(const SkImage* rasterImage);
* *
* @return true if the image was successfully uploaded and locked into a texture * @return true if the image was successfully uploaded and locked into a texture
*/ */
bool SkImage_pinAsTexture(const SkImage*, GrContext*); bool SkImage_pinAsTexture(const SkImage*, GrRecordingContext*);
/** /**
* The balancing call to a successful invokation of SkImage_pinAsTexture. When a balanced number of * The balancing call to a successful invokation of SkImage_pinAsTexture. When a balanced number of
@ -83,7 +83,7 @@ bool SkImage_pinAsTexture(const SkImage*, GrContext*);
* *
* The context passed to unpin must match the one passed to pin. * The context passed to unpin must match the one passed to pin.
*/ */
void SkImage_unpinAsTexture(const SkImage*, GrContext*); void SkImage_unpinAsTexture(const SkImage*, GrRecordingContext*);
/** /**
* Returns the bounds of the image relative to its encoded buffer. For all non-lazy images, * Returns the bounds of the image relative to its encoded buffer. For all non-lazy images,

View File

@ -20,10 +20,6 @@
#include <new> #include <new>
#if SK_SUPPORT_GPU
#include "include/gpu/GrContext.h"
#endif
template <typename T> int SafeCount(const T* obj) { template <typename T> int SafeCount(const T* obj) {
return obj ? obj->count() : 0; return obj ? obj->count() : 0;
} }

View File

@ -15,9 +15,8 @@
#include "src/image/SkImage_Base.h" #include "src/image/SkImage_Base.h"
#if SK_SUPPORT_GPU #if SK_SUPPORT_GPU
#include "include/gpu/GrContext.h" #include "include/gpu/GrDirectContext.h"
#include "include/gpu/GrRecordingContext.h" #include "include/gpu/GrRecordingContext.h"
#include "src/gpu/GrContextPriv.h"
#include "src/gpu/GrImageInfo.h" #include "src/gpu/GrImageInfo.h"
#include "src/gpu/GrProxyProvider.h" #include "src/gpu/GrProxyProvider.h"
#include "src/gpu/GrRecordingContextPriv.h" #include "src/gpu/GrRecordingContextPriv.h"

View File

@ -18,7 +18,6 @@
#include "src/core/SkWriteBuffer.h" #include "src/core/SkWriteBuffer.h"
#if SK_SUPPORT_GPU #if SK_SUPPORT_GPU
#include "include/gpu/GrContext.h"
#include "src/gpu/GrColorInfo.h" #include "src/gpu/GrColorInfo.h"
#include "src/gpu/effects/generated/GrHighContrastFilterEffect.h" #include "src/gpu/effects/generated/GrHighContrastFilterEffect.h"
#include "src/gpu/glsl/GrGLSLFragmentProcessor.h" #include "src/gpu/glsl/GrGLSLFragmentProcessor.h"

View File

@ -14,7 +14,6 @@
#include "src/core/SkVM.h" #include "src/core/SkVM.h"
#if SK_SUPPORT_GPU #if SK_SUPPORT_GPU
#include "include/gpu/GrContext.h"
#include "src/gpu/effects/generated/GrLumaColorFilterEffect.h" #include "src/gpu/effects/generated/GrLumaColorFilterEffect.h"
#include "src/gpu/glsl/GrGLSLFragmentProcessor.h" #include "src/gpu/glsl/GrGLSLFragmentProcessor.h"
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h" #include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"

View File

@ -344,7 +344,6 @@ GR_DEFINE_FRAGMENT_PROCESSOR_TEST(ColorTableEffect);
#if GR_TEST_UTILS #if GR_TEST_UTILS
#include "include/gpu/GrContext.h"
std::unique_ptr<GrFragmentProcessor> ColorTableEffect::TestCreate(GrProcessorTestData* d) { std::unique_ptr<GrFragmentProcessor> ColorTableEffect::TestCreate(GrProcessorTestData* d) {
int flags = 0; int flags = 0;

View File

@ -15,7 +15,6 @@
#include "src/core/SkWriteBuffer.h" #include "src/core/SkWriteBuffer.h"
#if SK_SUPPORT_GPU #if SK_SUPPORT_GPU
#include "include/gpu/GrContext.h"
#include "include/gpu/GrRecordingContext.h" #include "include/gpu/GrRecordingContext.h"
#include "src/gpu/GrCaps.h" #include "src/gpu/GrCaps.h"
#include "src/gpu/GrColorSpaceXform.h" #include "src/gpu/GrColorSpaceXform.h"

View File

@ -24,7 +24,6 @@
#include "src/core/SkWriteBuffer.h" #include "src/core/SkWriteBuffer.h"
#if SK_SUPPORT_GPU #if SK_SUPPORT_GPU
#include "include/gpu/GrContext.h"
#include "src/gpu/GrTextureProxy.h" #include "src/gpu/GrTextureProxy.h"
#include "src/gpu/SkGr.h" #include "src/gpu/SkGr.h"
#endif #endif

View File

@ -17,7 +17,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#if SK_SUPPORT_GPU #if SK_SUPPORT_GPU
#include "include/gpu/GrContext.h"
#include "src/gpu/GrColorSpaceXform.h" #include "src/gpu/GrColorSpaceXform.h"
#include "src/gpu/effects/GrTextureEffect.h" #include "src/gpu/effects/GrTextureEffect.h"
#include "src/gpu/effects/generated/GrMagnifierEffect.h" #include "src/gpu/effects/generated/GrMagnifierEffect.h"

View File

@ -19,7 +19,6 @@
#include "src/gpu/SkGr.h" #include "src/gpu/SkGr.h"
#if SK_SUPPORT_GPU #if SK_SUPPORT_GPU
#include "include/gpu/GrContext.h"
#include "src/gpu/GrRecordingContextPriv.h" #include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/GrTextureProxy.h" #include "src/gpu/GrTextureProxy.h"
#include "src/gpu/effects/GrMatrixConvolutionEffect.h" #include "src/gpu/effects/GrMatrixConvolutionEffect.h"

View File

@ -16,7 +16,6 @@
#include "src/core/SkWriteBuffer.h" #include "src/core/SkWriteBuffer.h"
#if SK_SUPPORT_GPU #if SK_SUPPORT_GPU
#include "include/gpu/GrContext.h"
#include "include/gpu/GrRecordingContext.h" #include "include/gpu/GrRecordingContext.h"
#include "src/gpu/GrContextPriv.h" #include "src/gpu/GrContextPriv.h"
#include "src/gpu/GrRecordingContextPriv.h" #include "src/gpu/GrRecordingContextPriv.h"

View File

@ -19,7 +19,7 @@
#include <GLES/gl.h> #include <GLES/gl.h>
#include <GLES/glext.h> #include <GLES/glext.h>
#include "include/gpu/GrContext.h" #include "include/gpu/GrDirectContext.h"
#include "include/gpu/gl/GrGLTypes.h" #include "include/gpu/gl/GrGLTypes.h"
#include "src/gpu/GrContextPriv.h" #include "src/gpu/GrContextPriv.h"
#include "src/gpu/gl/GrGLDefines.h" #include "src/gpu/gl/GrGLDefines.h"
@ -62,7 +62,13 @@ SkColorType GetSkColorTypeFromBufferFormat(uint32_t bufferFormat) {
GrBackendFormat GetBackendFormat(GrContext* context, AHardwareBuffer* hardwareBuffer, GrBackendFormat GetBackendFormat(GrContext* context, AHardwareBuffer* hardwareBuffer,
uint32_t bufferFormat, bool requireKnownFormat) { uint32_t bufferFormat, bool requireKnownFormat) {
GrBackendApi backend = context->backend(); // CONTEXT TODO: Elevate direct context requirement to Android API.
auto dContext = GrAsDirectContext(context);
if (!dContext) {
SkDEBUGFAIL("Requires direct context.");
return GrBackendFormat();
}
GrBackendApi backend = dContext->backend();
if (backend == GrBackendApi::kOpenGL) { if (backend == GrBackendApi::kOpenGL) {
switch (bufferFormat) { switch (bufferFormat) {
@ -104,7 +110,7 @@ GrBackendFormat GetBackendFormat(GrContext* context, AHardwareBuffer* hardwareBu
if (requireKnownFormat) { if (requireKnownFormat) {
return GrBackendFormat(); return GrBackendFormat();
} else { } else {
GrVkGpu* gpu = static_cast<GrVkGpu*>(context->priv().getGpu()); GrVkGpu* gpu = static_cast<GrVkGpu*>(dContext->priv().getGpu());
SkASSERT(gpu); SkASSERT(gpu);
VkDevice device = gpu->device(); VkDevice device = gpu->device();
@ -169,7 +175,7 @@ public:
// eglDestroyImageKHR will remove a ref from the AHardwareBuffer // eglDestroyImageKHR will remove a ref from the AHardwareBuffer
eglDestroyImageKHR(fDisplay, fImage); eglDestroyImageKHR(fDisplay, fImage);
} }
void rebind(GrContext* grContext); void rebind(GrDirectContext*);
private: private:
GrGLuint fTexID; GrGLuint fTexID;
@ -178,7 +184,7 @@ private:
GrGLuint fTexTarget; GrGLuint fTexTarget;
}; };
void GLTextureHelper::rebind(GrContext* grContext) { void GLTextureHelper::rebind(GrDirectContext* dContext) {
glBindTexture(fTexTarget, fTexID); glBindTexture(fTexTarget, fTexID);
GLenum status = GL_NO_ERROR; GLenum status = GL_NO_ERROR;
if ((status = glGetError()) != GL_NO_ERROR) { if ((status = glGetError()) != GL_NO_ERROR) {
@ -191,7 +197,7 @@ void GLTextureHelper::rebind(GrContext* grContext) {
SkDebugf("glEGLImageTargetTexture2DOES failed (%#x)", (int) status); SkDebugf("glEGLImageTargetTexture2DOES failed (%#x)", (int) status);
return; return;
} }
grContext->resetContext(kTextureBinding_GrGLBackendState); dContext->resetContext(kTextureBinding_GrGLBackendState);
} }
void delete_gl_texture(void* context) { void delete_gl_texture(void* context) {
@ -200,12 +206,18 @@ void delete_gl_texture(void* context) {
} }
void update_gl_texture(void* context, GrContext* grContext) { void update_gl_texture(void* context, GrContext* grContext) {
// CONTEXT TODO: Elevate direct context requirement to Android API.
auto dContext = GrAsDirectContext(grContext);
if (!dContext) {
SkDEBUGFAIL("Direct context required.");
return;
}
GLTextureHelper* cleanupHelper = static_cast<GLTextureHelper*>(context); GLTextureHelper* cleanupHelper = static_cast<GLTextureHelper*>(context);
cleanupHelper->rebind(grContext); cleanupHelper->rebind(dContext);
} }
static GrBackendTexture make_gl_backend_texture( static GrBackendTexture make_gl_backend_texture(
GrContext* context, AHardwareBuffer* hardwareBuffer, GrDirectContext* dContext, AHardwareBuffer* hardwareBuffer,
int width, int height, int width, int height,
DeleteImageProc* deleteProc, DeleteImageProc* deleteProc,
UpdateImageProc* updateProc, UpdateImageProc* updateProc,
@ -253,7 +265,7 @@ static GrBackendTexture make_gl_backend_texture(
eglDestroyImageKHR(display, image); eglDestroyImageKHR(display, image);
return GrBackendTexture(); return GrBackendTexture();
} }
context->resetContext(kTextureBinding_GrGLBackendState); dContext->resetContext(kTextureBinding_GrGLBackendState);
GrGLTextureInfo textureInfo; GrGLTextureInfo textureInfo;
textureInfo.fID = texID; textureInfo.fID = texID;
@ -295,11 +307,13 @@ void delete_vk_image(void* context) {
} }
void update_vk_image(void* context, GrContext* grContext) { void update_vk_image(void* context, GrContext* grContext) {
// CONTEXT TODO: Elevate direct context requirement to Android API.
SkASSERT(GrAsDirectContext(grContext));
// no op // no op
} }
static GrBackendTexture make_vk_backend_texture( static GrBackendTexture make_vk_backend_texture(
GrContext* context, AHardwareBuffer* hardwareBuffer, GrDirectContext* dContext, AHardwareBuffer* hardwareBuffer,
int width, int height, int width, int height,
DeleteImageProc* deleteProc, DeleteImageProc* deleteProc,
UpdateImageProc* updateProc, UpdateImageProc* updateProc,
@ -307,8 +321,8 @@ static GrBackendTexture make_vk_backend_texture(
bool isProtectedContent, bool isProtectedContent,
const GrBackendFormat& backendFormat, const GrBackendFormat& backendFormat,
bool isRenderable) { bool isRenderable) {
SkASSERT(context->backend() == GrBackendApi::kVulkan); SkASSERT(dContext->backend() == GrBackendApi::kVulkan);
GrVkGpu* gpu = static_cast<GrVkGpu*>(context->priv().getGpu()); GrVkGpu* gpu = static_cast<GrVkGpu*>(dContext->priv().getGpu());
VkPhysicalDevice physicalDevice = gpu->physicalDevice(); VkPhysicalDevice physicalDevice = gpu->physicalDevice();
VkDevice device = gpu->device(); VkDevice device = gpu->device();
@ -510,8 +524,8 @@ static bool can_import_protected_content_eglimpl() {
return equal || atStart || atEnd || inMiddle; return equal || atStart || atEnd || inMiddle;
} }
static bool can_import_protected_content(GrContext* context) { static bool can_import_protected_content(GrDirectContext* dContext) {
if (GrBackendApi::kOpenGL == context->backend()) { if (GrBackendApi::kOpenGL == dContext->backend()) {
// Only compute whether the extension is present once the first time this // Only compute whether the extension is present once the first time this
// function is called. // function is called.
static bool hasIt = can_import_protected_content_eglimpl(); static bool hasIt = can_import_protected_content_eglimpl();
@ -528,21 +542,24 @@ GrBackendTexture MakeBackendTexture(GrContext* context, AHardwareBuffer* hardwar
bool isProtectedContent, bool isProtectedContent,
const GrBackendFormat& backendFormat, const GrBackendFormat& backendFormat,
bool isRenderable) { bool isRenderable) {
if (context->abandoned()) { // CONTEXT TODO: Elevate direct context requirement to Android API.
auto dContext = GrAsDirectContext(context);
SkASSERT(dContext);
if (!dContext || dContext->abandoned()) {
return GrBackendTexture(); return GrBackendTexture();
} }
bool createProtectedImage = isProtectedContent && can_import_protected_content(context); bool createProtectedImage = isProtectedContent && can_import_protected_content(dContext);
if (GrBackendApi::kOpenGL == context->backend()) { if (GrBackendApi::kOpenGL == dContext->backend()) {
return make_gl_backend_texture(context, hardwareBuffer, width, height, deleteProc, return make_gl_backend_texture(dContext, hardwareBuffer, width, height, deleteProc,
updateProc, imageCtx, createProtectedImage, backendFormat, updateProc, imageCtx, createProtectedImage, backendFormat,
isRenderable); isRenderable);
} else { } else {
SkASSERT(GrBackendApi::kVulkan == context->backend()); SkASSERT(GrBackendApi::kVulkan == dContext->backend());
#ifdef SK_VULKAN #ifdef SK_VULKAN
// Currently we don't support protected images on vulkan // Currently we don't support protected images on vulkan
SkASSERT(!createProtectedImage); SkASSERT(!createProtectedImage);
return make_vk_backend_texture(context, hardwareBuffer, width, height, deleteProc, return make_vk_backend_texture(dContext, hardwareBuffer, width, height, deleteProc,
updateProc, imageCtx, createProtectedImage, backendFormat, updateProc, imageCtx, createProtectedImage, backendFormat,
isRenderable); isRenderable);
#else #else

View File

@ -7,7 +7,6 @@
#include "include/gpu/GrRecordingContext.h" #include "include/gpu/GrRecordingContext.h"
#include "include/gpu/GrContext.h"
#include "include/gpu/GrContextThreadSafeProxy.h" #include "include/gpu/GrContextThreadSafeProxy.h"
#include "src/core/SkArenaAlloc.h" #include "src/core/SkArenaAlloc.h"
#include "src/gpu/GrAuditTrail.h" #include "src/gpu/GrAuditTrail.h"

View File

@ -617,16 +617,16 @@ sk_sp<SkImage> SkImage::MakeFromNV12TexturesCopyWithExternalBackend(
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
bool SkImage_pinAsTexture(const SkImage* image, GrContext* ctx) { bool SkImage_pinAsTexture(const SkImage* image, GrRecordingContext* rContext) {
SkASSERT(image); SkASSERT(image);
SkASSERT(ctx); SkASSERT(rContext);
return as_IB(image)->onPinAsTexture(ctx); return as_IB(image)->onPinAsTexture(rContext);
} }
void SkImage_unpinAsTexture(const SkImage* image, GrContext* ctx) { void SkImage_unpinAsTexture(const SkImage* image, GrRecordingContext* rContext) {
SkASSERT(image); SkASSERT(image);
SkASSERT(ctx); SkASSERT(rContext);
as_IB(image)->onUnpinAsTexture(ctx); as_IB(image)->onUnpinAsTexture(rContext);
} }
SkIRect SkImage_getSubset(const SkImage* image) { SkIRect SkImage_getSubset(const SkImage* image) {

View File

@ -127,8 +127,8 @@ public:
virtual bool onIsValid(GrRecordingContext*) const = 0; virtual bool onIsValid(GrRecordingContext*) const = 0;
virtual bool onPinAsTexture(GrContext*) const { return false; } virtual bool onPinAsTexture(GrRecordingContext*) const { return false; }
virtual void onUnpinAsTexture(GrContext*) const {} virtual void onUnpinAsTexture(GrRecordingContext*) const {}
virtual sk_sp<SkImage> onMakeColorTypeAndColorSpace(SkColorType, sk_sp<SkColorSpace>, virtual sk_sp<SkImage> onMakeColorTypeAndColorSpace(SkColorType, sk_sp<SkColorSpace>,
GrDirectContext*) const = 0; GrDirectContext*) const = 0;

View File

@ -9,7 +9,6 @@
#include "include/core/SkPromiseImageTexture.h" #include "include/core/SkPromiseImageTexture.h"
#include "include/gpu/GrBackendSurface.h" #include "include/gpu/GrBackendSurface.h"
#include "include/gpu/GrContext.h"
#include "include/gpu/GrDirectContext.h" #include "include/gpu/GrDirectContext.h"
#include "include/gpu/GrRecordingContext.h" #include "include/gpu/GrRecordingContext.h"
#include "src/core/SkBitmapCache.h" #include "src/core/SkBitmapCache.h"

View File

@ -20,7 +20,6 @@
#include "src/shaders/SkBitmapProcShader.h" #include "src/shaders/SkBitmapProcShader.h"
#if SK_SUPPORT_GPU #if SK_SUPPORT_GPU
#include "include/gpu/GrContext.h"
#include "src/gpu/GrTextureAdjuster.h" #include "src/gpu/GrTextureAdjuster.h"
#include "src/gpu/SkGr.h" #include "src/gpu/SkGr.h"
#endif #endif
@ -119,8 +118,8 @@ public:
#if SK_SUPPORT_GPU #if SK_SUPPORT_GPU
GrSurfaceProxyView refPinnedView(GrRecordingContext* context, GrSurfaceProxyView refPinnedView(GrRecordingContext* context,
uint32_t* uniqueID) const override; uint32_t* uniqueID) const override;
bool onPinAsTexture(GrContext*) const override; bool onPinAsTexture(GrRecordingContext*) const override;
void onUnpinAsTexture(GrContext*) const override; void onUnpinAsTexture(GrRecordingContext*) const override;
#endif #endif
SkMipmap* onPeekMips() const override { return fBitmap.fMips.get(); } SkMipmap* onPeekMips() const override { return fBitmap.fMips.get(); }
@ -214,14 +213,14 @@ GrSurfaceProxyView SkImage_Raster::refPinnedView(GrRecordingContext*, uint32_t*
return {}; return {};
} }
bool SkImage_Raster::onPinAsTexture(GrContext* ctx) const { bool SkImage_Raster::onPinAsTexture(GrRecordingContext* rContext) const {
if (fPinnedView) { if (fPinnedView) {
SkASSERT(fPinnedCount > 0); SkASSERT(fPinnedCount > 0);
SkASSERT(fPinnedUniqueID != 0); SkASSERT(fPinnedUniqueID != 0);
} else { } else {
SkASSERT(fPinnedCount == 0); SkASSERT(fPinnedCount == 0);
SkASSERT(fPinnedUniqueID == 0); SkASSERT(fPinnedUniqueID == 0);
fPinnedView = GrRefCachedBitmapView(ctx, fBitmap, GrMipMapped::kNo); fPinnedView = GrRefCachedBitmapView(rContext, fBitmap, GrMipMapped::kNo);
if (!fPinnedView) { if (!fPinnedView) {
return false; return false;
} }
@ -233,7 +232,7 @@ bool SkImage_Raster::onPinAsTexture(GrContext* ctx) const {
return true; return true;
} }
void SkImage_Raster::onUnpinAsTexture(GrContext* ctx) const { void SkImage_Raster::onUnpinAsTexture(GrRecordingContext*) const {
// Note: we always decrement, even if fPinnedTexture is null // Note: we always decrement, even if fPinnedTexture is null
SkASSERT(fPinnedCount > 0); SkASSERT(fPinnedCount > 0);
SkASSERT(fPinnedUniqueID != 0); SkASSERT(fPinnedUniqueID != 0);

View File

@ -8,7 +8,6 @@
#include "include/core/SkRefCnt.h" #include "include/core/SkRefCnt.h"
#include "include/core/SkSurface.h" #include "include/core/SkSurface.h"
#include "include/gpu/GrBackendSurface.h" #include "include/gpu/GrBackendSurface.h"
#include "include/gpu/GrContext.h"
#include "include/gpu/mtl/GrMtlTypes.h" #include "include/gpu/mtl/GrMtlTypes.h"
#include "src/gpu/GrContextPriv.h" #include "src/gpu/GrContextPriv.h"
#include "src/gpu/GrProxyProvider.h" #include "src/gpu/GrProxyProvider.h"

View File

@ -89,7 +89,6 @@ skvm::Color SkColorFilterShader::onProgram(skvm::Builder* p,
#if SK_SUPPORT_GPU #if SK_SUPPORT_GPU
///////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////
#include "include/gpu/GrContext.h"
std::unique_ptr<GrFragmentProcessor> SkColorFilterShader::asFragmentProcessor( std::unique_ptr<GrFragmentProcessor> SkColorFilterShader::asFragmentProcessor(
const GrFPArgs& args) const { const GrFPArgs& args) const {

View File

@ -22,6 +22,7 @@
#include <atomic> #include <atomic>
#if SK_SUPPORT_GPU #if SK_SUPPORT_GPU
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/GrRecordingContext.h" #include "include/gpu/GrRecordingContext.h"
#include "src/gpu/GrCaps.h" #include "src/gpu/GrCaps.h"
#include "src/gpu/GrColorInfo.h" #include "src/gpu/GrColorInfo.h"
@ -342,8 +343,6 @@ void SkPictureShader::PictureShaderContext::shadeSpan(int x, int y, SkPMColor ds
} }
#if SK_SUPPORT_GPU #if SK_SUPPORT_GPU
#include "include/gpu/GrContext.h"
#include "src/gpu/GrContextPriv.h"
std::unique_ptr<GrFragmentProcessor> SkPictureShader::asFragmentProcessor( std::unique_ptr<GrFragmentProcessor> SkPictureShader::asFragmentProcessor(
const GrFPArgs& args) const { const GrFPArgs& args) const {

View File

@ -28,6 +28,7 @@
#include "tests/Test.h" #include "tests/Test.h"
#include "src/gpu/GrContextPriv.h"
#include "src/gpu/text/GrAtlasManager.h" #include "src/gpu/text/GrAtlasManager.h"
#include "src/gpu/text/GrTextBlobCache.h" #include "src/gpu/text/GrTextBlobCache.h"

View File

@ -16,7 +16,6 @@
#include "tools/debugger/DebugLayerManager.h" #include "tools/debugger/DebugLayerManager.h"
#include "tools/debugger/DrawCommand.h" #include "tools/debugger/DrawCommand.h"
#include "include/gpu/GrContext.h"
#include "src/gpu/GrAuditTrail.h" #include "src/gpu/GrAuditTrail.h"
#include "src/gpu/GrRecordingContextPriv.h" #include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/GrRenderTargetContext.h" #include "src/gpu/GrRenderTargetContext.h"

View File

@ -10,26 +10,26 @@
#include "include/core/SkImage.h" #include "include/core/SkImage.h"
#include "include/core/SkPixmap.h" #include "include/core/SkPixmap.h"
#include "include/gpu/GrBackendSurface.h" #include "include/gpu/GrBackendSurface.h"
#include "include/gpu/GrContext.h" #include "include/gpu/GrDirectContext.h"
#include "src/core/SkAutoPixmapStorage.h" #include "src/core/SkAutoPixmapStorage.h"
namespace { namespace {
class ManagedBackendTexture : public SkNVRefCnt<ManagedBackendTexture> { class ManagedBackendTexture : public SkNVRefCnt<ManagedBackendTexture> {
public: public:
~ManagedBackendTexture() { ~ManagedBackendTexture() {
if (fContext && fTexture.isValid()) { if (fDContext && fTexture.isValid()) {
fContext->submit(true); fDContext->submit(true);
fContext->deleteBackendTexture(fTexture); fDContext->deleteBackendTexture(fTexture);
} }
} }
static void Release(void* context) { static_cast<ManagedBackendTexture*>(context)->unref(); } static void Release(void* context) { static_cast<ManagedBackendTexture*>(context)->unref(); }
template <typename... Args> template <typename... Args>
static sk_sp<ManagedBackendTexture> Make(GrContext* context, Args&&... args) { static sk_sp<ManagedBackendTexture> Make(GrDirectContext* dContext, Args&&... args) {
sk_sp<ManagedBackendTexture> mbet(new ManagedBackendTexture); sk_sp<ManagedBackendTexture> mbet(new ManagedBackendTexture);
mbet->fContext = context; mbet->fDContext = dContext;
mbet->fTexture = context->createBackendTexture(std::forward<Args>(args)..., Release, mbet->fTexture = dContext->createBackendTexture(std::forward<Args>(args)..., Release,
mbet->refAndPassAsContext()); mbet->refAndPassAsContext());
return mbet; return mbet;
} }
@ -43,13 +43,13 @@ public:
private: private:
ManagedBackendTexture() = default; ManagedBackendTexture() = default;
GrContext* fContext = nullptr; GrDirectContext* fDContext = nullptr;
GrBackendTexture fTexture; GrBackendTexture fTexture;
}; };
} // namespace } // namespace
namespace sk_gpu_test { namespace sk_gpu_test {
sk_sp<SkImage> MakeBackendTextureImage(GrContext* context, sk_sp<SkImage> MakeBackendTextureImage(GrDirectContext* dContext,
const SkPixmap& pixmap, const SkPixmap& pixmap,
GrRenderable renderable, GrRenderable renderable,
GrSurfaceOrigin origin) { GrSurfaceOrigin origin) {
@ -64,8 +64,8 @@ sk_sp<SkImage> MakeBackendTextureImage(GrContext* context,
} }
src = &temp; src = &temp;
} }
auto mbet = ManagedBackendTexture::Make(context, src, 1, renderable, GrProtected::kNo); auto mbet = ManagedBackendTexture::Make(dContext, src, 1, renderable, GrProtected::kNo);
return SkImage::MakeFromTexture(context, return SkImage::MakeFromTexture(dContext,
mbet->texture(), mbet->texture(),
origin, origin,
src->colorType(), src->colorType(),

View File

@ -8,7 +8,7 @@
#include "include/core/SkRefCnt.h" #include "include/core/SkRefCnt.h"
#include "include/gpu/GrTypes.h" #include "include/gpu/GrTypes.h"
class GrContext; class GrDirectContext;
class SkImage; class SkImage;
class SkPixmap; class SkPixmap;
@ -20,5 +20,6 @@ namespace sk_gpu_test {
* For testing purposes the texture can be made renderable to exercise different code paths for * For testing purposes the texture can be made renderable to exercise different code paths for
* renderable textures/formats. * renderable textures/formats.
*/ */
sk_sp<SkImage> MakeBackendTextureImage(GrContext*, const SkPixmap&, GrRenderable, GrSurfaceOrigin); sk_sp<SkImage> MakeBackendTextureImage(GrDirectContext*, const SkPixmap&,
GrRenderable, GrSurfaceOrigin);
} // namespace sk_gpu_test } // namespace sk_gpu_test