aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/SkBitmapDevice.cpp10
-rw-r--r--src/core/SkDevice.cpp9
-rw-r--r--src/gpu/SkGpuDevice.cpp18
-rw-r--r--src/gpu/SkGpuDevice.h10
-rw-r--r--src/pdf/SkPDFDevice.cpp8
-rw-r--r--src/pdf/SkPDFDevice.h2
-rw-r--r--src/svg/SkSVGDevice.cpp10
-rw-r--r--src/svg/SkSVGDevice.h3
8 files changed, 28 insertions, 42 deletions
diff --git a/src/core/SkBitmapDevice.cpp b/src/core/SkBitmapDevice.cpp
index 41416e733b..75eaa963b5 100644
--- a/src/core/SkBitmapDevice.cpp
+++ b/src/core/SkBitmapDevice.cpp
@@ -69,7 +69,7 @@ static bool valid_for_bitmap_device(const SkImageInfo& info,
}
SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap)
- : INHERITED(SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType))
+ : INHERITED(bitmap.info(), SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType))
, fBitmap(bitmap)
{
SkASSERT(valid_for_bitmap_device(bitmap.info(), nullptr));
@@ -81,7 +81,7 @@ SkBitmapDevice* SkBitmapDevice::Create(const SkImageInfo& info) {
}
SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap, const SkSurfaceProps& surfaceProps)
- : INHERITED(surfaceProps)
+ : INHERITED(bitmap.info(), surfaceProps)
, fBitmap(bitmap)
{
SkASSERT(valid_for_bitmap_device(bitmap.info(), nullptr));
@@ -120,13 +120,10 @@ SkBitmapDevice* SkBitmapDevice::Create(const SkImageInfo& origInfo,
return new SkBitmapDevice(bitmap, surfaceProps);
}
-SkImageInfo SkBitmapDevice::imageInfo() const {
- return fBitmap.info();
-}
-
void SkBitmapDevice::setNewSize(const SkISize& size) {
SkASSERT(!fBitmap.pixelRef());
fBitmap.setInfo(fBitmap.info().makeWH(size.fWidth, size.fHeight));
+ this->privateResize(fBitmap.info().width(), fBitmap.info().height());
}
void SkBitmapDevice::replaceBitmapBackendForRasterSurface(const SkBitmap& bm) {
@@ -134,6 +131,7 @@ void SkBitmapDevice::replaceBitmapBackendForRasterSurface(const SkBitmap& bm) {
SkASSERT(bm.height() == fBitmap.height());
fBitmap = bm; // intent is to use bm's pixelRef (and rowbytes/config)
fBitmap.lockPixels();
+ this->privateResize(fBitmap.info().width(), fBitmap.info().height());
}
SkBaseDevice* SkBitmapDevice::onCreateDevice(const CreateInfo& cinfo, const SkPaint*) {
diff --git a/src/core/SkDevice.cpp b/src/core/SkDevice.cpp
index 5eaf44d419..4534c2fea2 100644
--- a/src/core/SkDevice.cpp
+++ b/src/core/SkDevice.cpp
@@ -24,7 +24,10 @@
#include "SkTextBlobRunIterator.h"
#include "SkTextToPathIter.h"
-SkBaseDevice::SkBaseDevice(const SkSurfaceProps& surfaceProps) : fSurfaceProps(surfaceProps) {
+SkBaseDevice::SkBaseDevice(const SkImageInfo& info, const SkSurfaceProps& surfaceProps)
+ : fInfo(info)
+ , fSurfaceProps(surfaceProps)
+{
fOrigin.setZero();
fMetaData = nullptr;
}
@@ -40,10 +43,6 @@ SkMetaData& SkBaseDevice::getMetaData() {
return *fMetaData;
}
-SkImageInfo SkBaseDevice::imageInfo() const {
- return SkImageInfo::MakeUnknown();
-}
-
#ifdef SK_SUPPORT_LEGACY_ACCESSBITMAP
const SkBitmap& SkBaseDevice::accessBitmap(bool changePixels) {
const SkBitmap& bitmap = this->onAccessBitmap();
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 040833b731..258355e497 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -122,10 +122,22 @@ sk_sp<SkGpuDevice> SkGpuDevice::Make(GrContext* context, SkBudgeted budgeted,
info.width(), info.height(), flags));
}
-SkGpuDevice::SkGpuDevice(sk_sp<GrDrawContext> drawContext, int width, int height, unsigned flags)
- : INHERITED(drawContext->surfaceProps())
+static SkImageInfo make_info(GrDrawContext* context, int w, int h, bool opaque) {
+ SkColorType colorType;
+ if (!GrPixelConfigToColorType(context->config(), &colorType)) {
+ colorType = kUnknown_SkColorType;
+ }
+ return SkImageInfo::Make(w, h, colorType,
+ opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType,
+ sk_ref_sp(context->getColorSpace()));
+}
+
+SkGpuDevice::SkGpuDevice(sk_sp<GrDrawContext> drawContext, int width, int height, unsigned flags)
+ : INHERITED(make_info(drawContext.get(), width, height, SkToBool(flags & kIsOpaque_Flag)),
+ drawContext->surfaceProps())
, fContext(SkRef(drawContext->accessRenderTarget()->getContext()))
- , fDrawContext(std::move(drawContext)) {
+ , fDrawContext(std::move(drawContext))
+{
fSize.set(width, height);
fOpaque = SkToBool(flags & kIsOpaque_Flag);
diff --git a/src/gpu/SkGpuDevice.h b/src/gpu/SkGpuDevice.h
index d5fe04febf..4de0a50f4b 100644
--- a/src/gpu/SkGpuDevice.h
+++ b/src/gpu/SkGpuDevice.h
@@ -66,16 +66,6 @@ public:
GrDrawContext* accessDrawContext() override;
- SkImageInfo imageInfo() const override {
- SkColorType colorType;
- if (!GrPixelConfigToColorType(fDrawContext->config(), &colorType)) {
- colorType = kUnknown_SkColorType;
- }
- return SkImageInfo::Make(fSize.fWidth, fSize.fHeight, colorType,
- fOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType,
- sk_ref_sp(fDrawContext->getColorSpace()));
- }
-
void drawPaint(const SkDraw&, const SkPaint& paint) override;
virtual void drawPoints(const SkDraw&, SkCanvas::PointMode mode, size_t count,
const SkPoint[], const SkPaint& paint) override;
diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp
index edf17280ef..73d41b1c36 100644
--- a/src/pdf/SkPDFDevice.cpp
+++ b/src/pdf/SkPDFDevice.cpp
@@ -559,7 +559,8 @@ private:
////////////////////////////////////////////////////////////////////////////////
SkPDFDevice::SkPDFDevice(SkISize pageSize, SkScalar rasterDpi, SkPDFDocument* doc, bool flip)
- : INHERITED(SkSurfaceProps(0, kUnknown_SkPixelGeometry))
+ : INHERITED(SkImageInfo::MakeUnknown(pageSize.width(), pageSize.height()),
+ SkSurfaceProps(0, kUnknown_SkPixelGeometry))
, fPageSize(pageSize)
, fContentSize(pageSize)
, fExistingClipRegion(SkIRect::MakeSize(pageSize))
@@ -1294,11 +1295,6 @@ void SkPDFDevice::drawDevice(const SkDraw& d, SkBaseDevice* device,
&content.entry()->fContent);
}
-SkImageInfo SkPDFDevice::imageInfo() const {
- SkImageInfo info = SkImageInfo::MakeUnknown(fPageSize.width(), fPageSize.height());
- return info;
-}
-
sk_sp<SkSurface> SkPDFDevice::makeSurface(const SkImageInfo& info, const SkSurfaceProps& props) {
return SkSurface::MakeRaster(info, &props);
}
diff --git a/src/pdf/SkPDFDevice.h b/src/pdf/SkPDFDevice.h
index 4a860281e3..6588efb8d1 100644
--- a/src/pdf/SkPDFDevice.h
+++ b/src/pdf/SkPDFDevice.h
@@ -119,8 +119,6 @@ public:
void drawDevice(const SkDraw&, SkBaseDevice*, int x, int y,
const SkPaint&) override;
- SkImageInfo imageInfo() const override;
-
// PDF specific methods.
/** Create the resource dictionary for this device. */
diff --git a/src/svg/SkSVGDevice.cpp b/src/svg/SkSVGDevice.cpp
index 4330901b7e..3ba721ee39 100644
--- a/src/svg/SkSVGDevice.cpp
+++ b/src/svg/SkSVGDevice.cpp
@@ -570,10 +570,11 @@ SkBaseDevice* SkSVGDevice::Create(const SkISize& size, SkXMLWriter* writer) {
}
SkSVGDevice::SkSVGDevice(const SkISize& size, SkXMLWriter* writer)
- : INHERITED(SkSurfaceProps(0, kUnknown_SkPixelGeometry))
+ : INHERITED(SkImageInfo::MakeUnknown(size.fWidth, size.fHeight),
+ SkSurfaceProps(0, kUnknown_SkPixelGeometry))
, fWriter(writer)
, fResourceBucket(new ResourceBucket)
- , fSize(size) {
+{
SkASSERT(writer);
fWriter->writeHeader();
@@ -590,11 +591,6 @@ SkSVGDevice::SkSVGDevice(const SkISize& size, SkXMLWriter* writer)
SkSVGDevice::~SkSVGDevice() {
}
-SkImageInfo SkSVGDevice::imageInfo() const {
- SkImageInfo info = SkImageInfo::MakeUnknown(fSize.fWidth, fSize.fHeight);
- return info;
-}
-
void SkSVGDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) {
AutoElement rect("rect", fWriter, fResourceBucket, draw, paint);
rect.addRectAttributes(SkRect::MakeWH(SkIntToScalar(this->width()),
diff --git a/src/svg/SkSVGDevice.h b/src/svg/SkSVGDevice.h
index bf86e15c51..cb13ffdc8c 100644
--- a/src/svg/SkSVGDevice.h
+++ b/src/svg/SkSVGDevice.h
@@ -17,8 +17,6 @@ class SkSVGDevice : public SkBaseDevice {
public:
static SkBaseDevice* Create(const SkISize& size, SkXMLWriter* writer);
- SkImageInfo imageInfo() const override;
-
protected:
void drawPaint(const SkDraw&, const SkPaint& paint) override;
void drawPoints(const SkDraw&, SkCanvas::PointMode mode, size_t count,
@@ -68,7 +66,6 @@ private:
SkXMLWriter* fWriter;
SkAutoTDelete<AutoElement> fRootElement;
SkAutoTDelete<ResourceBucket> fResourceBucket;
- SkISize fSize;
typedef SkBaseDevice INHERITED;
};