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

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

Issue 324293004: Remove picture pre-allocation from SkPictureRecorder (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix initializer list order Created 6 years, 6 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 | « no previous file | 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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 SkPicturePlayback* fPlayback; 279 SkPicturePlayback* fPlayback;
280 int fWidth, fHeight; 280 int fWidth, fHeight;
281 mutable const AccelData* fAccelData; 281 mutable const AccelData* fAccelData;
282 282
283 void needsNewGenID() { fUniqueID = SK_InvalidGenID; } 283 void needsNewGenID() { fUniqueID = SK_InvalidGenID; }
284 284
285 // Create a new SkPicture from an existing SkPicturePlayback. Ref count of 285 // Create a new SkPicture from an existing SkPicturePlayback. Ref count of
286 // playback is unchanged. 286 // playback is unchanged.
287 SkPicture(SkPicturePlayback*, int width, int height); 287 SkPicture(SkPicturePlayback*, int width, int height);
288 288
289 SkPicture(int width, int height, SkPictureRecord& record, bool deepCopyOps);
290
289 private: 291 private:
290 friend class SkPictureRecord;
291 friend class SkPictureTester; // for unit testing
292
293 SkAutoTUnref<SkPathHeap> fPathHeap; // reference counted 292 SkAutoTUnref<SkPathHeap> fPathHeap; // reference counted
294 293
295 // ContentInfo is not serialized! It is intended solely for use
296 // with suitableForGpuRasterization.
297 class ContentInfo {
298 public:
299 ContentInfo() { this->reset(); }
300
301 ContentInfo(const ContentInfo& src) { this->set(src); }
302
303 void set(const ContentInfo& src) {
304 fNumPaintWithPathEffectUses = src.fNumPaintWithPathEffectUses;
305 fNumAAConcavePaths = src.fNumAAConcavePaths;
306 fNumAAHairlineConcavePaths = src.fNumAAHairlineConcavePaths;
307 }
308
309 void reset() {
310 fNumPaintWithPathEffectUses = 0;
311 fNumAAConcavePaths = 0;
312 fNumAAHairlineConcavePaths = 0;
313 }
314
315 void swap(ContentInfo* other) {
316 SkTSwap(fNumPaintWithPathEffectUses, other->fNumPaintWithPathEffectU ses);
317 SkTSwap(fNumAAConcavePaths, other->fNumAAConcavePaths);
318 SkTSwap(fNumAAHairlineConcavePaths, other->fNumAAHairlineConcavePath s);
319 }
320
321 // This field is incremented every time a paint with a path effect is
322 // used (i.e., it is not a de-duplicated count)
323 int fNumPaintWithPathEffectUses;
324 // This field is incremented every time an anti-aliased drawPath call is
325 // issued with a concave path
326 int fNumAAConcavePaths;
327 // This field is incremented every time a drawPath call is
328 // issued for a hairline stroked concave path.
329 int fNumAAHairlineConcavePaths;
330 };
331
332 ContentInfo fContentInfo;
333
334 void incPaintWithPathEffectUses() {
335 ++fContentInfo.fNumPaintWithPathEffectUses;
336 }
337 int numPaintWithPathEffectUses() const {
338 return fContentInfo.fNumPaintWithPathEffectUses;
339 }
340
341 void incAAConcavePaths() {
342 ++fContentInfo.fNumAAConcavePaths;
343 }
344 int numAAConcavePaths() const {
345 return fContentInfo.fNumAAConcavePaths;
346 }
347
348 void incAAHairlineConcavePaths() {
349 ++fContentInfo.fNumAAHairlineConcavePaths;
350 SkASSERT(fContentInfo.fNumAAHairlineConcavePaths <= fContentInfo.fNumAAC oncavePaths);
351 }
352 int numAAHairlineConcavePaths() const {
353 return fContentInfo.fNumAAHairlineConcavePaths;
354 }
355
356 const SkPath& getPath(int index) const; 294 const SkPath& getPath(int index) const;
357 int addPathToHeap(const SkPath& path); 295 int addPathToHeap(const SkPath& path);
358 296
359 void flattenToBuffer(SkWriteBuffer& buffer) const; 297 void flattenToBuffer(SkWriteBuffer& buffer) const;
360 bool parseBufferTag(SkReadBuffer& buffer, uint32_t tag, uint32_t size); 298 bool parseBufferTag(SkReadBuffer& buffer, uint32_t tag, uint32_t size);
361 299
362 static void WriteTagSize(SkWriteBuffer& buffer, uint32_t tag, size_t size); 300 static void WriteTagSize(SkWriteBuffer& buffer, uint32_t tag, size_t size);
363 static void WriteTagSize(SkWStream* stream, uint32_t tag, size_t size); 301 static void WriteTagSize(SkWStream* stream, uint32_t tag, size_t size);
364 302
365 void initForPlayback() const; 303 void initForPlayback() const;
(...skipping 26 matching lines...) Expand all
392 const OperationList& EXPERIMENTAL_getActiveOps(const SkIRect& queryRect) con st; 330 const OperationList& EXPERIMENTAL_getActiveOps(const SkIRect& queryRect) con st;
393 331
394 /** PRIVATE / EXPERIMENTAL -- do not call 332 /** PRIVATE / EXPERIMENTAL -- do not call
395 Return the ID of the operation currently being executed when playing 333 Return the ID of the operation currently being executed when playing
396 back. 0 indicates no call is active. 334 back. 0 indicates no call is active.
397 */ 335 */
398 size_t EXPERIMENTAL_curOpID() const; 336 size_t EXPERIMENTAL_curOpID() const;
399 337
400 void createHeader(SkPictInfo* info) const; 338 void createHeader(SkPictInfo* info) const;
401 static bool IsValidPictInfo(const SkPictInfo& info); 339 static bool IsValidPictInfo(const SkPictInfo& info);
402 static SkPicturePlayback* FakeEndRecording(const SkPicture* resourceSrc,
403 const SkPictureRecord& record);
404 340
405 friend class SkFlatPicture; 341 friend class SkFlatPicture;
406 friend class SkPicturePlayback; 342 friend class SkPicturePlayback;
407 friend class SkPictureRecorder; 343 friend class SkPictureRecorder; // just for SkPicture-based constructor
408 friend class SkGpuDevice; 344 friend class SkGpuDevice;
409 friend class GrGatherCanvas; 345 friend class GrGatherCanvas;
410 friend class GrGatherDevice; 346 friend class GrGatherDevice;
411 friend class SkDebugCanvas; 347 friend class SkDebugCanvas;
412 348
413 typedef SkRefCnt INHERITED; 349 typedef SkRefCnt INHERITED;
414 }; 350 };
415 351
416 /** 352 /**
417 * Subclasses of this can be passed to canvas.drawPicture. During the drawing 353 * Subclasses of this can be passed to canvas.drawPicture. During the drawing
418 * of the picture, this callback will periodically be invoked. If its 354 * of the picture, this callback will periodically be invoked. If its
419 * abortDrawing() returns true, then picture playback will be interrupted. 355 * abortDrawing() returns true, then picture playback will be interrupted.
420 * 356 *
421 * The resulting drawing is undefined, as there is no guarantee how often the 357 * The resulting drawing is undefined, as there is no guarantee how often the
422 * callback will be invoked. If the abort happens inside some level of nested 358 * callback will be invoked. If the abort happens inside some level of nested
423 * calls to save(), restore will automatically be called to return the state 359 * calls to save(), restore will automatically be called to return the state
424 * to the same level it was before the drawPicture call was made. 360 * to the same level it was before the drawPicture call was made.
425 */ 361 */
426 class SK_API SkDrawPictureCallback { 362 class SK_API SkDrawPictureCallback {
427 public: 363 public:
428 SkDrawPictureCallback() {} 364 SkDrawPictureCallback() {}
429 virtual ~SkDrawPictureCallback() {} 365 virtual ~SkDrawPictureCallback() {}
430 366
431 virtual bool abortDrawing() = 0; 367 virtual bool abortDrawing() = 0;
432 }; 368 };
433 369
434 #endif 370 #endif
OLDNEW
« no previous file with comments | « no previous file | include/core/SkPictureRecorder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698