Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(120)

Unified Diff: src/pdf/SkPDFDevice.cpp

Issue 354133002: change gpudevice and pdfdevice to inherit from basedevice (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/pdf/SkPDFDevice.cpp
diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp
index ab4d71d37f8f24bd9a91ae188ca34bdd208b0cd6..f4db93799d9f1fdeb0648a9c5ed8e87383653a59 100644
--- a/src/pdf/SkPDFDevice.cpp
+++ b/src/pdf/SkPDFDevice.cpp
@@ -702,8 +702,8 @@ private:
////////////////////////////////////////////////////////////////////////////////
robertphillips 2014/06/27 12:02:58 Shouldn't this be make_content_info ?
reed1 2014/06/27 12:39:42 Done.
-static inline SkBitmap makeContentBitmap(const SkISize& contentSize,
- const SkMatrix* initialTransform) {
+static inline SkImageInfo makeContentInfo(const SkISize& contentSize,
+ const SkMatrix* initialTransform) {
SkImageInfo info;
if (initialTransform) {
// Compute the size of the drawing area.
@@ -723,24 +723,21 @@ static inline SkBitmap makeContentBitmap(const SkISize& contentSize,
info = SkImageInfo::MakeUnknown(abs(contentSize.fWidth),
abs(contentSize.fHeight));
}
-
- SkBitmap bitmap;
- bitmap.setInfo(info);
- return bitmap;
+ return info;
}
// TODO(vandebo) change pageSize to SkSize.
robertphillips 2014/06/27 12:02:58 Remove this TODO ?
reed1 2014/06/27 12:39:42 Done.
// TODO: inherit from SkBaseDevice instead of SkBitmapDevice
SkPDFDevice::SkPDFDevice(const SkISize& pageSize, const SkISize& contentSize,
const SkMatrix& initialTransform)
- : SkBitmapDevice(makeContentBitmap(contentSize, &initialTransform)),
- fPageSize(pageSize),
- fContentSize(contentSize),
- fLastContentEntry(NULL),
- fLastMarginContentEntry(NULL),
- fClipStack(NULL),
- fEncoder(NULL),
- fRasterDpi(72.0f) {
+ : fPageSize(pageSize)
+ , fContentSize(contentSize)
+ , fLastContentEntry(NULL)
+ , fLastMarginContentEntry(NULL)
+ , fClipStack(NULL)
+ , fEncoder(NULL)
+ , fRasterDpi(72.0f)
+{
// Just report that PDF does not supports perspective in the
// initial transform.
NOT_IMPLEMENTED(initialTransform.hasPerspective(), true);
@@ -754,7 +751,7 @@ SkPDFDevice::SkPDFDevice(const SkISize& pageSize, const SkISize& contentSize,
SkIRect existingClip = SkIRect::MakeWH(this->width(), this->height());
fExistingClipRegion.setRect(existingClip);
-
+ fLegacyBitmap.setInfo(makeContentInfo(contentSize, &initialTransform));
this->init();
}
@@ -762,17 +759,19 @@ SkPDFDevice::SkPDFDevice(const SkISize& pageSize, const SkISize& contentSize,
SkPDFDevice::SkPDFDevice(const SkISize& layerSize,
const SkClipStack& existingClipStack,
const SkRegion& existingClipRegion)
- : SkBitmapDevice(makeContentBitmap(layerSize, NULL)),
- fPageSize(layerSize),
- fContentSize(layerSize),
- fExistingClipStack(existingClipStack),
- fExistingClipRegion(existingClipRegion),
- fLastContentEntry(NULL),
- fLastMarginContentEntry(NULL),
- fClipStack(NULL),
- fEncoder(NULL),
- fRasterDpi(72.0f) {
+ : fPageSize(layerSize)
+ , fContentSize(layerSize)
+ , fExistingClipStack(existingClipStack)
+ , fExistingClipRegion(existingClipRegion)
+ , fLastContentEntry(NULL)
+ , fLastMarginContentEntry(NULL)
+ , fClipStack(NULL)
+ , fEncoder(NULL)
+ , fRasterDpi(72.0f)
+{
fInitialTransform.reset();
+ fLegacyBitmap.setInfo(makeContentInfo(layerSize, NULL));
+
this->init();
}
@@ -961,13 +960,18 @@ void SkPDFDevice::drawRect(const SkDraw& d, const SkRect& rect,
&content.entry()->fContent);
}
-void SkPDFDevice::drawRRect(const SkDraw& draw, const SkRRect& rrect,
- const SkPaint& paint) {
+void SkPDFDevice::drawRRect(const SkDraw& draw, const SkRRect& rrect, const SkPaint& paint) {
SkPath path;
path.addRRect(rrect);
this->drawPath(draw, path, paint, NULL, true);
}
+void SkPDFDevice::drawOval(const SkDraw& draw, const SkRect& oval, const SkPaint& paint) {
+ SkPath path;
+ path.addOval(oval);
+ this->drawPath(draw, path, paint, NULL, true);
+}
+
void SkPDFDevice::drawPath(const SkDraw& d, const SkPath& origPath,
const SkPaint& paint, const SkMatrix* prePathMatrix,
bool pathIsMutable) {
@@ -2237,8 +2241,7 @@ void SkPDFDevice::internalDrawBitmap(const SkMatrix& origMatrix,
}
perspectiveBitmap.eraseColor(SK_ColorTRANSPARENT);
- SkBitmapDevice device(perspectiveBitmap);
- SkCanvas canvas(&device);
+ SkCanvas canvas(perspectiveBitmap);
SkScalar deltaX = bounds.left();
SkScalar deltaY = bounds.top();
@@ -2305,6 +2308,10 @@ void SkPDFDevice::internalDrawBitmap(const SkMatrix& origMatrix,
&content.entry()->fContent);
}
robertphillips 2014/06/27 12:02:58 Can these last two be put in the header ?
reed1 2014/06/27 12:39:42 Done.
+const SkBitmap& SkPDFDevice::onAccessBitmap() {
+ return fLegacyBitmap;
+}
+
bool SkPDFDevice::allowImageFilter(const SkImageFilter*) {
return false;
}

Powered by Google App Engine
This is Rietveld 408576698