aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/SkBitmapDevice.cpp5
-rw-r--r--src/core/SkCanvas.cpp44
-rw-r--r--src/core/SkDevice.cpp4
-rw-r--r--src/core/SkPictureRecord.cpp7
-rw-r--r--src/core/SkPictureRecord.h4
-rw-r--r--src/gpu/SkGpuDevice.cpp5
-rw-r--r--src/utils/SkDeferredCanvas.cpp6
7 files changed, 59 insertions, 16 deletions
diff --git a/src/core/SkBitmapDevice.cpp b/src/core/SkBitmapDevice.cpp
index 4b4f45317f..5e70b1ab1b 100644
--- a/src/core/SkBitmapDevice.cpp
+++ b/src/core/SkBitmapDevice.cpp
@@ -10,6 +10,7 @@
#include "SkDraw.h"
#include "SkRasterClip.h"
#include "SkShader.h"
+#include "SkSurface.h"
#define CHECK_FOR_ANNOTATION(paint) \
do { if (paint.getAnnotation()) { return; } } while (0)
@@ -381,6 +382,10 @@ void SkBitmapDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device,
draw.drawSprite(src, x, y, paint);
}
+SkSurface* SkBitmapDevice::newSurface(const SkImageInfo& info) {
+ return SkSurface::NewRaster(info);
+}
+
///////////////////////////////////////////////////////////////////////////////
bool SkBitmapDevice::filterTextFlags(const SkPaint& paint, TextFlags* flags) {
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 08b09e8e2b..6f4e88da86 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -832,6 +832,26 @@ int SkCanvas::saveLayer(const SkRect* bounds, const SkPaint* paint,
return this->internalSaveLayer(bounds, paint, flags, false);
}
+static SkBaseDevice* createCompatibleDevice(SkCanvas* canvas,
+ SkBitmap::Config config,
+ int width, int height,
+ bool isOpaque) {
+ SkBaseDevice* device = canvas->getDevice();
+ if (device) {
+ return device->createCompatibleDevice(config, width, height, isOpaque);
+ } else {
+ return NULL;
+ }
+}
+
+#ifdef SK_SUPPORT_LEGACY_CANVAS_CREATECOMPATIBLEDEVICE
+SkBaseDevice* SkCanvas::createCompatibleDevice(SkBitmap::Config config,
+ int width, int height,
+ bool isOpaque) {
+ return createCompatibleDevice(this, config, width, height, isOpaque);
+}
+#endif
+
int SkCanvas::internalSaveLayer(const SkRect* bounds, const SkPaint* paint,
SaveFlags flags, bool justForImageFilter) {
// do this before we create the layer. We don't call the public save() since
@@ -864,8 +884,8 @@ int SkCanvas::internalSaveLayer(const SkRect* bounds, const SkPaint* paint,
SkBaseDevice* device;
if (paint && paint->getImageFilter()) {
- device = this->createCompatibleDevice(config, ir.width(), ir.height(),
- isOpaque);
+ device = createCompatibleDevice(this, config, ir.width(), ir.height(),
+ isOpaque);
} else {
device = this->createLayerDevice(config, ir.width(), ir.height(),
isOpaque);
@@ -964,6 +984,15 @@ bool SkCanvas::isDrawingToLayer() const {
return fSaveLayerCount > 0;
}
+SkSurface* SkCanvas::newSurface(const SkImageInfo& info) {
+ return this->onNewSurface(info);
+}
+
+SkSurface* SkCanvas::onNewSurface(const SkImageInfo& info) {
+ SkBaseDevice* dev = this->getDevice();
+ return dev ? dev->newSurface(info) : NULL;
+}
+
/////////////////////////////////////////////////////////////////////////////
// can't draw it if its empty, or its too big for a fixed-point width or height
@@ -1548,17 +1577,6 @@ SkBaseDevice* SkCanvas::createLayerDevice(SkBitmap::Config config,
}
}
-SkBaseDevice* SkCanvas::createCompatibleDevice(SkBitmap::Config config,
- int width, int height,
- bool isOpaque) {
- SkBaseDevice* device = this->getDevice();
- if (device) {
- return device->createCompatibleDevice(config, width, height, isOpaque);
- } else {
- return NULL;
- }
-}
-
GrContext* SkCanvas::getGrContext() {
#if SK_SUPPORT_GPU
SkBaseDevice* device = this->getTopDevice();
diff --git a/src/core/SkDevice.cpp b/src/core/SkDevice.cpp
index c08ae26159..9ce8b6b5df 100644
--- a/src/core/SkDevice.cpp
+++ b/src/core/SkDevice.cpp
@@ -1,4 +1,3 @@
-
/*
* Copyright 2011 Google Inc.
*
@@ -18,6 +17,7 @@
#endif
///////////////////////////////////////////////////////////////////////////////
+
SkBaseDevice::SkBaseDevice()
: fLeakyProperties(SkDeviceProperties::MakeDefault())
#ifdef SK_DEBUG
@@ -115,3 +115,5 @@ bool SkBaseDevice::readPixels(SkBitmap* bitmap, int x, int y,
}
return result;
}
+
+SkSurface* SkBaseDevice::newSurface(const SkImageInfo&) { return NULL; }
diff --git a/src/core/SkPictureRecord.cpp b/src/core/SkPictureRecord.cpp
index 3bf9851216..5ce35d6fe8 100644
--- a/src/core/SkPictureRecord.cpp
+++ b/src/core/SkPictureRecord.cpp
@@ -1,10 +1,10 @@
-
/*
* Copyright 2011 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
+
#include "SkPictureRecord.h"
#include "SkTSearch.h"
#include "SkPixelRef.h"
@@ -12,6 +12,7 @@
#include "SkBBoxHierarchy.h"
#include "SkDevice.h"
#include "SkPictureStateTree.h"
+#include "SkSurface.h"
#define HEAP_BLOCK_SIZE 4096
@@ -1316,6 +1317,10 @@ void SkPictureRecord::endCommentGroup() {
///////////////////////////////////////////////////////////////////////////////
+SkSurface* SkPictureRecord::onNewSurface(const SkImageInfo& info) {
+ return SkSurface::NewPicture(info.fWidth, info.fHeight);
+}
+
void SkPictureRecord::addBitmap(const SkBitmap& bitmap) {
const int index = fBitmapHeap->insert(bitmap);
// In debug builds, a bad return value from insert() will crash, allowing for debugging. In
diff --git a/src/core/SkPictureRecord.h b/src/core/SkPictureRecord.h
index 3832516427..6d14c621aa 100644
--- a/src/core/SkPictureRecord.h
+++ b/src/core/SkPictureRecord.h
@@ -1,10 +1,10 @@
-
/*
* Copyright 2011 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
+
#ifndef SkPictureRecord_DEFINED
#define SkPictureRecord_DEFINED
@@ -215,6 +215,8 @@ public:
#endif
protected:
+ virtual SkSurface* onNewSurface(const SkImageInfo&) SK_OVERRIDE;
+
// Return fontmetrics.fTop,fBottom in topbot[0,1], after they have been
// tweaked by paint.computeFastBounds().
static void ComputeFontMetricsTopBottom(const SkPaint& paint, SkScalar topbot[2]);
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index da56009c55..8c272f947a 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -27,6 +27,7 @@
#include "SkPathEffect.h"
#include "SkRRect.h"
#include "SkStroke.h"
+#include "SkSurface.h"
#include "SkTLazy.h"
#include "SkUtils.h"
#include "SkErrorInternals.h"
@@ -1913,6 +1914,10 @@ SkBaseDevice* SkGpuDevice::onCreateCompatibleDevice(SkBitmap::Config config,
}
}
+SkSurface* SkGpuDevice::newSurface(const SkImageInfo& info) {
+ return SkSurface::NewRenderTarget(fContext, info, fRenderTarget->numSamples());
+}
+
SkGpuDevice::SkGpuDevice(GrContext* context,
GrTexture* texture,
bool needClear)
diff --git a/src/utils/SkDeferredCanvas.cpp b/src/utils/SkDeferredCanvas.cpp
index 1cb6d3766a..efc65463b5 100644
--- a/src/utils/SkDeferredCanvas.cpp
+++ b/src/utils/SkDeferredCanvas.cpp
@@ -173,6 +173,8 @@ public:
virtual void writePixels(const SkBitmap& bitmap, int x, int y,
SkCanvas::Config8888 config8888) SK_OVERRIDE;
+ virtual SkSurface* newSurface(const SkImageInfo&) SK_OVERRIDE;
+
protected:
virtual const SkBitmap& onAccessBitmap() SK_OVERRIDE;
virtual bool onReadPixels(const SkBitmap& bitmap,
@@ -495,6 +497,10 @@ SkBaseDevice* DeferredDevice::onCreateCompatibleDevice(
return immediateDevice()->createCompatibleDevice(config, width, height, isOpaque);
}
+SkSurface* DeferredDevice::newSurface(const SkImageInfo& info) {
+ return this->immediateDevice()->newSurface(info);
+}
+
bool DeferredDevice::onReadPixels(
const SkBitmap& bitmap, int x, int y, SkCanvas::Config8888 config8888) {
this->flushPendingCommands(kNormal_PlaybackMode);