Index: skia/ext/vector_platform_device_skia.cc |
=================================================================== |
--- skia/ext/vector_platform_device_skia.cc (revision 96545) |
+++ skia/ext/vector_platform_device_skia.cc (working copy) |
@@ -5,6 +5,7 @@ |
#include "skia/ext/vector_platform_device_skia.h" |
#include "skia/ext/bitmap_platform_device.h" |
+#include "skia/ext/platform_canvas.h" |
#include "third_party/skia/include/core/SkClipStack.h" |
#include "third_party/skia/include/core/SkDraw.h" |
#include "third_party/skia/include/core/SkRect.h" |
@@ -20,8 +21,8 @@ |
} |
VectorPlatformDeviceSkia::VectorPlatformDeviceSkia(SkPDFDevice* pdf_device) |
- : PlatformDevice(makeABitmap(pdf_device->width(), pdf_device->height())), |
- pdf_device_(pdf_device) { |
+ : PlatformDevice(pdf_device) {//PlatformDevice(makeABitmap(pdf_device->width(), pdf_device->height())), |
+ //pdf_device_(pdf_device) { |
} |
VectorPlatformDeviceSkia::~VectorPlatformDeviceSkia() { |
@@ -39,36 +40,49 @@ |
// image in EndPlatformPaint. |
DCHECK(raster_surface_ == NULL); |
#if defined(OS_WIN) |
- raster_surface_ = BitmapPlatformDevice::create(pdf_device_->width(), |
- pdf_device_->height(), |
+ raster_surface_ = BitmapPlatformDevice::create(GetOwningDevice()->width(), |
+ GetOwningDevice()->height(), |
false, /* not opaque */ |
NULL); |
#elif defined(OS_POSIX) && !defined(OS_MACOSX) |
- raster_surface_ = BitmapPlatformDevice::Create(pdf_device_->width(), |
- pdf_device_->height(), |
+ raster_surface_ = BitmapPlatformDevice::Create(GetOwningDevice()->width(), |
+ GetOwningDevice()->height(), |
false /* not opaque */); |
#endif |
raster_surface_->unref(); // SkRefPtr and create both took a reference. |
- SkCanvas canvas(raster_surface_.get()); |
- return raster_surface_->BeginPlatformPaint(); |
+ //SkCanvas canvas(raster_surface_.get()); |
+ raster_canvas_ = new SkCanvas(raster_surface_.get()); |
+ //return raster_surface_->BeginPlatformPaint(); |
+ return skia::BeginPlatformPaint(raster_canvas_.get()); |
} |
void VectorPlatformDeviceSkia::EndPlatformPaint() { |
DCHECK(raster_surface_ != NULL); |
+ |
+ // BitmapPlatformDevice matches begin and end calls. |
+ skia::EndPlatformPaint(raster_canvas_.get()); |
Jeff Timanus
2011/08/12 23:59:22
This was an example of where BitmapPlatformDevice:
|
SkPaint paint; |
// SkPDFDevice checks the passed SkDraw for an empty clip (only). Fake |
// it out by setting a non-empty clip. |
SkDraw draw; |
- SkRegion clip(SkIRect::MakeWH(pdf_device_->width(), pdf_device_->height())); |
+ SkRegion clip(SkIRect::MakeWH(GetOwningDevice()->width(), |
+ GetOwningDevice()->height())); |
draw.fClip=&clip; |
- pdf_device_->drawSprite(draw, raster_surface_->accessBitmap(false), 0, 0, |
- paint); |
- // BitmapPlatformDevice matches begin and end calls. |
- raster_surface_->EndPlatformPaint(); |
+ |
+ SkCanvas pdf_canvas(GetOwningDevice()); |
vandebo (ex-Chrome)
2011/08/15 19:52:10
Will using two different canvases (with different
Jeff Timanus
2011/08/15 20:06:25
A third option is to make drawSprite a public entr
vandebo (ex-Chrome)
2011/08/15 20:13:56
I don't think either of these are particularly cle
|
+ pdf_canvas.drawSprite(raster_surface_->accessBitmap(false), 0, 0, &paint); |
+#if 0 |
+ GetOwningDevice()->drawSprite( |
+ draw, |
+ raster_surface_->accessBitmap(false), 0, 0, paint); |
+#endif |
+ //raster_surface_->EndPlatformPaint(); |
+ raster_canvas_ = NULL; |
raster_surface_ = NULL; |
} |
+#if 0 |
uint32_t VectorPlatformDeviceSkia::getDeviceCapabilities() { |
return SkDevice::getDeviceCapabilities() | kVector_Capability; |
} |
@@ -190,6 +204,7 @@ |
} |
pdf_device_->drawDevice(draw, real_device, x, y, paint); |
} |
+#endif |
#if defined(OS_WIN) |
void VectorPlatformDeviceSkia::DrawToNativeContext(HDC dc, |
@@ -211,6 +226,7 @@ |
#endif |
+#if 0 |
SkDevice* VectorPlatformDeviceSkia::onCreateCompatibleDevice( |
SkBitmap::Config config, int width, int height, bool isOpaque, |
Usage /*usage*/) { |
@@ -219,5 +235,6 @@ |
isOpaque)); |
return new VectorPlatformDeviceSkia(static_cast<SkPDFDevice*>(dev.get())); |
} |
+#endif |
} // namespace skia |