More SkISizification in GPU code.
Uses SkISize instead of separate width/height variables in many places.
No functional change.
Change-Id: If87b2c57e43d810f0820c4e3c9ef8e6b8ebd10ba
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/249886
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 937e168..45f1111 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -1020,7 +1020,7 @@
bool GrGLGpu::uploadCompressedTexData(GrGLFormat format,
SkImage::CompressionType compressionType,
- const SkISize& size,
+ const SkISize& dimensions,
GrGLenum target,
const void* data) {
SkASSERT(format != GrGLFormat::kUnknown);
@@ -1038,13 +1038,14 @@
// Make sure that the width and height that we pass to OpenGL
// is a multiple of the block size.
- size_t dataSize = GrCompressedDataSize(compressionType, size.width(), size.height());
+ size_t dataSize =
+ GrCompressedDataSize(compressionType, dimensions.width(), dimensions.height());
if (useTexStorage) {
// We never resize or change formats of textures.
- GL_ALLOC_CALL(
- this->glInterface(),
- TexStorage2D(target, kMipLevelCount, internalFormat, size.width(), size.height()));
+ GL_ALLOC_CALL(this->glInterface(),
+ TexStorage2D(target, kMipLevelCount, internalFormat, dimensions.width(),
+ dimensions.height()));
GrGLenum error = CHECK_ALLOC_ERROR(this->glInterface());
if (error != GR_GL_NO_ERROR) {
return false;
@@ -1053,8 +1054,8 @@
0, // level
0, // left
0, // top
- size.width(),
- size.height(),
+ dimensions.width(),
+ dimensions.height(),
internalFormat,
SkToInt(dataSize),
data));
@@ -1062,8 +1063,8 @@
GL_ALLOC_CALL(this->glInterface(), CompressedTexImage2D(target,
0, // level
internalFormat,
- size.width(),
- size.height(),
+ dimensions.width(),
+ dimensions.height(),
0, // border
SkToInt(dataSize),
data));
@@ -1451,7 +1452,7 @@
}
GrGLuint GrGLGpu::createCompressedTexture2D(
- const SkISize& size,
+ const SkISize& dimensions,
GrGLFormat format,
SkImage::CompressionType compression,
GrGLTextureParameters::SamplerOverriddenState* initialState,
@@ -1469,14 +1470,14 @@
*initialState = set_initial_texture_params(this->glInterface(), GR_GL_TEXTURE_2D);
- if (!this->uploadCompressedTexData(format, compression, size, GR_GL_TEXTURE_2D, data)) {
+ if (!this->uploadCompressedTexData(format, compression, dimensions, GR_GL_TEXTURE_2D, data)) {
GL_CALL(DeleteTextures(1, &id));
return 0;
}
return id;
}
-GrGLuint GrGLGpu::createTexture2D(const SkISize& size,
+GrGLuint GrGLGpu::createTexture2D(const SkISize& dimensions,
GrGLFormat format,
GrRenderable renderable,
GrGLTextureParameters::SamplerOverriddenState* initialState,
@@ -1512,7 +1513,7 @@
if (this->glCaps().formatSupportsTexStorage(format)) {
GL_ALLOC_CALL(this->glInterface(),
TexStorage2D(GR_GL_TEXTURE_2D, SkTMax(mipLevelCount, 1), internalFormat,
- size.width(), size.height()));
+ dimensions.width(), dimensions.height()));
success = (GR_GL_NO_ERROR == CHECK_ALLOC_ERROR(this->glInterface()));
} else {
GrGLenum externalFormat, externalType;
@@ -1521,8 +1522,8 @@
if (externalFormat && externalType) {
for (int level = 0; level < mipLevelCount && error == GR_GL_NO_ERROR; level++) {
const int twoToTheMipLevel = 1 << level;
- const int currentWidth = SkTMax(1, size.width() / twoToTheMipLevel);
- const int currentHeight = SkTMax(1, size.height() / twoToTheMipLevel);
+ const int currentWidth = SkTMax(1, dimensions.width() / twoToTheMipLevel);
+ const int currentHeight = SkTMax(1, dimensions.height() / twoToTheMipLevel);
GL_ALLOC_CALL(
this->glInterface(),
TexImage2D(GR_GL_TEXTURE_2D, level, internalFormat, currentWidth,
diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h
index e49f459..3af1dd5 100644
--- a/src/gpu/gl/GrGLGpu.h
+++ b/src/gpu/gl/GrGLGpu.h
@@ -225,13 +225,13 @@
// returned. On failure, zero is returned.
// The texture is populated with |texels|, if it is non-null.
// The texture parameters are cached in |initialTexParams|.
- GrGLuint createTexture2D(const SkISize& size,
+ GrGLuint createTexture2D(const SkISize& dimensions,
GrGLFormat format,
GrRenderable,
GrGLTextureParameters::SamplerOverriddenState* initialState,
int mipLevelCount);
- GrGLuint createCompressedTexture2D(const SkISize& size, GrGLFormat format,
+ GrGLuint createCompressedTexture2D(const SkISize& dimensions, GrGLFormat format,
SkImage::CompressionType compression,
GrGLTextureParameters::SamplerOverriddenState* initialState,
const void* data);
@@ -378,7 +378,7 @@
// to populate a new texture. Returns false if we failed to create and upload the texture.
bool uploadCompressedTexData(GrGLFormat,
SkImage::CompressionType,
- const SkISize& size,
+ const SkISize& dimensions,
GrGLenum target,
const void* data);
diff --git a/src/gpu/gl/GrGLPathRendering.cpp b/src/gpu/gl/GrGLPathRendering.cpp
index abcae33..884bb9f 100644
--- a/src/gpu/gl/GrGLPathRendering.cpp
+++ b/src/gpu/gl/GrGLPathRendering.cpp
@@ -89,8 +89,8 @@
gpu->flushColorWrite(false);
GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(args.fProxy->peekRenderTarget());
- SkISize size = SkISize::Make(rt->width(), rt->height());
- this->setProjectionMatrix(*args.fViewMatrix, size, args.fProxy->origin());
+ SkISize dimensions = rt->dimensions();
+ this->setProjectionMatrix(*args.fViewMatrix, dimensions, args.fProxy->origin());
gpu->flushScissor(*args.fScissor, rt->width(), rt->height(), args.fProxy->origin());
gpu->flushHWAAState(rt, args.fUseHWAA);
gpu->flushRenderTarget(rt);
diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp
index 74cf539..38f81ca 100644
--- a/src/gpu/gl/GrGLProgram.cpp
+++ b/src/gpu/gl/GrGLProgram.cpp
@@ -147,12 +147,11 @@
}
// set RT adjustment
- SkISize size;
- size.set(rt->width(), rt->height());
+ SkISize dimensions = rt->dimensions();
if (!primProc.isPathRendering()) {
if (fRenderTargetState.fRenderTargetOrigin != origin ||
- fRenderTargetState.fRenderTargetSize != size) {
- fRenderTargetState.fRenderTargetSize = size;
+ fRenderTargetState.fRenderTargetSize != dimensions) {
+ fRenderTargetState.fRenderTargetSize = dimensions;
fRenderTargetState.fRenderTargetOrigin = origin;
float rtAdjustmentVec[4];
@@ -162,7 +161,6 @@
} else {
SkASSERT(fGpu->glCaps().shaderCaps()->pathRenderingSupport());
const GrPathProcessor& pathProc = primProc.cast<GrPathProcessor>();
- fGpu->glPathRendering()->setProjectionMatrix(pathProc.viewMatrix(),
- size, origin);
+ fGpu->glPathRendering()->setProjectionMatrix(pathProc.viewMatrix(), dimensions, origin);
}
}
diff --git a/src/gpu/gl/GrGLRenderTarget.cpp b/src/gpu/gl/GrGLRenderTarget.cpp
index 0442945..48aad47 100644
--- a/src/gpu/gl/GrGLRenderTarget.cpp
+++ b/src/gpu/gl/GrGLRenderTarget.cpp
@@ -20,27 +20,27 @@
// Because this class is virtually derived from GrSurface we must explicitly call its constructor.
// Constructor for wrapped render targets.
GrGLRenderTarget::GrGLRenderTarget(GrGLGpu* gpu,
- const SkISize& size,
+ const SkISize& dimensions,
GrGLFormat format,
GrPixelConfig config,
int sampleCount,
const IDs& ids,
GrGLStencilAttachment* stencil)
- : GrSurface(gpu, size, config, GrProtected::kNo)
- , INHERITED(gpu, size, config, sampleCount, GrProtected::kNo, stencil) {
+ : GrSurface(gpu, dimensions, config, GrProtected::kNo)
+ , INHERITED(gpu, dimensions, config, sampleCount, GrProtected::kNo, stencil) {
this->setFlags(gpu->glCaps(), ids);
this->init(format, ids);
this->registerWithCacheWrapped(GrWrapCacheable::kNo);
}
GrGLRenderTarget::GrGLRenderTarget(GrGLGpu* gpu,
- const SkISize& size,
+ const SkISize& dimensions,
GrGLFormat format,
GrPixelConfig config,
int sampleCount,
const IDs& ids)
- : GrSurface(gpu, size, config, GrProtected::kNo)
- , INHERITED(gpu, size, config, sampleCount, GrProtected::kNo) {
+ : GrSurface(gpu, dimensions, config, GrProtected::kNo)
+ , INHERITED(gpu, dimensions, config, sampleCount, GrProtected::kNo) {
this->setFlags(gpu->glCaps(), ids);
this->init(format, ids);
}
@@ -61,7 +61,7 @@
}
sk_sp<GrGLRenderTarget> GrGLRenderTarget::MakeWrapped(GrGLGpu* gpu,
- const SkISize& size,
+ const SkISize& dimensions,
GrGLFormat format,
GrPixelConfig config,
int sampleCount,
@@ -76,11 +76,11 @@
format.fStencilBits = stencilBits;
format.fTotalBits = stencilBits;
// Ownership of sb is passed to the GrRenderTarget so doesn't need to be deleted
- sb = new GrGLStencilAttachment(gpu, sbDesc, size.width(), size.height(), sampleCount,
- format);
+ sb = new GrGLStencilAttachment(gpu, sbDesc, dimensions.width(), dimensions.height(),
+ sampleCount, format);
}
return sk_sp<GrGLRenderTarget>(
- new GrGLRenderTarget(gpu, size, format, config, sampleCount, idDesc, sb));
+ new GrGLRenderTarget(gpu, dimensions, format, config, sampleCount, idDesc, sb));
}
GrBackendRenderTarget GrGLRenderTarget::getBackendRenderTarget() const {
@@ -104,7 +104,7 @@
size_t GrGLRenderTarget::onGpuMemorySize() const {
const GrCaps& caps = *this->getGpu()->caps();
- return GrSurface::ComputeSize(caps, this->backendFormat(), this->width(), this->height(),
+ return GrSurface::ComputeSize(caps, this->backendFormat(), this->dimensions(),
fNumSamplesOwnedPerPixel, GrMipMapped::kNo);
}
@@ -222,8 +222,8 @@
// Log any renderbuffer's contribution to memory.
if (fMSColorRenderbufferID) {
const GrCaps& caps = *this->getGpu()->caps();
- size_t size = GrSurface::ComputeSize(caps, this->backendFormat(), this->width(),
- this->height(), this->msaaSamples(), GrMipMapped::kNo);
+ size_t size = GrSurface::ComputeSize(caps, this->backendFormat(), this->dimensions(),
+ this->msaaSamples(), GrMipMapped::kNo);
// Due to this resource having both a texture and a renderbuffer component, dump as
// skia/gpu_resources/resource_#/renderbuffer
diff --git a/src/gpu/gl/GrGLTextureRenderTarget.cpp b/src/gpu/gl/GrGLTextureRenderTarget.cpp
index 38bc4ef..6648828 100644
--- a/src/gpu/gl/GrGLTextureRenderTarget.cpp
+++ b/src/gpu/gl/GrGLTextureRenderTarget.cpp
@@ -73,6 +73,6 @@
size_t GrGLTextureRenderTarget::onGpuMemorySize() const {
const GrCaps& caps = *this->getGpu()->caps();
- return GrSurface::ComputeSize(caps, this->backendFormat(), this->width(), this->height(),
+ return GrSurface::ComputeSize(caps, this->backendFormat(), this->dimensions(),
this->numSamplesOwnedPerPixel(), this->texturePriv().mipMapped());
}