summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-12 17:36:39 +0000
committervandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-12 17:36:39 +0000
commita34f012a19f0915ba5ebc9ba8049763651839515 (patch)
tree00a4e4b273478b9655bbea4c5bcf7253262eab62
parent3035828750f79776b5aa13019663316ecfb8f582 (diff)
downloadchromium_src-a34f012a19f0915ba5ebc9ba8049763651839515.zip
chromium_src-a34f012a19f0915ba5ebc9ba8049763651839515.tar.gz
chromium_src-a34f012a19f0915ba5ebc9ba8049763651839515.tar.bz2
Push the initial transform down into SkPDFDevice. (Chrome side).
This change also rolls skis to r1111 to get the Skia side of the change. BUG=NONE TEST=NONE Review URL: http://codereview.chromium.org/6820038 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81267 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--DEPS2
-rw-r--r--printing/pdf_metafile_skia.cc12
-rw-r--r--skia/ext/vector_platform_device_skia.cc54
-rw-r--r--skia/ext/vector_platform_device_skia.h14
4 files changed, 26 insertions, 56 deletions
diff --git a/DEPS b/DEPS
index f0af7cf..a5c721d 100644
--- a/DEPS
+++ b/DEPS
@@ -12,7 +12,7 @@ vars = {
"libjingle_revision": "55",
"libvpx_revision": "76510",
"ffmpeg_revision": "79854",
- "skia_revision": "1110",
+ "skia_revision": "1111",
"v8_revision": "7579",
}
diff --git a/printing/pdf_metafile_skia.cc b/printing/pdf_metafile_skia.cc
index 72d8908..1d2b0798 100644
--- a/printing/pdf_metafile_skia.cc
+++ b/printing/pdf_metafile_skia.cc
@@ -9,6 +9,7 @@
#include "base/file_util.h"
#include "skia/ext/vector_platform_device_skia.h"
#include "third_party/skia/include/core/SkRefCnt.h"
+#include "third_party/skia/include/core/SkScalar.h"
#include "third_party/skia/include/core/SkStream.h"
#include "third_party/skia/include/pdf/SkPDFDevice.h"
#include "third_party/skia/include/pdf/SkPDFDocument.h"
@@ -40,11 +41,16 @@ skia::PlatformDevice* PdfMetafileSkia::StartPageForVectorCanvas(
const float& scale_factor) {
DCHECK(data_->current_page_.get() == NULL);
+ // Adjust for the margins and apply the scale factor.
+ SkMatrix transform;
+ transform.setTranslate(SkIntToScalar(content_origin.x()),
+ SkIntToScalar(content_origin.y()));
+ transform.preScale(SkFloatToScalar(scale_factor),
+ SkFloatToScalar(scale_factor));
+
skia::VectorPlatformDeviceSkia* device =
new skia::VectorPlatformDeviceSkia(page_size.width(), page_size.height(),
- SkPDFDevice::kFlip_OriginTransform);
- device->setInitialTransform(content_origin.x(), content_origin.y(),
- scale_factor);
+ transform);
data_->current_page_ = device->PdfDevice();
return device;
}
diff --git a/skia/ext/vector_platform_device_skia.cc b/skia/ext/vector_platform_device_skia.cc
index 8c064cb..db01169 100644
--- a/skia/ext/vector_platform_device_skia.cc
+++ b/skia/ext/vector_platform_device_skia.cc
@@ -19,10 +19,13 @@ SkDevice* VectorPlatformDeviceSkiaFactory::newDevice(SkCanvas* noUsed,
bool isOpaque,
bool isForLayer) {
SkASSERT(config == SkBitmap::kARGB_8888_Config);
- SkPDFDevice::OriginTransform flip = SkPDFDevice::kFlip_OriginTransform;
- if (isForLayer)
- flip = SkPDFDevice::kNoFlip_OriginTransform;
- return new VectorPlatformDeviceSkia(width, height, flip);
+ SkMatrix initialTransform;
+ initialTransform.reset();
+ if (isForLayer) {
+ initialTransform.setTranslate(0, height);
+ initialTransform.preScale(1, -1);
+ }
+ return new VectorPlatformDeviceSkia(width, height, initialTransform);
}
static inline SkBitmap makeABitmap(int width, int height) {
@@ -32,11 +35,10 @@ static inline SkBitmap makeABitmap(int width, int height) {
}
VectorPlatformDeviceSkia::VectorPlatformDeviceSkia(
- int width, int height, SkPDFDevice::OriginTransform flip)
+ int width, int height, const SkMatrix& initialTransform)
: PlatformDevice(makeABitmap(width, height)),
- pdf_device_(new SkPDFDevice(width, height, flip)) {
+ pdf_device_(new SkPDFDevice(width, height, initialTransform)) {
pdf_device_->unref(); // SkRefPtr and new both took a reference.
- base_transform_.reset();
}
VectorPlatformDeviceSkia::~VectorPlatformDeviceSkia() {
@@ -79,11 +81,8 @@ PlatformDevice::PlatformSurface VectorPlatformDeviceSkia::BeginPlatformPaint() {
void VectorPlatformDeviceSkia::EndPlatformPaint() {
DCHECK(raster_surface_ != NULL);
SkPaint paint;
- pdf_device_->drawSprite(SkDraw(),
- raster_surface_->accessBitmap(false),
- base_transform_.getTranslateX(),
- base_transform_.getTranslateY(),
- paint);
+ pdf_device_->drawSprite(SkDraw(), raster_surface_->accessBitmap(false),
+ 0, 0, paint);
raster_surface_ = NULL;
}
@@ -106,16 +105,7 @@ int VectorPlatformDeviceSkia::height() const {
void VectorPlatformDeviceSkia::setMatrixClip(const SkMatrix& matrix,
const SkRegion& region,
const SkClipStack& stack) {
- SkMatrix transform = base_transform_;
- transform.preConcat(matrix);
-
- DCHECK(SkMatrix::kTranslate_Mask == base_transform_.getType() ||
- SkMatrix::kIdentity_Mask == base_transform_.getType());
- SkRegion clip = region;
- clip.translate(base_transform_.getTranslateX(),
- base_transform_.getTranslateY());
-
- pdf_device_->setMatrixClip(transform, clip, stack);
+ pdf_device_->setMatrixClip(matrix, region, stack);
}
bool VectorPlatformDeviceSkia::readPixels(const SkIRect& srcRect,
@@ -231,24 +221,4 @@ void VectorPlatformDeviceSkia::drawToHDC(HDC dc,
}
#endif
-void VectorPlatformDeviceSkia::setInitialTransform(int xOffset, int yOffset,
- float scale_factor) {
- // TODO(vandebo) Supporting a scale factor is some work because we have to
- // transform both matrices and clips that come in, but Region only supports
- // translation. Instead, we could change SkPDFDevice to include it in the
- // initial transform. Delay that work until we would use it. Also checked
- // in setMatrixClip.
- DCHECK_EQ(1.0f, scale_factor);
-
- base_transform_.setTranslate(xOffset, yOffset);
- SkScalar scale = SkFloatToScalar(scale_factor);
- base_transform_.postScale(scale, scale);
-
- SkMatrix matrix;
- matrix.reset();
- SkRegion region;
- SkClipStack stack;
- setMatrixClip(matrix, region, stack);
-}
-
} // namespace skia
diff --git a/skia/ext/vector_platform_device_skia.h b/skia/ext/vector_platform_device_skia.h
index 48a40fe..f518f54 100644
--- a/skia/ext/vector_platform_device_skia.h
+++ b/skia/ext/vector_platform_device_skia.h
@@ -9,12 +9,12 @@
#include "base/basictypes.h"
#include "base/logging.h"
#include "skia/ext/platform_device.h"
-#include "third_party/skia/include/core/SkMatrix.h"
#include "third_party/skia/include/core/SkRefCnt.h"
#include "third_party/skia/include/core/SkTScopedPtr.h"
#include "third_party/skia/include/pdf/SkPDFDevice.h"
class SkClipStack;
+class SkMatrix;
struct SkIRect;
struct SkRect;
@@ -31,9 +31,9 @@ class VectorPlatformDeviceSkiaFactory : public SkDeviceFactory {
class VectorPlatformDeviceSkia : public PlatformDevice {
public:
- SK_API VectorPlatformDeviceSkia(int width, int height,
- SkPDFDevice::OriginTransform flip);
-
+ SK_API VectorPlatformDeviceSkia(int width,
+ int height,
+ const SkMatrix& initialTransform);
~VectorPlatformDeviceSkia();
SkPDFDevice* PdfDevice() { return pdf_device_.get(); }
@@ -88,14 +88,8 @@ class VectorPlatformDeviceSkia : public PlatformDevice {
virtual void drawToHDC(HDC dc, int x, int y, const RECT* src_rect);
#endif
- // Our own methods.
-
- // This needs to be called before anything is drawn.
- SK_API void setInitialTransform(int xOffset, int yOffset, float scale_factor);
-
private:
SkRefPtr<SkPDFDevice> pdf_device_;
- SkMatrix base_transform_;
SkRefPtr<BitmapPlatformDevice> raster_surface_;
DISALLOW_COPY_AND_ASSIGN(VectorPlatformDeviceSkia);