Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / skia / src / core / SkPictureRecorder.cpp
1 /*
2  * Copyright 2014 Google Inc.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7
8 #include "SkPictureRecorder.h"
9 #include "SkRecord.h"
10 #include "SkRecordDraw.h"
11 #include "SkRecorder.h"
12 #include "SkTypes.h"
13
14 SkPictureRecorder::SkPictureRecorder() {}
15
16 SkPictureRecorder::~SkPictureRecorder() {}
17
18 SkCanvas* SkPictureRecorder::beginRecording(SkScalar width, SkScalar height,
19                                             SkBBHFactory* bbhFactory /* = NULL */,
20                                             uint32_t recordFlags /* = 0 */) {
21     fCullWidth = width;
22     fCullHeight = height;
23
24     if (bbhFactory) {
25         fBBH.reset((*bbhFactory)(width, height));
26         SkASSERT(fBBH.get());
27     }
28
29     fRecord.reset(SkNEW(SkRecord));
30     fRecorder.reset(SkNEW_ARGS(SkRecorder, (fRecord.get(), width, height)));
31     return this->getRecordingCanvas();
32 }
33
34 SkCanvas* SkPictureRecorder::getRecordingCanvas() {
35     return fRecorder.get();
36 }
37
38 SkPicture* SkPictureRecorder::endRecording() {
39     return SkNEW_ARGS(SkPicture, (fCullWidth, fCullHeight, fRecord.detach(), fBBH.get()));
40 }
41
42 void SkPictureRecorder::partialReplay(SkCanvas* canvas) const {
43     if (NULL == canvas) {
44         return;
45     }
46     SkRecordDraw(*fRecord, canvas, NULL/*bbh*/, NULL/*callback*/);
47 }