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

Unified Diff: src/gpu/GrGpu.cpp

Issue 1257073003: Move draw on upload decision in GrGpu (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fixed for sw conversion case 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/GrTest.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 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,
« no previous file with comments | « src/gpu/GrGpu.h ('k') | src/gpu/GrTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698