aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-03-12 18:28:35 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-03-12 18:28:35 +0000
commit9c135db83d198e7d8200027c7d2cf60f38517ee3 (patch)
treee4ba92d604d39ea5947eb3d282c86df44adab67c /src/core
parent9d201d6364b259876abf80e26308320db925ced5 (diff)
support direct writing to top layer, and hide getTopLayer()
this should remove many of the chrome callers that today call accessBitmap on the toplayer, so they can read/write those pixels. The ultimate fix will be to support custom allocation of raster layers (via GDI/cairo/mac) so we can remove PlatformDevice subclassing in skia/ext BUG=skia: R=bsalomon@google.com, scroggo@google.com Review URL: https://codereview.chromium.org/197433002 git-svn-id: http://skia.googlecode.com/svn/trunk@13774 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core')
-rw-r--r--src/core/SkBitmapDevice.cpp9
-rw-r--r--src/core/SkCanvas.cpp14
-rw-r--r--src/core/SkDevice.cpp16
3 files changed, 39 insertions, 0 deletions
diff --git a/src/core/SkBitmapDevice.cpp b/src/core/SkBitmapDevice.cpp
index 098f0fc96c..8524f0b72b 100644
--- a/src/core/SkBitmapDevice.cpp
+++ b/src/core/SkBitmapDevice.cpp
@@ -268,6 +268,15 @@ void SkBitmapDevice::writePixels(const SkBitmap& bitmap,
}
#endif
+void* SkBitmapDevice::onAccessPixels(SkImageInfo* info, size_t* rowBytes) {
+ if (fBitmap.getPixels()) {
+ *info = fBitmap.info();
+ *rowBytes = fBitmap.rowBytes();
+ return fBitmap.getPixels();
+ }
+ return NULL;
+}
+
static void rect_memcpy(void* dst, size_t dstRB, const void* src, size_t srcRB, size_t bytesPerRow,
int rowCount) {
SkASSERT(bytesPerRow <= srcRB);
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 9fbb37bf31..4086291507 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -1040,6 +1040,15 @@ const void* SkCanvas::onPeekPixels(SkImageInfo* info, size_t* rowBytes) {
return dev ? dev->peekPixels(info, rowBytes) : NULL;
}
+void* SkCanvas::accessTopLayerPixels(SkImageInfo* info, size_t* rowBytes) {
+ return this->onAccessTopLayerPixels(info, rowBytes);
+}
+
+void* SkCanvas::onAccessTopLayerPixels(SkImageInfo* info, size_t* rowBytes) {
+ SkBaseDevice* dev = this->getTopDevice();
+ return dev ? dev->accessPixels(info, rowBytes) : NULL;
+}
+
SkAutoROCanvasPixels::SkAutoROCanvasPixels(SkCanvas* canvas) {
fAddr = canvas->peekPixels(&fInfo, &fRowBytes);
if (NULL == fAddr) {
@@ -1713,6 +1722,11 @@ void SkCanvas::internal_private_getTotalClipAsPath(SkPath* path) const {
(void)rgn.getBoundaryPath(path);
}
+GrRenderTarget* SkCanvas::internal_private_accessTopLayerRenderTarget() {
+ SkBaseDevice* dev = this->getTopDevice();
+ return dev ? dev->accessRenderTarget() : NULL;
+}
+
SkBaseDevice* SkCanvas::createLayerDevice(const SkImageInfo& info) {
SkBaseDevice* device = this->getTopDevice();
return device ? device->createCompatibleDeviceForSaveLayer(info) : NULL;
diff --git a/src/core/SkDevice.cpp b/src/core/SkDevice.cpp
index 666e456e8c..587181302d 100644
--- a/src/core/SkDevice.cpp
+++ b/src/core/SkDevice.cpp
@@ -194,6 +194,22 @@ bool SkBaseDevice::onReadPixels(const SkBitmap&, int x, int y, SkCanvas::Config8
return false;
}
+void* SkBaseDevice::accessPixels(SkImageInfo* info, size_t* rowBytes) {
+ SkImageInfo tmpInfo;
+ size_t tmpRowBytes;
+ if (NULL == info) {
+ info = &tmpInfo;
+ }
+ if (NULL == rowBytes) {
+ rowBytes = &tmpRowBytes;
+ }
+ return this->onAccessPixels(info, rowBytes);
+}
+
+void* SkBaseDevice::onAccessPixels(SkImageInfo* info, size_t* rowBytes) {
+ return NULL;
+}
+
#ifdef SK_SUPPORT_LEGACY_WRITEPIXELSCONFIG
void SkBaseDevice::writePixels(const SkBitmap&, int x, int y, SkCanvas::Config8888) {}
#endif