aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2018-06-01 15:04:28 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-06-02 00:00:56 +0000
commita9b04b90669e08c1ee4aa826a83c416b24704248 (patch)
tree01fd326b461a8d2065c0cd70f367dba0806318ba /src
parent257c1fb7524db283f43ac3d3813e917cbe522e81 (diff)
Remove origin from GrGpu::writePixels
Change-Id: Iea3d68d282420f28623ebea315499fbd7ad9d471 Reviewed-on: https://skia-review.googlesource.com/131526 Commit-Queue: Brian Salomon <bsalomon@google.com> Auto-Submit: Brian Salomon <bsalomon@google.com> Reviewed-by: Brian Osman <brianosman@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/gpu/GrGpu.cpp16
-rw-r--r--src/gpu/GrGpu.h24
-rw-r--r--src/gpu/GrOpFlushState.cpp4
-rw-r--r--src/gpu/gl/GrGLGpu.cpp65
-rw-r--r--src/gpu/gl/GrGLGpu.h11
-rw-r--r--src/gpu/mock/GrMockGpu.h5
-rw-r--r--src/gpu/mtl/GrMtlGpu.h5
-rw-r--r--src/gpu/vk/GrVkGpu.cpp61
-rw-r--r--src/gpu/vk/GrVkGpu.h15
9 files changed, 64 insertions, 142 deletions
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
index 083a125bab..7f60129d51 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -232,9 +232,8 @@ bool GrGpu::readPixels(GrSurface* surface, GrSurfaceOrigin origin, int left, int
rowBytes);
}
-bool GrGpu::writePixels(GrSurface* surface, GrSurfaceOrigin origin, int left, int top, int width,
- int height, GrColorType srcColorType, const GrMipLevel texels[],
- int mipLevelCount) {
+bool GrGpu::writePixels(GrSurface* surface, int left, int top, int width, int height,
+ GrColorType srcColorType, const GrMipLevel texels[], int mipLevelCount) {
SkASSERT(surface);
if (1 == mipLevelCount) {
// We require that if we are not mipped, then the write region is contained in the surface
@@ -255,23 +254,16 @@ bool GrGpu::writePixels(GrSurface* surface, GrSurfaceOrigin origin, int left, in
}
this->handleDirtyContext();
- if (this->onWritePixels(surface, origin, left, top, width, height, srcColorType, texels,
+ if (this->onWritePixels(surface, left, top, width, height, srcColorType, texels,
mipLevelCount)) {
SkIRect rect = SkIRect::MakeXYWH(left, top, width, height);
- this->didWriteToSurface(surface, origin, &rect, mipLevelCount);
+ this->didWriteToSurface(surface, kTopLeft_GrSurfaceOrigin, &rect, mipLevelCount);
fStats.incTextureUploads();
return true;
}
return false;
}
-bool GrGpu::writePixels(GrSurface* surface, GrSurfaceOrigin origin, int left, int top, int width,
- int height, GrColorType srcColorType, const void* buffer, size_t rowBytes) {
- GrMipLevel mipLevel = { buffer, rowBytes };
-
- return this->writePixels(surface, origin, left, top, width, height, srcColorType, &mipLevel, 1);
-}
-
bool GrGpu::transferPixels(GrTexture* texture, int left, int top, int width, int height,
GrColorType bufferColorType, GrBuffer* transferBuffer, size_t offset,
size_t rowBytes) {
diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h
index 6adabf46d1..6958ea997f 100644
--- a/src/gpu/GrGpu.h
+++ b/src/gpu/GrGpu.h
@@ -184,25 +184,16 @@ public:
* @param texels array of mipmap levels containing texture data
* @param mipLevelCount number of levels in 'texels'
*/
- bool writePixels(GrSurface* surface, GrSurfaceOrigin origin, int left, int top, int width,
- int height, GrColorType srcColorType, const GrMipLevel texels[],
- int mipLevelCount);
-
- /**
- * This function is a shim which creates a SkTArray<GrMipLevel> of size 1.
- * It then calls writePixels with that SkTArray.
- */
- bool writePixels(GrSurface*, GrSurfaceOrigin, int left, int top, int width, int height,
- GrColorType, const void* buffer, size_t rowBytes);
+ bool writePixels(GrSurface* surface, int left, int top, int width, int height,
+ GrColorType srcColorType, const GrMipLevel texels[], int mipLevelCount);
/**
- * This version of writePixels doesn't take an origin. TODO: Remove origin handling from
- * GrGpu::writePixels entirely.
+ * Helper for the case of a single level.
*/
bool writePixels(GrSurface* surface, int left, int top, int width, int height,
GrColorType srcColorType, const void* buffer, size_t rowBytes) {
- return this->writePixels(surface, kTopLeft_GrSurfaceOrigin, left, top, width, height,
- srcColorType, buffer, rowBytes);
+ GrMipLevel mipLevel = {buffer, rowBytes};
+ return this->writePixels(surface, left, top, width, height, srcColorType, &mipLevel, 1);
}
/**
@@ -449,9 +440,8 @@ private:
GrColorType, void* buffer, size_t rowBytes) = 0;
// overridden by backend-specific derived class to perform the surface write
- virtual bool onWritePixels(GrSurface*, GrSurfaceOrigin, int left, int top, int width,
- int height, GrColorType, const GrMipLevel texels[],
- int mipLevelCount) = 0;
+ virtual bool onWritePixels(GrSurface*, int left, int top, int width, int height, GrColorType,
+ const GrMipLevel texels[], int mipLevelCount) = 0;
// overridden by backend-specific derived class to perform the texture transfer
virtual bool onTransferPixels(GrTexture*, int left, int top, int width, int height,
diff --git a/src/gpu/GrOpFlushState.cpp b/src/gpu/GrOpFlushState.cpp
index 94a021d90a..09b657a64d 100644
--- a/src/gpu/GrOpFlushState.cpp
+++ b/src/gpu/GrOpFlushState.cpp
@@ -88,8 +88,8 @@ void GrOpFlushState::doUpload(GrDeferredTextureUploadFn& upload) {
fGpu->caps()->supportedWritePixelsColorType(dstSurface->config(), srcColorType) != srcColorType) {
return false;
}
- return this->fGpu->writePixels(dstSurface, dstProxy->origin(), left, top, width, height,
- srcColorType, buffer, rowBytes);
+ return this->fGpu->writePixels(dstSurface, left, top, width, height, srcColorType, buffer,
+ rowBytes);
};
upload(wp);
}
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 41d74e78ff..aa5d2e7bd4 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -661,9 +661,9 @@ static bool check_write_and_transfer_input(GrGLTexture* glTex) {
return true;
}
-bool GrGLGpu::onWritePixels(GrSurface* surface, GrSurfaceOrigin origin, int left, int top,
- int width, int height, GrColorType srcColorType,
- const GrMipLevel texels[], int mipLevelCount) {
+bool GrGLGpu::onWritePixels(GrSurface* surface, int left, int top, int width, int height,
+ GrColorType srcColorType, const GrMipLevel texels[],
+ int mipLevelCount) {
auto glTex = static_cast<GrGLTexture*>(surface->asTexture());
if (!check_write_and_transfer_input(glTex)) {
@@ -680,9 +680,9 @@ bool GrGLGpu::onWritePixels(GrSurface* surface, GrSurfaceOrigin origin, int left
// caps knows to make the external format be GL_RGBA.
auto srgbEncoded = GrPixelConfigIsSRGBEncoded(surface->config());
auto srcAsConfig = GrColorTypeToPixelConfig(srcColorType, srgbEncoded);
- return this->uploadTexData(glTex->config(), glTex->width(), glTex->height(), origin,
- glTex->target(), kWrite_UploadType, left, top, width, height,
- srcAsConfig, texels, mipLevelCount);
+ return this->uploadTexData(glTex->config(), glTex->width(), glTex->height(), glTex->target(),
+ kWrite_UploadType, left, top, width, height, srcAsConfig, texels,
+ mipLevelCount);
}
// For GL_[UN]PACK_ALIGNMENT. TODO: This really wants to be GrColorType.
@@ -907,14 +907,11 @@ static bool allocate_and_populate_texture(GrPixelConfig config,
* @param glFlipY Did GL flip the texture vertically?
*/
static void restore_pixelstore_state(const GrGLInterface& interface, const GrGLCaps& caps,
- bool restoreGLRowLength, bool glFlipY) {
+ bool restoreGLRowLength) {
if (restoreGLRowLength) {
SkASSERT(caps.unpackRowLengthSupport());
GR_GL_CALL(&interface, PixelStorei(GR_GL_UNPACK_ROW_LENGTH, 0));
}
- if (glFlipY) {
- GR_GL_CALL(&interface, PixelStorei(GR_GL_UNPACK_FLIP_Y, GR_GL_FALSE));
- }
}
void GrGLGpu::unbindCpuToGpuXferBuffer() {
@@ -928,10 +925,9 @@ void GrGLGpu::unbindCpuToGpuXferBuffer() {
// TODO: Make this take a GrColorType instead of dataConfig. This requires updating GrGLCaps to
// convert from GrColorType to externalFormat/externalType GLenum values.
-bool GrGLGpu::uploadTexData(GrPixelConfig texConfig, int texWidth, int texHeight,
- GrSurfaceOrigin texOrigin, GrGLenum target, UploadType uploadType,
- int left, int top, int width, int height, GrPixelConfig dataConfig,
- const GrMipLevel texels[], int mipLevelCount,
+bool GrGLGpu::uploadTexData(GrPixelConfig texConfig, int texWidth, int texHeight, GrGLenum target,
+ UploadType uploadType, int left, int top, int width, int height,
+ GrPixelConfig dataConfig, const GrMipLevel texels[], int mipLevelCount,
GrMipMapsStatus* mipMapsStatus) {
SkASSERT(this->caps()->isConfigTexturable(texConfig));
SkDEBUGCODE(
@@ -984,16 +980,6 @@ bool GrGLGpu::uploadTexData(GrPixelConfig texConfig, int texWidth, int texHeight
* GL_UNPACK_ROW_LENGTH.
*/
bool restoreGLRowLength = false;
- bool swFlipY = false;
- bool glFlipY = false;
-
- if (kBottomLeft_GrSurfaceOrigin == texOrigin && mipLevelCount) {
- if (caps.unpackFlipYSupport()) {
- glFlipY = true;
- } else {
- swFlipY = true;
- }
- }
// in case we need a temporary, trimmed copy of the src pixels
SkAutoSMalloc<128 * 128> tempStorage;
@@ -1021,9 +1007,7 @@ bool GrGLGpu::uploadTexData(GrPixelConfig texConfig, int texWidth, int texHeight
? texelsShallowCopy[currentMipLevel].fRowBytes
: trimRowBytes;
-
- if (((!caps.unpackRowLengthSupport() || usesMips) && trimRowBytes != rowBytes) ||
- swFlipY) {
+ if (((!caps.unpackRowLengthSupport() || usesMips) && trimRowBytes != rowBytes)) {
willNeedData = true;
}
@@ -1068,27 +1052,20 @@ bool GrGLGpu::uploadTexData(GrPixelConfig texConfig, int texWidth, int texHeight
// TODO: This optimization should be enabled with or without mips.
// For use with mips, we must set GR_GL_UNPACK_ROW_LENGTH once per
// mip level, before calling glTexImage2D.
- if (caps.unpackRowLengthSupport() && !swFlipY && !usesMips) {
+ if (caps.unpackRowLengthSupport() && !usesMips) {
// can't use this for flipping, only non-neg values allowed. :(
if (rowBytes != trimRowBytes) {
GrGLint rowLength = static_cast<GrGLint>(rowBytes / bpp);
GR_GL_CALL(interface, PixelStorei(GR_GL_UNPACK_ROW_LENGTH, rowLength));
restoreGLRowLength = true;
}
- } else if (trimRowBytes != rowBytes || swFlipY) {
+ } else if (trimRowBytes != rowBytes) {
// copy data into our new storage, skipping the trailing bytes
const char* src = (const char*)texelsShallowCopy[currentMipLevel].fPixels;
- if (swFlipY && currentHeight >= 1) {
- src += (currentHeight - 1) * rowBytes;
- }
char* dst = buffer + individualMipOffsets[currentMipLevel];
for (int y = 0; y < currentHeight; y++) {
memcpy(dst, src, trimRowBytes);
- if (swFlipY) {
- src -= rowBytes;
- } else {
- src += rowBytes;
- }
+ src += rowBytes;
dst += trimRowBytes;
}
// now point data to our copied version
@@ -1099,9 +1076,6 @@ bool GrGLGpu::uploadTexData(GrPixelConfig texConfig, int texWidth, int texHeight
}
if (mipLevelCount) {
- if (glFlipY) {
- GR_GL_CALL(interface, PixelStorei(GR_GL_UNPACK_FLIP_Y, GR_GL_TRUE));
- }
GR_GL_CALL(interface, PixelStorei(GR_GL_UNPACK_ALIGNMENT, config_alignment(texConfig)));
}
@@ -1116,9 +1090,6 @@ bool GrGLGpu::uploadTexData(GrPixelConfig texConfig, int texWidth, int texHeight
succeeded = false;
}
} else {
- if (swFlipY || glFlipY) {
- top = texHeight - (top + height);
- }
for (int currentMipLevel = 0; currentMipLevel < mipLevelCount; currentMipLevel++) {
if (!texelsShallowCopy[currentMipLevel].fPixels) {
continue;
@@ -1137,7 +1108,7 @@ bool GrGLGpu::uploadTexData(GrPixelConfig texConfig, int texWidth, int texHeight
}
}
- restore_pixelstore_state(*interface, caps, restoreGLRowLength, glFlipY);
+ restore_pixelstore_state(*interface, caps, restoreGLRowLength);
return succeeded;
}
@@ -1563,9 +1534,9 @@ bool GrGLGpu::createTextureImpl(const GrSurfaceDesc& desc, GrGLTextureInfo* info
set_initial_texture_params(this->glInterface(), *info, initialTexParams);
}
- if (!this->uploadTexData(desc.fConfig, desc.fWidth, desc.fHeight, kTopLeft_GrSurfaceOrigin,
- info->fTarget, kNewTexture_UploadType, 0, 0, desc.fWidth, desc.fHeight,
- desc.fConfig, texels, mipLevelCount, mipMapsStatus)) {
+ if (!this->uploadTexData(desc.fConfig, desc.fWidth, desc.fHeight, info->fTarget,
+ kNewTexture_UploadType, 0, 0, desc.fWidth, desc.fHeight, desc.fConfig,
+ texels, mipLevelCount, mipMapsStatus)) {
GL_CALL(DeleteTextures(1, &(info->fID)));
return false;
}
diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h
index 06a1dee004..508b0f862d 100644
--- a/src/gpu/gl/GrGLGpu.h
+++ b/src/gpu/gl/GrGLGpu.h
@@ -234,8 +234,8 @@ private:
bool onReadPixels(GrSurface*, GrSurfaceOrigin, int left, int top, int width, int height,
GrColorType, void* buffer, size_t rowBytes) override;
- bool onWritePixels(GrSurface*, GrSurfaceOrigin, int left, int top, int width, int height,
- GrColorType, const GrMipLevel texels[], int mipLevelCount) override;
+ bool onWritePixels(GrSurface*, int left, int top, int width, int height, GrColorType,
+ const GrMipLevel texels[], int mipLevelCount) override;
bool onTransferPixels(GrTexture*, int left, int top, int width, int height, GrColorType,
GrBuffer* transferBuffer, size_t offset, size_t rowBytes) override;
@@ -370,10 +370,9 @@ private:
kNewTexture_UploadType, // we are creating a new texture
kWrite_UploadType, // we are using TexSubImage2D to copy data to an existing texture
};
- bool uploadTexData(GrPixelConfig texConfig, int texWidth, int texHeight,
- GrSurfaceOrigin texOrigin, GrGLenum target, UploadType uploadType, int left,
- int top, int width, int height, GrPixelConfig dataConfig,
- const GrMipLevel texels[], int mipLevelCount,
+ bool uploadTexData(GrPixelConfig texConfig, int texWidth, int texHeight, GrGLenum target,
+ UploadType uploadType, int left, int top, int width, int height,
+ GrPixelConfig dataConfig, const GrMipLevel texels[], int mipLevelCount,
GrMipMapsStatus* mipMapsStatus = nullptr);
bool createRenderTargetObjects(const GrSurfaceDesc&, const GrGLTextureInfo& texInfo,
diff --git a/src/gpu/mock/GrMockGpu.h b/src/gpu/mock/GrMockGpu.h
index e61b817646..0b874bb7fa 100644
--- a/src/gpu/mock/GrMockGpu.h
+++ b/src/gpu/mock/GrMockGpu.h
@@ -76,9 +76,8 @@ private:
return true;
}
- bool onWritePixels(GrSurface* surface, GrSurfaceOrigin, int left, int top, int width,
- int height, GrColorType, const GrMipLevel texels[],
- int mipLevelCount) override {
+ bool onWritePixels(GrSurface* surface, int left, int top, int width, int height, GrColorType,
+ const GrMipLevel texels[], int mipLevelCount) override {
return true;
}
diff --git a/src/gpu/mtl/GrMtlGpu.h b/src/gpu/mtl/GrMtlGpu.h
index 329103e3a6..4e1c5e7ff4 100644
--- a/src/gpu/mtl/GrMtlGpu.h
+++ b/src/gpu/mtl/GrMtlGpu.h
@@ -101,9 +101,8 @@ private:
return false;
}
- bool onWritePixels(GrSurface*, GrSurfaceOrigin, int left, int top, int width,
- int height, GrColorType, const GrMipLevel[],
- int) override {
+ bool onWritePixels(GrSurface*, int left, int top, int width, int height, GrColorType,
+ const GrMipLevel[], int) override {
return false;
}
diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp
index 59e3e612f8..f115a51abf 100644
--- a/src/gpu/vk/GrVkGpu.cpp
+++ b/src/gpu/vk/GrVkGpu.cpp
@@ -327,9 +327,9 @@ GrBuffer* GrVkGpu::onCreateBuffer(size_t size, GrBufferType type, GrAccessPatter
return buff;
}
-bool GrVkGpu::onWritePixels(GrSurface* surface, GrSurfaceOrigin origin, int left, int top,
- int width, int height, GrColorType srcColorType,
- const GrMipLevel texels[], int mipLevelCount) {
+bool GrVkGpu::onWritePixels(GrSurface* surface, int left, int top, int width, int height,
+ GrColorType srcColorType, const GrMipLevel texels[],
+ int mipLevelCount) {
GrVkTexture* vkTex = static_cast<GrVkTexture*>(surface->asTexture());
if (!vkTex) {
return false;
@@ -356,7 +356,7 @@ bool GrVkGpu::onWritePixels(GrSurface* surface, GrSurfaceOrigin origin, int left
false);
this->submitCommandBuffer(kForce_SyncQueue);
}
- success = this->uploadTexDataLinear(vkTex, origin, left, top, width, height, srcColorType,
+ success = this->uploadTexDataLinear(vkTex, left, top, width, height, srcColorType,
texels[0].fPixels, texels[0].fRowBytes);
} else {
int currentMipLevels = vkTex->texturePriv().maxMipMapLevel() + 1;
@@ -365,8 +365,8 @@ bool GrVkGpu::onWritePixels(GrSurface* surface, GrSurfaceOrigin origin, int left
return false;
}
}
- success = this->uploadTexDataOptimal(vkTex, origin, left, top, width, height, srcColorType,
- texels, mipLevelCount);
+ success = this->uploadTexDataOptimal(vkTex, left, top, width, height, srcColorType, texels,
+ mipLevelCount);
}
return success;
@@ -486,9 +486,8 @@ void GrVkGpu::internalResolveRenderTarget(GrRenderTarget* target, bool requiresS
}
}
-bool GrVkGpu::uploadTexDataLinear(GrVkTexture* tex, GrSurfaceOrigin texOrigin, int left, int top,
- int width, int height, GrColorType dataColorType,
- const void* data, size_t rowBytes) {
+bool GrVkGpu::uploadTexDataLinear(GrVkTexture* tex, int left, int top, int width, int height,
+ GrColorType dataColorType, const void* data, size_t rowBytes) {
SkASSERT(data);
SkASSERT(tex->isLinearTiled());
@@ -519,9 +518,8 @@ bool GrVkGpu::uploadTexDataLinear(GrVkTexture* tex, GrSurfaceOrigin texOrigin, i
&subres,
&layout));
- int texTop = kBottomLeft_GrSurfaceOrigin == texOrigin ? tex->height() - top - height : top;
const GrVkAlloc& alloc = tex->alloc();
- VkDeviceSize offset = texTop*layout.rowPitch + left*bpp;
+ VkDeviceSize offset = top * layout.rowPitch + left * bpp;
VkDeviceSize size = height*layout.rowPitch;
SkASSERT(size + offset <= alloc.fSize);
void* mapPtr = GrVkMemory::MapAlloc(this, alloc);
@@ -530,19 +528,8 @@ bool GrVkGpu::uploadTexDataLinear(GrVkTexture* tex, GrSurfaceOrigin texOrigin, i
}
mapPtr = reinterpret_cast<char*>(mapPtr) + offset;
- if (kBottomLeft_GrSurfaceOrigin == texOrigin) {
- // copy into buffer by rows
- const char* srcRow = reinterpret_cast<const char*>(data);
- char* dstRow = reinterpret_cast<char*>(mapPtr)+(height - 1)*layout.rowPitch;
- for (int y = 0; y < height; y++) {
- memcpy(dstRow, srcRow, trimRowBytes);
- srcRow += rowBytes;
- dstRow -= layout.rowPitch;
- }
- } else {
- SkRectMemcpy(mapPtr, static_cast<size_t>(layout.rowPitch), data, rowBytes, trimRowBytes,
- height);
- }
+ SkRectMemcpy(mapPtr, static_cast<size_t>(layout.rowPitch), data, rowBytes, trimRowBytes,
+ height);
GrVkMemory::FlushMappedAlloc(this, alloc, offset, size);
GrVkMemory::UnmapAlloc(this, alloc);
@@ -550,9 +537,9 @@ bool GrVkGpu::uploadTexDataLinear(GrVkTexture* tex, GrSurfaceOrigin texOrigin, i
return true;
}
-bool GrVkGpu::uploadTexDataOptimal(GrVkTexture* tex, GrSurfaceOrigin texOrigin, int left, int top,
- int width, int height, GrColorType dataColorType,
- const GrMipLevel texels[], int mipLevelCount) {
+bool GrVkGpu::uploadTexDataOptimal(GrVkTexture* tex, int left, int top, int width, int height,
+ GrColorType dataColorType, const GrMipLevel texels[],
+ int mipLevelCount) {
SkASSERT(!tex->isLinearTiled());
// The assumption is either that we have no mipmaps, or that our rect is the entire texture
SkASSERT(1 == mipLevelCount ||
@@ -579,9 +566,6 @@ bool GrVkGpu::uploadTexDataOptimal(GrVkTexture* tex, GrSurfaceOrigin texOrigin,
memcpy(texelsShallowCopy.get(), texels, mipLevelCount*sizeof(GrMipLevel));
}
- // Determine whether we need to flip when we copy into the buffer
- bool flipY = (kBottomLeft_GrSurfaceOrigin == texOrigin && mipLevelCount);
-
SkTArray<size_t> individualMipOffsets(mipLevelCount);
individualMipOffsets.push_back(0);
size_t combinedBufferSize = width * bpp * height;
@@ -640,16 +624,7 @@ bool GrVkGpu::uploadTexDataOptimal(GrVkTexture* tex, GrSurfaceOrigin texOrigin,
// copy data into the buffer, skipping the trailing bytes
char* dst = buffer + individualMipOffsets[currentMipLevel];
const char* src = (const char*)texelsShallowCopy[currentMipLevel].fPixels;
- if (flipY) {
- src += (currentHeight - 1) * rowBytes;
- for (int y = 0; y < currentHeight; y++) {
- memcpy(dst, src, trimRowBytes);
- src -= rowBytes;
- dst += trimRowBytes;
- }
- } else {
- SkRectMemcpy(dst, trimRowBytes, src, rowBytes, trimRowBytes, currentHeight);
- }
+ SkRectMemcpy(dst, trimRowBytes, src, rowBytes, trimRowBytes, currentHeight);
VkBufferImageCopy& region = regions.push_back();
memset(&region, 0, sizeof(VkBufferImageCopy));
@@ -657,7 +632,7 @@ bool GrVkGpu::uploadTexDataOptimal(GrVkTexture* tex, GrSurfaceOrigin texOrigin,
region.bufferRowLength = currentWidth;
region.bufferImageHeight = currentHeight;
region.imageSubresource = { VK_IMAGE_ASPECT_COLOR_BIT, SkToU32(currentMipLevel), 0, 1 };
- region.imageOffset = { left, flipY ? layerHeight - top - currentHeight : top, 0 };
+ region.imageOffset = {left, top, 0};
region.imageExtent = { (uint32_t)currentWidth, (uint32_t)currentHeight, 1 };
}
currentWidth = SkTMax(1, currentWidth/2);
@@ -753,8 +728,8 @@ sk_sp<GrTexture> GrVkGpu::onCreateTexture(const GrSurfaceDesc& desc, SkBudgeted
auto colorType = GrPixelConfigToColorType(desc.fConfig);
if (mipLevelCount) {
- if (!this->uploadTexDataOptimal(tex.get(), kTopLeft_GrSurfaceOrigin, 0, 0, desc.fWidth,
- desc.fHeight, colorType, texels, mipLevelCount)) {
+ if (!this->uploadTexDataOptimal(tex.get(), 0, 0, desc.fWidth, desc.fHeight, colorType,
+ texels, mipLevelCount)) {
tex->unref();
return nullptr;
}
diff --git a/src/gpu/vk/GrVkGpu.h b/src/gpu/vk/GrVkGpu.h
index 01e4ec7f70..4284bbca6a 100644
--- a/src/gpu/vk/GrVkGpu.h
+++ b/src/gpu/vk/GrVkGpu.h
@@ -168,9 +168,8 @@ private:
bool onReadPixels(GrSurface* surface, GrSurfaceOrigin, int left, int top, int width, int height,
GrColorType, void* buffer, size_t rowBytes) override;
- bool onWritePixels(GrSurface* surface, GrSurfaceOrigin, int left, int top, int width,
- int height, GrColorType, const GrMipLevel texels[],
- int mipLevelCount) override;
+ bool onWritePixels(GrSurface* surface, int left, int top, int width, int height, GrColorType,
+ const GrMipLevel texels[], int mipLevelCount) override;
bool onTransferPixels(GrTexture*, int left, int top, int width, int height, GrColorType,
GrBuffer* transferBuffer, size_t offset, size_t rowBytes) override;
@@ -209,12 +208,10 @@ private:
const SkIPoint& dstPoint);
// helpers for onCreateTexture and writeTexturePixels
- bool uploadTexDataLinear(GrVkTexture* tex, GrSurfaceOrigin texOrigin, int left, int top,
- int width, int height, GrColorType colorType, const void* data,
- size_t rowBytes);
- bool uploadTexDataOptimal(GrVkTexture* tex, GrSurfaceOrigin texOrigin, int left, int top,
- int width, int height, GrColorType colorType,
- const GrMipLevel texels[], int mipLevelCount);
+ bool uploadTexDataLinear(GrVkTexture* tex, int left, int top, int width, int height,
+ GrColorType colorType, const void* data, size_t rowBytes);
+ bool uploadTexDataOptimal(GrVkTexture* tex, int left, int top, int width, int height,
+ GrColorType colorType, const GrMipLevel texels[], int mipLevelCount);
void resolveImage(GrSurface* dst, GrVkRenderTarget* src, const SkIRect& srcRect,
const SkIPoint& dstPoint);