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

Unified Diff: src/gpu/GrDrawContext.cpp

Issue 2298253002: Add read/write-Pixels to GrDrawContext (Closed)
Patch Set: Created 4 years, 4 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 | « include/gpu/GrDrawContext.h ('k') | src/gpu/SkGpuDevice.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrDrawContext.cpp
diff --git a/src/gpu/GrDrawContext.cpp b/src/gpu/GrDrawContext.cpp
index 2bb9caa8b170d994862b5e0e51965fe9159023b2..e76683033cbb5fd2e9cbf6fe802cbca7864687c0 100644
--- a/src/gpu/GrDrawContext.cpp
+++ b/src/gpu/GrDrawContext.cpp
@@ -37,6 +37,7 @@
#include "../private/GrAuditTrail.h"
+#include "SkGr.h"
#include "SkLatticeIter.h"
#include "SkMatrixPriv.h"
@@ -1125,6 +1126,39 @@ void GrDrawContext::drawNonAAFilledRect(const GrClip& clip,
this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch);
}
+bool GrDrawContext::readPixels(const SkImageInfo& dstInfo, void* dstBuffer, size_t dstRowBytes,
+ int x, int y) {
+ // TODO: teach fRenderTarget to take ImageInfo directly to specify the src pixels
+ GrPixelConfig config = SkImageInfo2GrPixelConfig(dstInfo, *fContext->caps());
+ if (kUnknown_GrPixelConfig == config) {
+ return false;
+ }
+
+ uint32_t flags = 0;
+ if (kUnpremul_SkAlphaType == dstInfo.alphaType()) {
+ flags = GrContext::kUnpremul_PixelOpsFlag;
+ }
+
+ return fRenderTarget->readPixels(x, y, dstInfo.width(), dstInfo.height(),
+ config, dstBuffer, dstRowBytes, flags);
+}
+
+bool GrDrawContext::writePixels(const SkImageInfo& srcInfo, const void* srcBuffer,
+ size_t srcRowBytes, int x, int y) {
+ // TODO: teach fRenderTarget to take ImageInfo directly to specify the src pixels
+ GrPixelConfig config = SkImageInfo2GrPixelConfig(srcInfo, *fContext->caps());
+ if (kUnknown_GrPixelConfig == config) {
+ return false;
+ }
+ uint32_t flags = 0;
+ if (kUnpremul_SkAlphaType == srcInfo.alphaType()) {
+ flags = GrContext::kUnpremul_PixelOpsFlag;
+ }
+
+ return fRenderTarget->writePixels(x, y, srcInfo.width(), srcInfo.height(),
+ config, srcBuffer, srcRowBytes, flags);
+}
+
// Can 'path' be drawn as a pair of filled nested rectangles?
static bool fills_as_nested_rects(const SkMatrix& viewMatrix, const SkPath& path, SkRect rects[2]) {
« no previous file with comments | « include/gpu/GrDrawContext.h ('k') | src/gpu/SkGpuDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698