aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2014-11-12 14:31:11 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-11-12 14:31:11 -0800
commitb122ee50fb56cf6669fe1668b82c8815896e9943 (patch)
tree2239e51aab15b59943e71ff9b60e86a3b461789b /src
parente069400cabd0edd3db52bbf1958063d3ed12ef28 (diff)
start to replace onCreateDevice with onCreateCompatibleDevice
the new virtual takes a struct which we can amend in the future w/o having to update our subclasses in chrome. BUG=skia: NOTRY=True Review URL: https://codereview.chromium.org/723743002
Diffstat (limited to 'src')
-rw-r--r--src/core/SkBitmapDevice.cpp4
-rw-r--r--src/core/SkDevice.cpp6
-rw-r--r--src/gpu/SkGpuDevice.cpp12
-rw-r--r--src/gpu/SkGpuDevice.h2
-rw-r--r--src/pdf/SkPDFDevice.cpp8
-rw-r--r--src/utils/SkDeferredCanvas.cpp8
-rw-r--r--src/utils/SkPictureUtils.cpp6
7 files changed, 23 insertions, 23 deletions
diff --git a/src/core/SkBitmapDevice.cpp b/src/core/SkBitmapDevice.cpp
index cc4155a29f..0c28feadfc 100644
--- a/src/core/SkBitmapDevice.cpp
+++ b/src/core/SkBitmapDevice.cpp
@@ -111,8 +111,8 @@ void SkBitmapDevice::replaceBitmapBackendForRasterSurface(const SkBitmap& bm) {
fBitmap.lockPixels();
}
-SkBaseDevice* SkBitmapDevice::onCreateDevice(const SkImageInfo& info, Usage usage) {
- return SkBitmapDevice::Create(info);// &this->getDeviceProperties());
+SkBaseDevice* SkBitmapDevice::onCreateCompatibleDevice(const CreateInfo& cinfo) {
+ return SkBitmapDevice::Create(cinfo.fInfo);// &this->getDeviceProperties());
}
void SkBitmapDevice::lockPixels() {
diff --git a/src/core/SkDevice.cpp b/src/core/SkDevice.cpp
index 3d5000f569..20219a491a 100644
--- a/src/core/SkDevice.cpp
+++ b/src/core/SkDevice.cpp
@@ -29,15 +29,15 @@ SkBaseDevice::~SkBaseDevice() {
}
SkBaseDevice* SkBaseDevice::createCompatibleDevice(const SkImageInfo& info) {
- return this->onCreateDevice(info, kGeneral_Usage);
+ return this->onCreateCompatibleDevice(CreateInfo(info, kGeneral_Usage));
}
SkBaseDevice* SkBaseDevice::createCompatibleDeviceForSaveLayer(const SkImageInfo& info) {
- return this->onCreateDevice(info, kSaveLayer_Usage);
+ return this->onCreateCompatibleDevice(CreateInfo(info, kSaveLayer_Usage));
}
SkBaseDevice* SkBaseDevice::createCompatibleDeviceForImageFilter(const SkImageInfo& info) {
- return this->onCreateDevice(info, kImageFilter_Usage);
+ return this->onCreateCompatibleDevice(CreateInfo(info, kImageFilter_Usage));
}
SkMetaData& SkBaseDevice::getMetaData() {
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 124f994612..d04d2d8185 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -1751,24 +1751,24 @@ void SkGpuDevice::flush() {
///////////////////////////////////////////////////////////////////////////////
-SkBaseDevice* SkGpuDevice::onCreateDevice(const SkImageInfo& info, Usage usage) {
+SkBaseDevice* SkGpuDevice::onCreateCompatibleDevice(const CreateInfo& cinfo) {
GrSurfaceDesc desc;
desc.fConfig = fRenderTarget->config();
desc.fFlags = kRenderTarget_GrSurfaceFlag;
- desc.fWidth = info.width();
- desc.fHeight = info.height();
+ desc.fWidth = cinfo.fInfo.width();
+ desc.fHeight = cinfo.fInfo.height();
desc.fSampleCnt = fRenderTarget->numSamples();
SkAutoTUnref<GrTexture> texture;
// Skia's convention is to only clear a device if it is non-opaque.
- unsigned flags = info.isOpaque() ? 0 : kNeedClear_Flag;
+ unsigned flags = cinfo.fInfo.isOpaque() ? 0 : kNeedClear_Flag;
// If we're using distance field text, enable in the new device
flags |= (fFlags & kDFText_Flag) ? kDFText_Flag : 0;
#if CACHE_COMPATIBLE_DEVICE_TEXTURES
// layers are never draw in repeat modes, so we can request an approx
// match and ignore any padding.
- const GrContext::ScratchTexMatch match = (kSaveLayer_Usage == usage) ?
+ const GrContext::ScratchTexMatch match = (kSaveLayer_Usage == cinfo.fUsage) ?
GrContext::kApprox_ScratchTexMatch :
GrContext::kExact_ScratchTexMatch;
texture.reset(fContext->refScratchTexture(desc, match));
@@ -1779,7 +1779,7 @@ SkBaseDevice* SkGpuDevice::onCreateDevice(const SkImageInfo& info, Usage usage)
return SkGpuDevice::Create(texture, SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType), flags);
} else {
SkDebugf("---- failed to create compatible device texture [%d %d]\n",
- info.width(), info.height());
+ cinfo.fInfo.width(), cinfo.fInfo.height());
return NULL;
}
}
diff --git a/src/gpu/SkGpuDevice.h b/src/gpu/SkGpuDevice.h
index f7ff8c82a4..d90ecbcdff 100644
--- a/src/gpu/SkGpuDevice.h
+++ b/src/gpu/SkGpuDevice.h
@@ -142,7 +142,7 @@ private:
SkGpuDevice(GrSurface*, const SkSurfaceProps&, unsigned flags = 0);
- virtual SkBaseDevice* onCreateDevice(const SkImageInfo&, Usage) SK_OVERRIDE;
+ virtual SkBaseDevice* onCreateCompatibleDevice(const CreateInfo&) SK_OVERRIDE;
virtual SkSurface* newSurface(const SkImageInfo&, const SkSurfaceProps&) SK_OVERRIDE;
diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp
index b14ca72902..4395daca16 100644
--- a/src/pdf/SkPDFDevice.cpp
+++ b/src/pdf/SkPDFDevice.cpp
@@ -567,19 +567,19 @@ void GraphicStackState::updateDrawingState(const GraphicStateEntry& state) {
}
}
-SkBaseDevice* SkPDFDevice::onCreateDevice(const SkImageInfo& info, Usage usage) {
+SkBaseDevice* SkPDFDevice::onCreateCompatibleDevice(const CreateInfo& cinfo) {
// PDF does not support image filters, so render them on CPU.
// Note that this rendering is done at "screen" resolution (100dpi), not
// printer resolution.
// FIXME: It may be possible to express some filters natively using PDF
// to improve quality and file size (http://skbug.com/3043)
- if (kImageFilter_Usage == usage) {
- return SkBitmapDevice::Create(info);
+ if (kImageFilter_Usage == cinfo.fUsage) {
+ return SkBitmapDevice::Create(cinfo.fInfo);
}
SkMatrix initialTransform;
initialTransform.reset();
- SkISize size = SkISize::Make(info.width(), info.height());
+ SkISize size = SkISize::Make(cinfo.fInfo.width(), cinfo.fInfo.height());
return SkNEW_ARGS(SkPDFDevice, (size, size, initialTransform));
}
diff --git a/src/utils/SkDeferredCanvas.cpp b/src/utils/SkDeferredCanvas.cpp
index 06f7bb089a..c8216e4690 100644
--- a/src/utils/SkDeferredCanvas.cpp
+++ b/src/utils/SkDeferredCanvas.cpp
@@ -159,7 +159,7 @@ public:
virtual GrRenderTarget* accessRenderTarget() SK_OVERRIDE;
- virtual SkBaseDevice* onCreateDevice(const SkImageInfo&, Usage) SK_OVERRIDE;
+ virtual SkBaseDevice* onCreateCompatibleDevice(const CreateInfo&) SK_OVERRIDE;
virtual SkSurface* newSurface(const SkImageInfo&, const SkSurfaceProps&) SK_OVERRIDE;
@@ -463,15 +463,15 @@ const SkBitmap& SkDeferredDevice::onAccessBitmap() {
return immediateDevice()->accessBitmap(false);
}
-SkBaseDevice* SkDeferredDevice::onCreateDevice(const SkImageInfo& info, Usage usage) {
+SkBaseDevice* SkDeferredDevice::onCreateCompatibleDevice(const CreateInfo& cinfo) {
// Save layer usage not supported, and not required by SkDeferredCanvas.
- SkASSERT(usage != kSaveLayer_Usage);
+ SkASSERT(cinfo.fUsage != kSaveLayer_Usage);
// Create a compatible non-deferred device.
// We do not create a deferred device because we know the new device
// will not be used with a deferred canvas (there is no API for that).
// And connecting a SkDeferredDevice to non-deferred canvas can result
// in unpredictable behavior.
- return immediateDevice()->createCompatibleDevice(info);
+ return immediateDevice()->onCreateCompatibleDevice(cinfo);
}
SkSurface* SkDeferredDevice::newSurface(const SkImageInfo& info, const SkSurfaceProps& props) {
diff --git a/src/utils/SkPictureUtils.cpp b/src/utils/SkPictureUtils.cpp
index 391e5ffc79..3127497ff0 100644
--- a/src/utils/SkPictureUtils.cpp
+++ b/src/utils/SkPictureUtils.cpp
@@ -157,10 +157,10 @@ protected:
virtual void replaceBitmapBackendForRasterSurface(const SkBitmap&) SK_OVERRIDE {
not_supported();
}
- virtual SkBaseDevice* onCreateDevice(const SkImageInfo& info, Usage usage) SK_OVERRIDE {
+ virtual SkBaseDevice* onCreateCompatibleDevice(const CreateInfo& cinfo) SK_OVERRIDE {
// we expect to only get called via savelayer, in which case it is fine.
- SkASSERT(kSaveLayer_Usage == usage);
- return SkNEW_ARGS(GatherPixelRefDevice, (info.width(), info.height(), fPRSet));
+ SkASSERT(kSaveLayer_Usage == cinfo.fUsage);
+ return SkNEW_ARGS(GatherPixelRefDevice, (cinfo.fInfo.width(), cinfo.fInfo.height(), fPRSet));
}
virtual void flush() SK_OVERRIDE {}