*/
void prepareForExternalIO();
+ /**
+ * Reads a rectangle of pixels from the draw context.
+ * @param dstInfo image info for the destination
+ * @param dstBuffer destination pixels for the read
+ * @param dstRowBytes bytes in a row of 'dstBuffer'
+ * @param x x offset w/in the draw context from which to read
+ * @param y y offset w/in the draw context from which to read
+ *
+ * @return true if the read succeeded, false if not. The read can fail because of an
+ * unsupported pixel config.
+ */
+ bool readPixels(const SkImageInfo& dstInfo, void* dstBuffer, size_t dstRowBytes, int x, int y);
+
+ /**
+ * Writes a rectangle of pixels [srcInfo, srcBuffer, srcRowbytes] into the
+ * drawContext at the specified position.
+ * @param srcInfo image info for the source pixels
+ * @param srcBuffer source for the write
+ * @param srcRowBytes bytes in a row of 'srcBuffer'
+ * @param x x offset w/in the draw context at which to write
+ * @param y y offset w/in the draw context at which to write
+ *
+ * @return true if the write succeeded, false if not. The write can fail because of an
+ * unsupported pixel config.
+ */
+ bool writePixels(const SkImageInfo& srcInfo, const void* srcBuffer, size_t srcRowBytes,
+ int x, int y);
+
bool isStencilBufferMultisampled() const {
return fRenderTarget->isStencilBufferMultisampled();
}
#include "../private/GrAuditTrail.h"
+#include "SkGr.h"
#include "SkLatticeIter.h"
#include "SkMatrixPriv.h"
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]) {
int x, int y) {
ASSERT_SINGLE_OWNER
- // 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 fDrawContext->accessRenderTarget()->readPixels(x, y,
- dstInfo.width(), dstInfo.height(),
- config, dstPixels,
- dstRowBytes, flags);
+ return fDrawContext->readPixels(dstInfo, dstPixels, dstRowBytes, x, y);
}
-bool SkGpuDevice::onWritePixels(const SkImageInfo& info, const void* pixels, size_t rowBytes,
- int x, int y) {
+bool SkGpuDevice::onWritePixels(const SkImageInfo& srcInfo, const void* srcPixels,
+ size_t srcRowBytes, int x, int y) {
ASSERT_SINGLE_OWNER
- // TODO: teach fRenderTarget to take ImageInfo directly to specify the src pixels
- GrPixelConfig config = SkImageInfo2GrPixelConfig(info, *fContext->caps());
- if (kUnknown_GrPixelConfig == config) {
- return false;
- }
- uint32_t flags = 0;
- if (kUnpremul_SkAlphaType == info.alphaType()) {
- flags = GrContext::kUnpremul_PixelOpsFlag;
- }
- return fDrawContext->accessRenderTarget()->writePixels(x, y, info.width(), info.height(),
- config, pixels, rowBytes, flags);
+
+ return fDrawContext->writePixels(srcInfo, srcPixels, srcRowBytes, x, y);
}
bool SkGpuDevice::onAccessPixels(SkPixmap* pmap) {