Index: src/gpu/GrGpu.cpp |
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp |
index 728fb880622010fa9495932d467b7f6df7d3ff04..c61979bbfb1b17a839bc47a0dde17237c6962d07 100644 |
--- a/src/gpu/GrGpu.cpp |
+++ b/src/gpu/GrGpu.cpp |
@@ -232,6 +232,61 @@ void GrGpu::clearStencilClip(const SkIRect& rect, |
this->onClearStencilClip(renderTarget, rect, insideClip); |
} |
+bool GrGpu::getReadPixelsInfo(GrSurface* srcSurface, int width, int height, size_t rowBytes, |
+ GrPixelConfig readConfig, DrawPreference* drawPreference, |
+ ReadPixelTempDrawInfo* tempDrawInfo) { |
+ SkASSERT(drawPreference); |
+ SkASSERT(tempDrawInfo); |
+ SkASSERT(kGpuPrefersDraw_DrawPreference != *drawPreference); |
+ |
+ if (!this->onGetReadPixelsInfo(srcSurface, width, height, rowBytes, readConfig, drawPreference, |
+ tempDrawInfo)) { |
+ return false; |
+ } |
+ |
+ // Check to see if we're going to request that the caller draw when drawing is not possible. |
+ if (!srcSurface->asTexture() || |
+ !this->caps()->isConfigRenderable(tempDrawInfo->fTempSurfaceDesc.fConfig, false)) { |
+ // If we don't have a fallback to a straight read then fail. |
+ if (kRequireDraw_DrawPreference == *drawPreference) { |
+ return false; |
+ } |
+ *drawPreference = kNoDraw_DrawPreference; |
+ } |
+ |
+ return true; |
+} |
+bool GrGpu::getWritePixelsInfo(GrSurface* dstSurface, int width, int height, size_t rowBytes, |
+ GrPixelConfig srcConfig, DrawPreference* drawPreference, |
+ WritePixelTempDrawInfo* tempDrawInfo) { |
+ SkASSERT(drawPreference); |
+ SkASSERT(tempDrawInfo); |
+ SkASSERT(kGpuPrefersDraw_DrawPreference != *drawPreference); |
+ |
+ if (this->caps()->useDrawInsteadOfPartialRenderTargetWrite() && |
+ SkToBool(dstSurface->asRenderTarget()) && |
+ (width < dstSurface->width() || height < dstSurface->height())) { |
+ ElevateDrawPreference(drawPreference, kRequireDraw_DrawPreference); |
+ } |
+ |
+ if (!this->onGetWritePixelsInfo(dstSurface, width, height, rowBytes, srcConfig, drawPreference, |
+ tempDrawInfo)) { |
+ return false; |
+ } |
+ |
+ // Check to see if we're going to request that the caller draw when drawing is not possible. |
+ if (!dstSurface->asRenderTarget() || |
+ !this->caps()->isConfigTexturable(tempDrawInfo->fTempSurfaceDesc.fConfig)) { |
+ // If we don't have a fallback to a straight upload then fail. |
+ if (kRequireDraw_DrawPreference == *drawPreference || |
+ !this->caps()->isConfigTexturable(srcConfig)) { |
+ return false; |
+ } |
+ *drawPreference = kNoDraw_DrawPreference; |
+ } |
+ return true; |
+} |
+ |
bool GrGpu::readPixels(GrRenderTarget* target, |
int left, int top, int width, int height, |
GrPixelConfig config, void* buffer, |