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

Side by Side Diff: include/core/SkPicture.h

Issue 513983002: Try out scalar picture sizes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Update to ToT again Created 6 years, 3 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 | « gyp/skia_for_chromium_defines.gypi ('k') | include/core/SkPictureRecorder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2007 The Android Open Source Project 3 * Copyright 2007 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #ifndef SkPicture_DEFINED 10 #ifndef SkPicture_DEFINED
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 * Creates a thread-safe clone of the picture that is ready for playback. 113 * Creates a thread-safe clone of the picture that is ready for playback.
114 */ 114 */
115 SkPicture* clone() const; 115 SkPicture* clone() const;
116 #endif 116 #endif
117 117
118 /** Replays the drawing commands on the specified canvas. 118 /** Replays the drawing commands on the specified canvas.
119 @param canvas the canvas receiving the drawing commands. 119 @param canvas the canvas receiving the drawing commands.
120 */ 120 */
121 void draw(SkCanvas* canvas, SkDrawPictureCallback* = NULL) const; 121 void draw(SkCanvas* canvas, SkDrawPictureCallback* = NULL) const;
122 122
123 /** Return the width of the picture's recording canvas. This 123 #ifdef SK_LEGACY_PICTURE_SIZE_API
124 value reflects what was passed to setSize(), and does not necessarily 124 int width() const { return SkScalarCeilToInt(fCullWidth); }
125 reflect the bounds of what has been recorded into the picture. 125 int height() const { return SkScalarCeilToInt(fCullHeight); }
126 @return the width of the picture's recording canvas 126 #endif
127
128 /** Return the cull rect used when creating this picture: { 0, 0, cullWidth, cullHeight }.
129 It does not necessarily reflect the bounds of what has been recorded int o the picture.
130 @return the cull rect used to create this picture
127 */ 131 */
128 int width() const { return fWidth; } 132 const SkRect cullRect() const { return SkRect::MakeWH(fCullWidth, fCullHeigh t); }
129
130 /** Return the height of the picture's recording canvas. This
131 value reflects what was passed to setSize(), and does not necessarily
132 reflect the bounds of what has been recorded into the picture.
133 @return the height of the picture's recording canvas
134 */
135 int height() const { return fHeight; }
136 133
137 /** Return a non-zero, unique value representing the picture. This call is 134 /** Return a non-zero, unique value representing the picture. This call is
138 only valid when not recording. Between a beginRecording/endRecording 135 only valid when not recording. Between a beginRecording/endRecording
139 pair it will just return 0 (the invalid ID). Each beginRecording/ 136 pair it will just return 0 (the invalid ID). Each beginRecording/
140 endRecording pair will cause a different generation ID to be returned. 137 endRecording pair will cause a different generation ID to be returned.
141 */ 138 */
142 uint32_t uniqueID() const; 139 uint32_t uniqueID() const;
143 140
144 /** 141 /**
145 * Function to encode an SkBitmap to an SkData. A function with this 142 * Function to encode an SkBitmap to an SkData. A function with this
(...skipping 27 matching lines...) Expand all
173 170
174 /** Return true if the SkStream/Buffer represents a serialized picture, and 171 /** Return true if the SkStream/Buffer represents a serialized picture, and
175 fills out SkPictInfo. After this function returns, the data source is no t 172 fills out SkPictInfo. After this function returns, the data source is no t
176 rewound so it will have to be manually reset before passing to 173 rewound so it will have to be manually reset before passing to
177 CreateFromStream or CreateFromBuffer. Note, CreateFromStream and 174 CreateFromStream or CreateFromBuffer. Note, CreateFromStream and
178 CreateFromBuffer perform this check internally so these entry points are 175 CreateFromBuffer perform this check internally so these entry points are
179 intended for stand alone tools. 176 intended for stand alone tools.
180 If false is returned, SkPictInfo is unmodified. 177 If false is returned, SkPictInfo is unmodified.
181 */ 178 */
182 static bool InternalOnly_StreamIsSKP(SkStream*, SkPictInfo*); 179 static bool InternalOnly_StreamIsSKP(SkStream*, SkPictInfo*);
183 static bool InternalOnly_BufferIsSKP(SkReadBuffer&, SkPictInfo*); 180 static bool InternalOnly_BufferIsSKP(SkReadBuffer*, SkPictInfo*);
184 181
185 /** Return true if the picture is suitable for rendering on the GPU. 182 /** Return true if the picture is suitable for rendering on the GPU.
186 */ 183 */
187 184
188 #if SK_SUPPORT_GPU 185 #if SK_SUPPORT_GPU
189 bool suitableForGpuRasterization(GrContext*, const char ** = NULL) const; 186 bool suitableForGpuRasterization(GrContext*, const char ** = NULL) const;
190 #endif 187 #endif
191 188
192 class DeletionListener : public SkRefCnt { 189 class DeletionListener : public SkRefCnt {
193 public: 190 public:
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 // V25: SkDashPathEffect now only writes phase and interval array when flatt ening 234 // V25: SkDashPathEffect now only writes phase and interval array when flatt ening
238 // V26: Removed boolean from SkColorShader for inheriting color from SkPaint . 235 // V26: Removed boolean from SkColorShader for inheriting color from SkPaint .
239 // V27: Remove SkUnitMapper from gradients (and skia). 236 // V27: Remove SkUnitMapper from gradients (and skia).
240 // V28: No longer call bitmap::flatten inside SkWriteBuffer::writeBitmap. 237 // V28: No longer call bitmap::flatten inside SkWriteBuffer::writeBitmap.
241 // V29: Removed SaveFlags parameter from save(). 238 // V29: Removed SaveFlags parameter from save().
242 // V30: Remove redundant SkMatrix from SkLocalMatrixShader. 239 // V30: Remove redundant SkMatrix from SkLocalMatrixShader.
243 // V31: Add a serialized UniqueID to SkImageFilter. 240 // V31: Add a serialized UniqueID to SkImageFilter.
244 // V32: Removed SkPaintOptionsAndroid from SkPaint 241 // V32: Removed SkPaintOptionsAndroid from SkPaint
245 // V33: Serialize only public API of effects. 242 // V33: Serialize only public API of effects.
246 // V34: Add SkTextBlob serialization. 243 // V34: Add SkTextBlob serialization.
244 // V35: Store SkRect (rather then width & height) in header
247 245
248 // Note: If the picture version needs to be increased then please follow the 246 // Note: If the picture version needs to be increased then please follow the
249 // steps to generate new SKPs in (only accessible to Googlers): http://goo.g l/qATVcw 247 // steps to generate new SKPs in (only accessible to Googlers): http://goo.g l/qATVcw
250 248
251 // Only SKPs within the min/current picture version range (inclusive) can be read. 249 // Only SKPs within the min/current picture version range (inclusive) can be read.
252 static const uint32_t MIN_PICTURE_VERSION = 19; 250 static const uint32_t MIN_PICTURE_VERSION = 19;
253 static const uint32_t CURRENT_PICTURE_VERSION = 34; 251 static const uint32_t CURRENT_PICTURE_VERSION = 35;
254 252
255 mutable uint32_t fUniqueID; 253 mutable uint32_t fUniqueID;
256 254
257 // TODO: make SkPictureData const when clone method goes away 255 // TODO: make SkPictureData const when clone method goes away
258 SkAutoTDelete<SkPictureData> fData; 256 SkAutoTDelete<SkPictureData> fData;
259 int fWidth, fHeight; 257 const SkScalar fCullWidth;
258 const SkScalar fCullHeight;
260 mutable SkAutoTUnref<const AccelData> fAccelData; 259 mutable SkAutoTUnref<const AccelData> fAccelData;
261 260
262 mutable SkTDArray<DeletionListener*> fDeletionListeners; // pointers are re fed 261 mutable SkTDArray<DeletionListener*> fDeletionListeners; // pointers are re fed
263 262
264 void needsNewGenID() { fUniqueID = SK_InvalidGenID; } 263 void needsNewGenID() { fUniqueID = SK_InvalidGenID; }
265 void callDeletionListeners(); 264 void callDeletionListeners();
266 265
267 // Create a new SkPicture from an existing SkPictureData. The new picture 266 // Create a new SkPicture from an existing SkPictureData. The new picture
268 // takes ownership of 'data'. 267 // takes ownership of 'data'.
269 SkPicture(SkPictureData* data, int width, int height); 268 SkPicture(SkPictureData* data, SkScalar width, SkScalar height);
270 269
271 SkPicture(int width, int height, const SkPictureRecord& record, bool deepCop yOps); 270 SkPicture(SkScalar width, SkScalar height, const SkPictureRecord& record, bo ol deepCopyOps);
272 271
273 // An OperationList encapsulates a set of operation offsets into the picture byte 272 // An OperationList encapsulates a set of operation offsets into the picture byte
274 // stream along with the CTMs needed for those operation. 273 // stream along with the CTMs needed for those operation.
275 class OperationList : ::SkNoncopyable { 274 class OperationList : ::SkNoncopyable {
276 public: 275 public:
277 // The following three entry points should only be accessed if 276 // The following three entry points should only be accessed if
278 // 'valid' returns true. 277 // 'valid' returns true.
279 int numOps() const { return fOps.count(); } 278 int numOps() const { return fOps.count(); }
280 // The offset in the picture of the operation to execute. 279 // The offset in the picture of the operation to execute.
281 uint32_t offset(int index) const; 280 uint32_t offset(int index) const;
(...skipping 14 matching lines...) Expand all
296 friend class SkPictureData; // to access OperationList 295 friend class SkPictureData; // to access OperationList
297 friend class SkPictureRecorder; // just for SkPicture-based const ructor 296 friend class SkPictureRecorder; // just for SkPicture-based const ructor
298 friend class SkGpuDevice; // for EXPERIMENTAL_getActiveOps/ OperationList 297 friend class SkGpuDevice; // for EXPERIMENTAL_getActiveOps/ OperationList
299 friend class CollectLayers; // access to fRecord 298 friend class CollectLayers; // access to fRecord
300 friend class SkPicturePlayback; // to get fData & OperationList 299 friend class SkPicturePlayback; // to get fData & OperationList
301 friend class SkPictureReplacementPlayback; // to access OperationList 300 friend class SkPictureReplacementPlayback; // to access OperationList
302 301
303 typedef SkRefCnt INHERITED; 302 typedef SkRefCnt INHERITED;
304 303
305 // Takes ownership of the SkRecord, refs the (optional) BBH. 304 // Takes ownership of the SkRecord, refs the (optional) BBH.
306 SkPicture(int width, int height, SkRecord*, SkBBoxHierarchy*); 305 SkPicture(SkScalar width, SkScalar height, SkRecord*, SkBBoxHierarchy*);
307 // Return as a new SkPicture that's backed by SkRecord. 306 // Return as a new SkPicture that's backed by SkRecord.
308 static SkPicture* Forwardport(const SkPicture&); 307 static SkPicture* Forwardport(const SkPicture&);
309 308
310 SkAutoTDelete<SkRecord> fRecord; 309 SkAutoTDelete<SkRecord> fRecord;
311 SkAutoTUnref<SkBBoxHierarchy> fBBH; 310 SkAutoTUnref<SkBBoxHierarchy> fBBH;
312 311
313 struct PathCounter; 312 struct PathCounter;
314 313
315 struct Analysis { 314 struct Analysis {
316 Analysis() {} // Only used by SkPictureData codepath. 315 Analysis() {} // Only used by SkPictureData codepath.
317 explicit Analysis(const SkRecord&); 316 explicit Analysis(const SkRecord&);
318 317
319 bool suitableForGpuRasterization(const char** reason, int sampleCount) c onst; 318 bool suitableForGpuRasterization(const char** reason, int sampleCount) c onst;
320 319
321 bool fWillPlaybackBitmaps; 320 bool fWillPlaybackBitmaps;
322 bool fHasText; 321 bool fHasText;
323 int fNumPaintWithPathEffectUses; 322 int fNumPaintWithPathEffectUses;
324 int fNumFastPathDashEffects; 323 int fNumFastPathDashEffects;
325 int fNumAAConcavePaths; 324 int fNumAAConcavePaths;
326 int fNumAAHairlineConcavePaths; 325 int fNumAAHairlineConcavePaths;
327 } fAnalysis; 326 } fAnalysis;
328 }; 327 };
329 328
330 #endif 329 #endif
OLDNEW
« no previous file with comments | « gyp/skia_for_chromium_defines.gypi ('k') | include/core/SkPictureRecorder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698