Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / skia / src / core / SkPictureRecorder.cpp
index 7d24caf..77274e6 100644 (file)
@@ -17,19 +17,29 @@ SkPictureRecorder::SkPictureRecorder() {}
 
 SkPictureRecorder::~SkPictureRecorder() {}
 
-SkCanvas* SkPictureRecorder::beginRecording(int width, int height,
+SkCanvas* SkPictureRecorder::beginRecording(SkScalar width, SkScalar height,
                                             SkBBHFactory* bbhFactory /* = NULL */,
                                             uint32_t recordFlags /* = 0 */) {
-    fWidth = width;
-    fHeight = height;
+#ifdef SK_PICTURE_USE_SK_RECORD
+    return EXPERIMENTAL_beginRecording(width, height, bbhFactory);
+#else
+    return DEPRECATED_beginRecording(width, height, bbhFactory, recordFlags);
+#endif
+}
+
+SkCanvas* SkPictureRecorder::DEPRECATED_beginRecording(SkScalar width, SkScalar height,
+                                                       SkBBHFactory* bbhFactory /* = NULL */,
+                                                       uint32_t recordFlags /* = 0 */) {
+    fCullWidth = width;
+    fCullHeight = height;
 
     const SkISize size = SkISize::Make(width, height);
 
-    if (NULL != bbhFactory) {
+    if (bbhFactory) {
         // We don't need to hold a ref on the BBH ourselves, but might as well for
         // consistency with EXPERIMENTAL_beginRecording(), which does need to.
         fBBH.reset((*bbhFactory)(width, height));
-        SkASSERT(NULL != fBBH.get());
+        SkASSERT(fBBH.get());
         fPictureRecord.reset(SkNEW_ARGS(SkBBoxHierarchyRecord, (size, recordFlags, fBBH.get())));
     } else {
         fPictureRecord.reset(SkNEW_ARGS(SkPictureRecord, (size, recordFlags)));
@@ -39,14 +49,14 @@ SkCanvas* SkPictureRecorder::beginRecording(int width, int height,
     return this->getRecordingCanvas();
 }
 
-SkCanvas* SkPictureRecorder::EXPERIMENTAL_beginRecording(int width, int height,
+SkCanvas* SkPictureRecorder::EXPERIMENTAL_beginRecording(SkScalar width, SkScalar height,
                                                          SkBBHFactory* bbhFactory /* = NULL */) {
-    fWidth = width;
-    fHeight = height;
+    fCullWidth = width;
+    fCullHeight = height;
 
-    if (NULL != bbhFactory) {
+    if (bbhFactory) {
         fBBH.reset((*bbhFactory)(width, height));
-        SkASSERT(NULL != fBBH.get());
+        SkASSERT(fBBH.get());
     }
 
     fRecord.reset(SkNEW(SkRecord));
@@ -55,7 +65,7 @@ SkCanvas* SkPictureRecorder::EXPERIMENTAL_beginRecording(int width, int height,
 }
 
 SkCanvas* SkPictureRecorder::getRecordingCanvas() {
-    if (NULL != fRecorder.get()) {
+    if (fRecorder.get()) {
         return fRecorder.get();
     }
     return fPictureRecord.get();
@@ -64,21 +74,23 @@ SkCanvas* SkPictureRecorder::getRecordingCanvas() {
 SkPicture* SkPictureRecorder::endRecording() {
     SkPicture* picture = NULL;
 
-    if (NULL != fRecord.get()) {
-        picture = SkNEW_ARGS(SkPicture, (fWidth, fHeight, fRecord.detach(), fBBH.get()));
+    if (fRecord.get()) {
+        picture = SkNEW_ARGS(SkPicture, (fCullWidth, fCullHeight, 
+                                         fRecord.detach(), fBBH.get()));
     }
 
-    if (NULL != fPictureRecord.get()) {
+    if (fPictureRecord.get()) {
         fPictureRecord->endRecording();
         const bool deepCopyOps = false;
-        picture = SkNEW_ARGS(SkPicture, (fWidth, fHeight, *fPictureRecord.get(), deepCopyOps));
+        picture = SkNEW_ARGS(SkPicture, (fCullWidth, fCullHeight, 
+                                         *fPictureRecord.get(), deepCopyOps));
     }
 
     return picture;
 }
 
 void SkPictureRecorder::internalOnly_EnableOpts(bool enableOpts) {
-    if (NULL != fPictureRecord.get()) {
+    if (fPictureRecord.get()) {
         fPictureRecord->internalOnly_EnableOpts(enableOpts);
     }
 }
@@ -88,13 +100,14 @@ void SkPictureRecorder::partialReplay(SkCanvas* canvas) const {
         return;
     }
 
-    if (NULL != fRecord.get()) {
+    if (fRecord.get()) {
         SkRecordDraw(*fRecord, canvas, NULL/*bbh*/, NULL/*callback*/);
     }
 
-    if (NULL != fPictureRecord.get()) {
+    if (fPictureRecord.get()) {
         const bool deepCopyOps = true;
-        SkPicture picture(fWidth, fHeight, *fPictureRecord.get(), deepCopyOps);
-        picture.draw(canvas);
+        SkPicture picture(fCullWidth, fCullHeight, 
+                          *fPictureRecord.get(), deepCopyOps);
+        picture.playback(canvas);
     }
 }