Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(912)

Unified Diff: src/gpu/GrGpu.cpp

Issue 1270583003: Move some parts of onReadPixels up to GrGpu readPixels. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: nit Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrGpu.h ('k') | src/gpu/gl/GrGLGpu.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrGpu.cpp
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
index c7137ef6918fb67141d0eee2b3840fbc114e15c9..bb020f5b503d7ac7c7207fcc663e37e00542bab2 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -17,6 +17,7 @@
#include "GrResourceCache.h"
#include "GrRenderTargetPriv.h"
#include "GrStencilAttachment.h"
+#include "GrSurfacePriv.h"
#include "GrVertexBuffer.h"
#include "GrVertices.h"
@@ -239,6 +240,11 @@ bool GrGpu::getReadPixelsInfo(GrSurface* srcSurface, int width, int height, size
SkASSERT(tempDrawInfo);
SkASSERT(kGpuPrefersDraw_DrawPreference != *drawPreference);
+ // We currently do not support reading into a compressed buffer
+ if (GrPixelConfigIsCompressed(readConfig)) {
+ return false;
+ }
+
if (!this->onGetReadPixelsInfo(srcSurface, width, height, rowBytes, readConfig, drawPreference,
tempDrawInfo)) {
return false;
@@ -292,7 +298,24 @@ bool GrGpu::readPixels(GrSurface* surface,
GrPixelConfig config, void* buffer,
size_t rowBytes) {
this->handleDirtyContext();
- return this->onReadPixels(surface, left, top, width, height, config, buffer, rowBytes);
+
+ // We cannot read pixels into a compressed buffer
+ if (GrPixelConfigIsCompressed(config)) {
+ return false;
+ }
+
+ size_t bpp = GrBytesPerPixel(config);
+ if (!GrSurfacePriv::AdjustReadPixelParams(surface->width(), surface->height(), bpp,
+ &left, &top, &width, &height,
+ &buffer,
+ &rowBytes)) {
+ return false;
+ }
+
+ return this->onReadPixels(surface,
+ left, top, width, height,
+ config, buffer,
+ rowBytes);
}
bool GrGpu::writePixels(GrSurface* surface,
« no previous file with comments | « src/gpu/GrGpu.h ('k') | src/gpu/gl/GrGLGpu.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698