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

Side by Side Diff: src/core/SkMultiPictureDraw.cpp

Issue 491313003: SkMultiPictureDraw API (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix clang complaint Created 6 years, 4 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 unified diff | Download patch
« no previous file with comments | « include/core/SkMultiPictureDraw.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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 "SkCanvas.h"
9 #include "SkMultiPictureDraw.h"
10 #include "SkPicture.h"
11
12 SkMultiPictureDraw::SkMultiPictureDraw(int reserve) {
13 if (reserve > 0) {
14 fDrawData.setReserve(reserve);
15 }
16 }
17
18 void SkMultiPictureDraw::reset() {
19 for (int i = 0; i < fDrawData.count(); ++i) {
20 fDrawData[i].picture->unref();
21 fDrawData[i].canvas->unref();
22 SkDELETE(fDrawData[i].paint);
23 }
24
25 fDrawData.rewind();
26 }
27
28 void SkMultiPictureDraw::add(SkCanvas* canvas,
29 const SkPicture* picture,
30 const SkMatrix* matrix,
31 const SkPaint* paint) {
32 if (NULL == canvas || NULL == picture) {
33 SkDEBUGFAIL("parameters to SkMultiPictureDraw::add should be non-NULL");
34 return;
35 }
36
37 DrawData* data = fDrawData.append();
38
39 data->picture = SkRef(picture);
40 data->canvas = SkRef(canvas);
41 if (NULL != matrix) {
42 data->matrix = *matrix;
43 } else {
44 data->matrix.setIdentity();
45 }
46 if (NULL != paint) {
47 data->paint = SkNEW_ARGS(SkPaint, (*paint));
48 } else {
49 data->paint = NULL;
50 }
51 }
52
53 void SkMultiPictureDraw::draw() {
54 for (int i = 0; i < fDrawData.count(); ++i) {
55 fDrawData[i].canvas->drawPicture(fDrawData[i].picture,
56 &fDrawData[i].matrix,
57 fDrawData[i].paint);
58 }
59
60 this->reset();
61 }
62
OLDNEW
« no previous file with comments | « include/core/SkMultiPictureDraw.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698