SkRecords.h revision 6be2aa9a251bf6022570a03140f956655b3ef1da
1c4b21e6c03a6cdb03e116b9f510eb10cf8daedb1commit-bot@chromium.org/*
2c4b21e6c03a6cdb03e116b9f510eb10cf8daedb1commit-bot@chromium.org * Copyright 2014 Google Inc.
3c4b21e6c03a6cdb03e116b9f510eb10cf8daedb1commit-bot@chromium.org *
4c4b21e6c03a6cdb03e116b9f510eb10cf8daedb1commit-bot@chromium.org * Use of this source code is governed by a BSD-style license that can be
5c4b21e6c03a6cdb03e116b9f510eb10cf8daedb1commit-bot@chromium.org * found in the LICENSE file.
6c4b21e6c03a6cdb03e116b9f510eb10cf8daedb1commit-bot@chromium.org */
7c4b21e6c03a6cdb03e116b9f510eb10cf8daedb1commit-bot@chromium.org
8e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org#ifndef SkRecords_DEFINED
9e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org#define SkRecords_DEFINED
10e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org
11e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org#include "SkCanvas.h"
126be2aa9a251bf6022570a03140f956655b3ef1dareed#include "SkCanvasDrawable.h"
132347b624678fedf1d2f7ab1d79b9ad70087c3392reed#include "SkPicture.h"
1400d5c2c6523321d25b32905ff4822f083a4173eefmalita#include "SkTextBlob.h"
152347b624678fedf1d2f7ab1d79b9ad70087c3392reed
1600d5c2c6523321d25b32905ff4822f083a4173eefmalitanamespace SkRecords {
1700d5c2c6523321d25b32905ff4822f083a4173eefmalita
18e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org// A list of all the types of canvas calls we can record.
19e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org// Each of these is reified into a struct below.
20e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org//
21e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org// (We're using the macro-of-macro trick here to do several different things with the same list.)
22e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org//
23e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org// We leave this SK_RECORD_TYPES macro defined for use by code that wants to operate on SkRecords
24e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org// types polymorphically.  (See SkRecord::Record::{visit,mutate} for an example.)
2537f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.org//
2637f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.org// Order doesn't technically matter here, but the compiler can generally generate better code if
2737f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.org// you keep them semantically grouped, especially the Draws.  It's also nice to leave NoOp at 0.
2888c3e279ab79125e5741b0b0b3175291e2e2bbeecommit-bot@chromium.org#define SK_RECORD_TYPES(M)                                          \
2988c3e279ab79125e5741b0b0b3175291e2e2bbeecommit-bot@chromium.org    M(NoOp)                                                         \
3088c3e279ab79125e5741b0b0b3175291e2e2bbeecommit-bot@chromium.org    M(Restore)                                                      \
3188c3e279ab79125e5741b0b0b3175291e2e2bbeecommit-bot@chromium.org    M(Save)                                                         \
3288c3e279ab79125e5741b0b0b3175291e2e2bbeecommit-bot@chromium.org    M(SaveLayer)                                                    \
3337f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.org    M(PushCull)                                                     \
3437f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.org    M(PopCull)                                                      \
3588c3e279ab79125e5741b0b0b3175291e2e2bbeecommit-bot@chromium.org    M(SetMatrix)                                                    \
3688c3e279ab79125e5741b0b0b3175291e2e2bbeecommit-bot@chromium.org    M(ClipPath)                                                     \
3788c3e279ab79125e5741b0b0b3175291e2e2bbeecommit-bot@chromium.org    M(ClipRRect)                                                    \
3888c3e279ab79125e5741b0b0b3175291e2e2bbeecommit-bot@chromium.org    M(ClipRect)                                                     \
3988c3e279ab79125e5741b0b0b3175291e2e2bbeecommit-bot@chromium.org    M(ClipRegion)                                                   \
4088c3e279ab79125e5741b0b0b3175291e2e2bbeecommit-bot@chromium.org    M(Clear)                                                        \
415f0e82204ecca0805a7689cdba5f802458e103f4mtklein    M(BeginCommentGroup)                                            \
425f0e82204ecca0805a7689cdba5f802458e103f4mtklein    M(AddComment)                                                   \
435f0e82204ecca0805a7689cdba5f802458e103f4mtklein    M(EndCommentGroup)                                              \
4488c3e279ab79125e5741b0b0b3175291e2e2bbeecommit-bot@chromium.org    M(DrawBitmap)                                                   \
4588c3e279ab79125e5741b0b0b3175291e2e2bbeecommit-bot@chromium.org    M(DrawBitmapMatrix)                                             \
4688c3e279ab79125e5741b0b0b3175291e2e2bbeecommit-bot@chromium.org    M(DrawBitmapNine)                                               \
4788c3e279ab79125e5741b0b0b3175291e2e2bbeecommit-bot@chromium.org    M(DrawBitmapRectToRect)                                         \
486be2aa9a251bf6022570a03140f956655b3ef1dareed    M(DrawDrawable)                                                 \
4965151754b9fdb6a968d7307764c20655d1b680a0piotaixr    M(DrawImage)                                                    \
5065151754b9fdb6a968d7307764c20655d1b680a0piotaixr    M(DrawImageRect)                                                \
5188c3e279ab79125e5741b0b0b3175291e2e2bbeecommit-bot@chromium.org    M(DrawDRRect)                                                   \
5288c3e279ab79125e5741b0b0b3175291e2e2bbeecommit-bot@chromium.org    M(DrawOval)                                                     \
5388c3e279ab79125e5741b0b0b3175291e2e2bbeecommit-bot@chromium.org    M(DrawPaint)                                                    \
5488c3e279ab79125e5741b0b0b3175291e2e2bbeecommit-bot@chromium.org    M(DrawPath)                                                     \
55963137b75c0a1fe91f35e9826742f36309f5e65ddandov    M(DrawPatch)                                                    \
562347b624678fedf1d2f7ab1d79b9ad70087c3392reed    M(DrawPicture)                                                  \
5788c3e279ab79125e5741b0b0b3175291e2e2bbeecommit-bot@chromium.org    M(DrawPoints)                                                   \
5888c3e279ab79125e5741b0b0b3175291e2e2bbeecommit-bot@chromium.org    M(DrawPosText)                                                  \
5988c3e279ab79125e5741b0b0b3175291e2e2bbeecommit-bot@chromium.org    M(DrawPosTextH)                                                 \
60c551d9fcae98ff7b9d56f315947e89a26632aeecmtklein    M(DrawText)                                                     \
61c551d9fcae98ff7b9d56f315947e89a26632aeecmtklein    M(DrawTextOnPath)                                               \
6288c3e279ab79125e5741b0b0b3175291e2e2bbeecommit-bot@chromium.org    M(DrawRRect)                                                    \
6388c3e279ab79125e5741b0b0b3175291e2e2bbeecommit-bot@chromium.org    M(DrawRect)                                                     \
6488c3e279ab79125e5741b0b0b3175291e2e2bbeecommit-bot@chromium.org    M(DrawSprite)                                                   \
6529dfaa80f5776904f42b72b387a99e75f8dc5f5fmtklein    M(DrawTextBlob)                                                 \
6629dfaa80f5776904f42b72b387a99e75f8dc5f5fmtklein    M(DrawData)                                                     \
67f4078ad1ec42f549369ac4f639aab18d00afae95mtklein    M(DrawVertices)
68e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org
69e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org// Defines SkRecords::Type, an enum of all record types.
70e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org#define ENUM(T) T##_Type,
71e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.orgenum Type { SK_RECORD_TYPES(ENUM) };
72e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org#undef ENUM
73e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org
74e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org// Macros to make it easier to define a record for a draw call with 0 args, 1 args, 2 args, etc.
75e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org// These should be clearer when you look at their use below.
76e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org#define RECORD0(T)                      \
77e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.orgstruct T {                              \
78e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org    static const Type kType = T##_Type; \
79e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org};
80e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org
81e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org// We try to be flexible about the types the constructors take.  Instead of requring the exact type
82e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org// A here, we take any type Z which implicitly casts to A.  This allows the delay_copy() trick to
83e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org// work, allowing the caller to decide whether to pass by value or by const&.
84e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org
85e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org#define RECORD1(T, A, a)                \
86e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.orgstruct T {                              \
87e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org    static const Type kType = T##_Type; \
88e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org    template <typename Z>               \
89e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org    T(Z a) : a(a) {}                    \
90e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org    A a;                                \
91e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org};
92e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org
93e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org#define RECORD2(T, A, a, B, b)          \
94e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.orgstruct T {                              \
95e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org    static const Type kType = T##_Type; \
96e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org    template <typename Z, typename Y>   \
97e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org    T(Z a, Y b) : a(a), b(b) {}         \
98e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org    A a; B b;                           \
99e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org};
100e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org
101e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org#define RECORD3(T, A, a, B, b, C, c)              \
102e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.orgstruct T {                                        \
103e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org    static const Type kType = T##_Type;           \
104e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org    template <typename Z, typename Y, typename X> \
105e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org    T(Z a, Y b, X c) : a(a), b(b), c(c) {}        \
106e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org    A a; B b; C c;                                \
107e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org};
108e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org
109e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org#define RECORD4(T, A, a, B, b, C, c, D, d)                    \
110e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.orgstruct T {                                                    \
111e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org    static const Type kType = T##_Type;                       \
112e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org    template <typename Z, typename Y, typename X, typename W> \
113e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org    T(Z a, Y b, X c, W d) : a(a), b(b), c(c), d(d) {}         \
114e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org    A a; B b; C c; D d;                                       \
115e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org};
116e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org
117e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org#define RECORD5(T, A, a, B, b, C, c, D, d, E, e)                          \
118e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.orgstruct T {                                                                \
119e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org    static const Type kType = T##_Type;                                   \
120e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org    template <typename Z, typename Y, typename X, typename W, typename V> \
121e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org    T(Z a, Y b, X c, W d, V e) : a(a), b(b), c(c), d(d), e(e) {}          \
122e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org    A a; B b; C c; D d; E e;                                              \
123e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org};
124e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org
1259b222a5ddd3b39ca191d8443bade6052cdcb713dmtklein#define ACT_AS_PTR(ptr)                 \
1269b222a5ddd3b39ca191d8443bade6052cdcb713dmtklein    operator T*() const { return ptr; } \
1279b222a5ddd3b39ca191d8443bade6052cdcb713dmtklein    T* operator->() const { return ptr; }
12888c3e279ab79125e5741b0b0b3175291e2e2bbeecommit-bot@chromium.org
12953fecfb15d254397ab03032b888daa9d15c487b6mtkleintemplate <typename T>
13053fecfb15d254397ab03032b888daa9d15c487b6mtkleinclass RefBox : SkNoncopyable {
13153fecfb15d254397ab03032b888daa9d15c487b6mtkleinpublic:
1329b222a5ddd3b39ca191d8443bade6052cdcb713dmtklein    RefBox(T* obj) : fObj(SkSafeRef(obj)) {}
1339b222a5ddd3b39ca191d8443bade6052cdcb713dmtklein    ~RefBox() { SkSafeUnref(fObj); }
13453fecfb15d254397ab03032b888daa9d15c487b6mtklein
13553fecfb15d254397ab03032b888daa9d15c487b6mtklein    ACT_AS_PTR(fObj);
13653fecfb15d254397ab03032b888daa9d15c487b6mtklein
13753fecfb15d254397ab03032b888daa9d15c487b6mtkleinprivate:
13853fecfb15d254397ab03032b888daa9d15c487b6mtklein    T* fObj;
13953fecfb15d254397ab03032b888daa9d15c487b6mtklein};
14053fecfb15d254397ab03032b888daa9d15c487b6mtklein
141653d51867c20fc643537e4a0d73178697766ae4acommit-bot@chromium.org// An Optional doesn't own the pointer's memory, but may need to destroy non-POD data.
142653d51867c20fc643537e4a0d73178697766ae4acommit-bot@chromium.orgtemplate <typename T>
143653d51867c20fc643537e4a0d73178697766ae4acommit-bot@chromium.orgclass Optional : SkNoncopyable {
144653d51867c20fc643537e4a0d73178697766ae4acommit-bot@chromium.orgpublic:
145653d51867c20fc643537e4a0d73178697766ae4acommit-bot@chromium.org    Optional(T* ptr) : fPtr(ptr) {}
146653d51867c20fc643537e4a0d73178697766ae4acommit-bot@chromium.org    ~Optional() { if (fPtr) fPtr->~T(); }
147653d51867c20fc643537e4a0d73178697766ae4acommit-bot@chromium.org
14888c3e279ab79125e5741b0b0b3175291e2e2bbeecommit-bot@chromium.org    ACT_AS_PTR(fPtr);
14988c3e279ab79125e5741b0b0b3175291e2e2bbeecommit-bot@chromium.orgprivate:
15088c3e279ab79125e5741b0b0b3175291e2e2bbeecommit-bot@chromium.org    T* fPtr;
15188c3e279ab79125e5741b0b0b3175291e2e2bbeecommit-bot@chromium.org};
15288c3e279ab79125e5741b0b0b3175291e2e2bbeecommit-bot@chromium.org
15388c3e279ab79125e5741b0b0b3175291e2e2bbeecommit-bot@chromium.org// Like Optional, but ptr must not be NULL.
15488c3e279ab79125e5741b0b0b3175291e2e2bbeecommit-bot@chromium.orgtemplate <typename T>
15588c3e279ab79125e5741b0b0b3175291e2e2bbeecommit-bot@chromium.orgclass Adopted : SkNoncopyable {
15688c3e279ab79125e5741b0b0b3175291e2e2bbeecommit-bot@chromium.orgpublic:
15788c3e279ab79125e5741b0b0b3175291e2e2bbeecommit-bot@chromium.org    Adopted(T* ptr) : fPtr(ptr) { SkASSERT(fPtr); }
158f0ae5e471b759f18b614a8e0928c9151947de04ccommit-bot@chromium.org    Adopted(Adopted* source) {
159f0ae5e471b759f18b614a8e0928c9151947de04ccommit-bot@chromium.org        // Transfer ownership from source to this.
160f0ae5e471b759f18b614a8e0928c9151947de04ccommit-bot@chromium.org        fPtr = source->fPtr;
161f0ae5e471b759f18b614a8e0928c9151947de04ccommit-bot@chromium.org        source->fPtr = NULL;
162f0ae5e471b759f18b614a8e0928c9151947de04ccommit-bot@chromium.org    }
163f0ae5e471b759f18b614a8e0928c9151947de04ccommit-bot@chromium.org    ~Adopted() { if (fPtr) fPtr->~T(); }
16488c3e279ab79125e5741b0b0b3175291e2e2bbeecommit-bot@chromium.org
16588c3e279ab79125e5741b0b0b3175291e2e2bbeecommit-bot@chromium.org    ACT_AS_PTR(fPtr);
166653d51867c20fc643537e4a0d73178697766ae4acommit-bot@chromium.orgprivate:
167653d51867c20fc643537e4a0d73178697766ae4acommit-bot@chromium.org    T* fPtr;
168653d51867c20fc643537e4a0d73178697766ae4acommit-bot@chromium.org};
169653d51867c20fc643537e4a0d73178697766ae4acommit-bot@chromium.org
170653d51867c20fc643537e4a0d73178697766ae4acommit-bot@chromium.org// PODArray doesn't own the pointer's memory, and we assume the data is POD.
171653d51867c20fc643537e4a0d73178697766ae4acommit-bot@chromium.orgtemplate <typename T>
172f0ae5e471b759f18b614a8e0928c9151947de04ccommit-bot@chromium.orgclass PODArray {
173653d51867c20fc643537e4a0d73178697766ae4acommit-bot@chromium.orgpublic:
174653d51867c20fc643537e4a0d73178697766ae4acommit-bot@chromium.org    PODArray(T* ptr) : fPtr(ptr) {}
175f0ae5e471b759f18b614a8e0928c9151947de04ccommit-bot@chromium.org    // Default copy and assign.
176653d51867c20fc643537e4a0d73178697766ae4acommit-bot@chromium.org
17788c3e279ab79125e5741b0b0b3175291e2e2bbeecommit-bot@chromium.org    ACT_AS_PTR(fPtr);
178653d51867c20fc643537e4a0d73178697766ae4acommit-bot@chromium.orgprivate:
179653d51867c20fc643537e4a0d73178697766ae4acommit-bot@chromium.org    T* fPtr;
180653d51867c20fc643537e4a0d73178697766ae4acommit-bot@chromium.org};
181653d51867c20fc643537e4a0d73178697766ae4acommit-bot@chromium.org
18216307bd65011667ecdcb755465ce632eef204749commit-bot@chromium.org#undef ACT_AS_PTR
18316307bd65011667ecdcb755465ce632eef204749commit-bot@chromium.org
184e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org// Like SkBitmap, but deep copies pixels if they're not immutable.
185e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org// Using this, we guarantee the immutability of all bitmaps we record.
186ee36952c601723a7069b8c2fc200dd769b8db1b0mtkleinclass ImmutableBitmap : SkNoncopyable {
187e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.orgpublic:
188e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org    explicit ImmutableBitmap(const SkBitmap& bitmap) {
189e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org        if (bitmap.isImmutable()) {
190e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org            fBitmap = bitmap;
191e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org        } else {
192e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org            bitmap.copyTo(&fBitmap);
193e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org        }
194e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org        fBitmap.setImmutable();
195e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org    }
196e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org
197e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org    operator const SkBitmap& () const { return fBitmap; }
198e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org
199e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.orgprivate:
200e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org    SkBitmap fBitmap;
201e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org};
202e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org
20388c3e279ab79125e5741b0b0b3175291e2e2bbeecommit-bot@chromium.orgRECORD0(NoOp);
204e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org
205a723b576aed31a6eb2bdda6388e6bd779d04c6b0mtkleinRECORD2(Restore, SkIRect, devBounds, SkMatrix, matrix);
2065f6102d07982043542343ff0a6c67b1319ac9fc7Florin MalitaRECORD0(Save);
207653d51867c20fc643537e4a0d73178697766ae4acommit-bot@chromium.orgRECORD3(SaveLayer, Optional<SkRect>, bounds, Optional<SkPaint>, paint, SkCanvas::SaveFlags, flags);
208e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org
20988c3e279ab79125e5741b0b0b3175291e2e2bbeecommit-bot@chromium.orgRECORD1(PushCull, SkRect, rect);
21003a99b8f96b56d3349fa7b6832638e3b9830d169commit-bot@chromium.orgRECORD0(PopCull);
21103a99b8f96b56d3349fa7b6832638e3b9830d169commit-bot@chromium.org
212e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.orgRECORD1(SetMatrix, SkMatrix, matrix);
213e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org
214a723b576aed31a6eb2bdda6388e6bd779d04c6b0mtkleinRECORD4(ClipPath,   SkIRect, devBounds, SkPath,   path,   SkRegion::Op, op, bool, doAA);
215a723b576aed31a6eb2bdda6388e6bd779d04c6b0mtkleinRECORD4(ClipRRect,  SkIRect, devBounds, SkRRect,  rrect,  SkRegion::Op, op, bool, doAA);
216a723b576aed31a6eb2bdda6388e6bd779d04c6b0mtkleinRECORD4(ClipRect,   SkIRect, devBounds, SkRect,   rect,   SkRegion::Op, op, bool, doAA);
217a723b576aed31a6eb2bdda6388e6bd779d04c6b0mtkleinRECORD3(ClipRegion, SkIRect, devBounds, SkRegion, region, SkRegion::Op, op);
218e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org
219e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.orgRECORD1(Clear, SkColor, color);
2205f0e82204ecca0805a7689cdba5f802458e103f4mtklein
2215f0e82204ecca0805a7689cdba5f802458e103f4mtkleinRECORD1(BeginCommentGroup, PODArray<char>, description);
2225f0e82204ecca0805a7689cdba5f802458e103f4mtkleinRECORD2(AddComment, PODArray<char>, key, PODArray<char>, value);
2235f0e82204ecca0805a7689cdba5f802458e103f4mtkleinRECORD0(EndCommentGroup);
2245f0e82204ecca0805a7689cdba5f802458e103f4mtklein
22537f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.org// While not strictly required, if you have an SkPaint, it's fastest to put it first.
22637f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.orgRECORD4(DrawBitmap, Optional<SkPaint>, paint,
22737f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.org                    ImmutableBitmap, bitmap,
228653d51867c20fc643537e4a0d73178697766ae4acommit-bot@chromium.org                    SkScalar, left,
22937f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.org                    SkScalar, top);
23037f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.orgRECORD3(DrawBitmapMatrix, Optional<SkPaint>, paint, ImmutableBitmap, bitmap, SkMatrix, matrix);
23137f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.orgRECORD4(DrawBitmapNine, Optional<SkPaint>, paint,
23237f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.org                        ImmutableBitmap, bitmap,
233653d51867c20fc643537e4a0d73178697766ae4acommit-bot@chromium.org                        SkIRect, center,
23437f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.org                        SkRect, dst);
23537f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.orgRECORD5(DrawBitmapRectToRect, Optional<SkPaint>, paint,
23637f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.org                              ImmutableBitmap, bitmap,
237653d51867c20fc643537e4a0d73178697766ae4acommit-bot@chromium.org                              Optional<SkRect>, src,
238e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org                              SkRect, dst,
239e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org                              SkCanvas::DrawBitmapRectFlags, flags);
24037f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.orgRECORD3(DrawDRRect, SkPaint, paint, SkRRect, outer, SkRRect, inner);
2416be2aa9a251bf6022570a03140f956655b3ef1dareedRECORD2(DrawDrawable, SkRect, worstCaseBounds, int32_t, index);
24265151754b9fdb6a968d7307764c20655d1b680a0piotaixrRECORD4(DrawImage, Optional<SkPaint>, paint,
24365151754b9fdb6a968d7307764c20655d1b680a0piotaixr                   RefBox<const SkImage>, image,
24465151754b9fdb6a968d7307764c20655d1b680a0piotaixr                   SkScalar, left,
24565151754b9fdb6a968d7307764c20655d1b680a0piotaixr                   SkScalar, top);
24665151754b9fdb6a968d7307764c20655d1b680a0piotaixrRECORD4(DrawImageRect, Optional<SkPaint>, paint,
24765151754b9fdb6a968d7307764c20655d1b680a0piotaixr                       RefBox<const SkImage>, image,
24865151754b9fdb6a968d7307764c20655d1b680a0piotaixr                       Optional<SkRect>, src,
24965151754b9fdb6a968d7307764c20655d1b680a0piotaixr                       SkRect, dst);
25037f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.orgRECORD2(DrawOval, SkPaint, paint, SkRect, oval);
251e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.orgRECORD1(DrawPaint, SkPaint, paint);
25237f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.orgRECORD2(DrawPath, SkPaint, paint, SkPath, path);
25353fecfb15d254397ab03032b888daa9d15c487b6mtkleinRECORD3(DrawPicture, Optional<SkPaint>, paint,
25453fecfb15d254397ab03032b888daa9d15c487b6mtklein                     RefBox<const SkPicture>, picture,
25553fecfb15d254397ab03032b888daa9d15c487b6mtklein                     Optional<SkMatrix>, matrix);
25637f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.orgRECORD4(DrawPoints, SkPaint, paint, SkCanvas::PointMode, mode, size_t, count, SkPoint*, pts);
25737f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.orgRECORD4(DrawPosText, SkPaint, paint,
25837f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.org                     PODArray<char>, text,
259653d51867c20fc643537e4a0d73178697766ae4acommit-bot@chromium.org                     size_t, byteLength,
26037f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.org                     PODArray<SkPoint>, pos);
26137f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.orgRECORD5(DrawPosTextH, SkPaint, paint,
26237f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.org                      PODArray<char>, text,
263e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org                      size_t, byteLength,
264653d51867c20fc643537e4a0d73178697766ae4acommit-bot@chromium.org                      PODArray<SkScalar>, xpos,
26537f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.org                      SkScalar, y);
26637f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.orgRECORD2(DrawRRect, SkPaint, paint, SkRRect, rrect);
26737f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.orgRECORD2(DrawRect, SkPaint, paint, SkRect, rect);
26837f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.orgRECORD4(DrawSprite, Optional<SkPaint>, paint, ImmutableBitmap, bitmap, int, left, int, top);
26937f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.orgRECORD5(DrawText, SkPaint, paint,
27037f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.org                  PODArray<char>, text,
271653d51867c20fc643537e4a0d73178697766ae4acommit-bot@chromium.org                  size_t, byteLength,
272653d51867c20fc643537e4a0d73178697766ae4acommit-bot@chromium.org                  SkScalar, x,
27337f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.org                  SkScalar, y);
27400d5c2c6523321d25b32905ff4822f083a4173eefmalitaRECORD4(DrawTextBlob, SkPaint, paint,
27553fecfb15d254397ab03032b888daa9d15c487b6mtklein                      RefBox<const SkTextBlob>, blob,
27600d5c2c6523321d25b32905ff4822f083a4173eefmalita                      SkScalar, x,
27700d5c2c6523321d25b32905ff4822f083a4173eefmalita                      SkScalar, y);
27837f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.orgRECORD5(DrawTextOnPath, SkPaint, paint,
27937f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.org                        PODArray<char>, text,
280e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org                        size_t, byteLength,
281e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org                        SkPath, path,
28237f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.org                        Optional<SkMatrix>, matrix);
283e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org
28429dfaa80f5776904f42b72b387a99e75f8dc5f5fmtkleinRECORD2(DrawData, PODArray<char>, data, size_t, length);
28529dfaa80f5776904f42b72b387a99e75f8dc5f5fmtklein
2869b222a5ddd3b39ca191d8443bade6052cdcb713dmtkleinRECORD5(DrawPatch, SkPaint, paint,
2879b222a5ddd3b39ca191d8443bade6052cdcb713dmtklein                   PODArray<SkPoint>, cubics,
2889b222a5ddd3b39ca191d8443bade6052cdcb713dmtklein                   PODArray<SkColor>, colors,
2899b222a5ddd3b39ca191d8443bade6052cdcb713dmtklein                   PODArray<SkPoint>, texCoords,
2909b222a5ddd3b39ca191d8443bade6052cdcb713dmtklein                   RefBox<SkXfermode>, xmode);
2919b222a5ddd3b39ca191d8443bade6052cdcb713dmtklein
292e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org// This guy is so ugly we just write it manually.
293e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.orgstruct DrawVertices {
294e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org    static const Type kType = DrawVertices_Type;
295e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org
29637f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.org    DrawVertices(const SkPaint& paint,
29737f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.org                 SkCanvas::VertexMode vmode,
298e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org                 int vertexCount,
299e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org                 SkPoint* vertices,
300e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org                 SkPoint* texs,
301e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org                 SkColor* colors,
302e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org                 SkXfermode* xmode,
303e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org                 uint16_t* indices,
30437f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.org                 int indexCount)
30537f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.org        : paint(paint)
30637f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.org        , vmode(vmode)
307e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org        , vertexCount(vertexCount)
308e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org        , vertices(vertices)
309e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org        , texs(texs)
310e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org        , colors(colors)
311e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org        , xmode(SkSafeRef(xmode))
312e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org        , indices(indices)
31337f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.org        , indexCount(indexCount) {}
314e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org
31537f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.org    SkPaint paint;
316e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org    SkCanvas::VertexMode vmode;
317e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org    int vertexCount;
318653d51867c20fc643537e4a0d73178697766ae4acommit-bot@chromium.org    PODArray<SkPoint> vertices;
319653d51867c20fc643537e4a0d73178697766ae4acommit-bot@chromium.org    PODArray<SkPoint> texs;
320653d51867c20fc643537e4a0d73178697766ae4acommit-bot@chromium.org    PODArray<SkColor> colors;
321e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org    SkAutoTUnref<SkXfermode> xmode;
322653d51867c20fc643537e4a0d73178697766ae4acommit-bot@chromium.org    PODArray<uint16_t> indices;
323e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org    int indexCount;
324e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org};
3256cfa73a29a26edf1d03bca224ad6860396308ffcmtklein
326e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org#undef RECORD0
327e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org#undef RECORD1
328e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org#undef RECORD2
329e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org#undef RECORD3
330e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org#undef RECORD4
331e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org#undef RECORD5
332e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org
333e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org}  // namespace SkRecords
334e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org
335e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org#endif//SkRecords_DEFINED
336