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

Side by Side Diff: tools/PictureRenderer.h

Issue 1316233002: Style Change: NULL->nullptr (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-27 (Thursday) 10:25:06 EDT Created 5 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 | « tools/PictureBenchmark.cpp ('k') | tools/PictureRenderer.cpp » ('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 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef PictureRenderer_DEFINED 8 #ifndef PictureRenderer_DEFINED
9 #define PictureRenderer_DEFINED 9 #define PictureRenderer_DEFINED
10 10
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 static_assert(!(kHinting_DrawFilterFlag & SkPaint::kAllFlags), 76 static_assert(!(kHinting_DrawFilterFlag & SkPaint::kAllFlags),
77 "hinting_flag_must_be_greater"); 77 "hinting_flag_must_be_greater");
78 static_assert(!(kSlightHinting_DrawFilterFlag & SkPaint::kAllFlags), 78 static_assert(!(kSlightHinting_DrawFilterFlag & SkPaint::kAllFlags),
79 "slight_hinting_flag_must_be_greater"); 79 "slight_hinting_flag_must_be_greater");
80 80
81 /** 81 /**
82 * Called with each new SkPicture to render. 82 * Called with each new SkPicture to render.
83 * 83 *
84 * @param pict The SkPicture to render. 84 * @param pict The SkPicture to render.
85 * @param writePath The output directory within which this renderer should w rite all images, 85 * @param writePath The output directory within which this renderer should w rite all images,
86 * or NULL if this renderer should not write all images. 86 * or nullptr if this renderer should not write all images.
87 * @param mismatchPath The output directory within which this renderer shoul d write any images 87 * @param mismatchPath The output directory within which this renderer shoul d write any images
88 * which do not match expectations, or NULL if this renderer should not write mismatches. 88 * which do not match expectations, or nullptr if this renderer should n ot write mismatches.
89 * @param inputFilename The name of the input file we are rendering. 89 * @param inputFilename The name of the input file we are rendering.
90 * @param useChecksumBasedFilenames Whether to use checksum-based filenames when writing 90 * @param useChecksumBasedFilenames Whether to use checksum-based filenames when writing
91 * bitmap images to disk. 91 * bitmap images to disk.
92 * @param useMultiPictureDraw true if MultiPictureDraw should be used for re ndering 92 * @param useMultiPictureDraw true if MultiPictureDraw should be used for re ndering
93 */ 93 */
94 virtual void init(const SkPicture* pict, 94 virtual void init(const SkPicture* pict,
95 const SkString* writePath, 95 const SkString* writePath,
96 const SkString* mismatchPath, 96 const SkString* mismatchPath,
97 const SkString* inputFilename, 97 const SkString* inputFilename,
98 bool useChecksumBasedFilenames, 98 bool useChecksumBasedFilenames,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 * 131 *
132 * If fWritePath has been specified, the result of the work will be written to that dir. 132 * If fWritePath has been specified, the result of the work will be written to that dir.
133 * If fMismatchPath has been specified, and the actual image result differs from its 133 * If fMismatchPath has been specified, and the actual image result differs from its
134 * expectation, the result of the work will be written to that dir. 134 * expectation, the result of the work will be written to that dir.
135 * 135 *
136 * @param out If non-null, the implementing subclass MAY allocate an SkBitma p, copy the 136 * @param out If non-null, the implementing subclass MAY allocate an SkBitma p, copy the
137 * output image into it, and return it here. (Some subclasses ig nore this parameter) 137 * output image into it, and return it here. (Some subclasses ig nore this parameter)
138 * @return bool True if rendering succeeded and, if fWritePath had been spec ified, the output 138 * @return bool True if rendering succeeded and, if fWritePath had been spec ified, the output
139 * was successfully written to a file. 139 * was successfully written to a file.
140 */ 140 */
141 virtual bool render(SkBitmap** out = NULL) = 0; 141 virtual bool render(SkBitmap** out = nullptr) = 0;
142 142
143 /** 143 /**
144 * Called once finished with a particular SkPicture, before calling init aga in, and before 144 * Called once finished with a particular SkPicture, before calling init aga in, and before
145 * being done with this Renderer. 145 * being done with this Renderer.
146 */ 146 */
147 virtual void end(); 147 virtual void end();
148 148
149 /** 149 /**
150 * If this PictureRenderer is actually a TiledPictureRender, return a pointe r to this as a 150 * If this PictureRenderer is actually a TiledPictureRender, return a pointe r to this as a
151 * TiledPictureRender so its methods can be called. 151 * TiledPictureRender so its methods can be called.
152 */ 152 */
153 virtual TiledPictureRenderer* getTiledRenderer() { return NULL; } 153 virtual TiledPictureRenderer* getTiledRenderer() { return nullptr; }
154 154
155 /** 155 /**
156 * Resets the GPU's state. Does nothing if the backing is raster. For a GPU renderer, calls 156 * Resets the GPU's state. Does nothing if the backing is raster. For a GPU renderer, calls
157 * flush, swapBuffers and, if callFinish is true, finish. 157 * flush, swapBuffers and, if callFinish is true, finish.
158 * @param callFinish Whether to call finish. 158 * @param callFinish Whether to call finish.
159 */ 159 */
160 void resetState(bool callFinish); 160 void resetState(bool callFinish);
161 161
162 /** 162 /**
163 * Remove all decoded textures from the CPU caches and all uploaded textures 163 * Remove all decoded textures from the CPU caches and all uploaded textures
164 * from the GPU. 164 * from the GPU.
165 */ 165 */
166 void purgeTextures(); 166 void purgeTextures();
167 167
168 /** 168 /**
169 * Set the backend type. Returns true on success and false on failure. 169 * Set the backend type. Returns true on success and false on failure.
170 */ 170 */
171 #if SK_SUPPORT_GPU 171 #if SK_SUPPORT_GPU
172 bool setDeviceType(SkDeviceTypes deviceType, GrGLStandard gpuAPI = kNone_GrG LStandard) { 172 bool setDeviceType(SkDeviceTypes deviceType, GrGLStandard gpuAPI = kNone_GrG LStandard) {
173 #else 173 #else
174 bool setDeviceType(SkDeviceTypes deviceType) { 174 bool setDeviceType(SkDeviceTypes deviceType) {
175 #endif 175 #endif
176 fDeviceType = deviceType; 176 fDeviceType = deviceType;
177 #if SK_SUPPORT_GPU 177 #if SK_SUPPORT_GPU
178 // In case this function is called more than once 178 // In case this function is called more than once
179 SkSafeUnref(fGrContext); 179 SkSafeUnref(fGrContext);
180 fGrContext = NULL; 180 fGrContext = nullptr;
181 // Set to Native so it will have an initial value. 181 // Set to Native so it will have an initial value.
182 GrContextFactory::GLContextType glContextType = GrContextFactory::kNativ e_GLContextType; 182 GrContextFactory::GLContextType glContextType = GrContextFactory::kNativ e_GLContextType;
183 #endif 183 #endif
184 switch(deviceType) { 184 switch(deviceType) {
185 case kBitmap_DeviceType: 185 case kBitmap_DeviceType:
186 return true; 186 return true;
187 #if SK_SUPPORT_GPU 187 #if SK_SUPPORT_GPU
188 case kGPU_DeviceType: 188 case kGPU_DeviceType:
189 // Already set to GrContextFactory::kNative_GLContextType, above . 189 // Already set to GrContextFactory::kNative_GLContextType, above .
190 break; 190 break;
(...skipping 10 matching lines...) Expand all
201 glContextType = GrContextFactory::kMESA_GLContextType; 201 glContextType = GrContextFactory::kMESA_GLContextType;
202 break; 202 break;
203 #endif 203 #endif
204 #endif 204 #endif
205 default: 205 default:
206 // Invalid device type. 206 // Invalid device type.
207 return false; 207 return false;
208 } 208 }
209 #if SK_SUPPORT_GPU 209 #if SK_SUPPORT_GPU
210 fGrContext = fGrContextFactory.get(glContextType, gpuAPI); 210 fGrContext = fGrContextFactory.get(glContextType, gpuAPI);
211 if (NULL == fGrContext) { 211 if (nullptr == fGrContext) {
212 return false; 212 return false;
213 } else { 213 } else {
214 fGrContext->ref(); 214 fGrContext->ref();
215 return true; 215 return true;
216 } 216 }
217 #endif 217 #endif
218 } 218 }
219 219
220 #if SK_SUPPORT_GPU 220 #if SK_SUPPORT_GPU
221 void setSampleCount(int sampleCount) { 221 void setSampleCount(int sampleCount) {
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 case kAngle_DeviceType: 383 case kAngle_DeviceType:
384 glContextType = GrContextFactory::kANGLE_GLContextType; 384 glContextType = GrContextFactory::kANGLE_GLContextType;
385 break; 385 break;
386 #endif 386 #endif
387 #if SK_MESA 387 #if SK_MESA
388 case kMesa_DeviceType: 388 case kMesa_DeviceType:
389 glContextType = GrContextFactory::kMESA_GLContextType; 389 glContextType = GrContextFactory::kMESA_GLContextType;
390 break; 390 break;
391 #endif 391 #endif
392 default: 392 default:
393 return NULL; 393 return nullptr;
394 } 394 }
395 return fGrContextFactory.getGLContext(glContextType); 395 return fGrContextFactory.getGLContext(glContextType);
396 } 396 }
397 397
398 GrContext* getGrContext() { 398 GrContext* getGrContext() {
399 return fGrContext; 399 return fGrContext;
400 } 400 }
401 401
402 const GrContextOptions& getGrContextOptions() { 402 const GrContextOptions& getGrContextOptions() {
403 return fGrContextFactory.getGlobalOptions(); 403 return fGrContextFactory.getGlobalOptions();
404 } 404 }
405 #endif 405 #endif
406 406
407 SkCanvas* getCanvas() { 407 SkCanvas* getCanvas() {
408 return fCanvas; 408 return fCanvas;
409 } 409 }
410 410
411 const SkPicture* getPicture() { 411 const SkPicture* getPicture() {
412 return fPicture; 412 return fPicture;
413 } 413 }
414 414
415 #if SK_SUPPORT_GPU 415 #if SK_SUPPORT_GPU
416 explicit PictureRenderer(const GrContextOptions &opts) 416 explicit PictureRenderer(const GrContextOptions &opts)
417 #else 417 #else
418 PictureRenderer() 418 PictureRenderer()
419 #endif 419 #endif
420 : fJsonSummaryPtr(NULL) 420 : fJsonSummaryPtr(nullptr)
421 , fDeviceType(kBitmap_DeviceType) 421 , fDeviceType(kBitmap_DeviceType)
422 , fEnableWrites(false) 422 , fEnableWrites(false)
423 , fBBoxHierarchyType(kNone_BBoxHierarchyType) 423 , fBBoxHierarchyType(kNone_BBoxHierarchyType)
424 , fHasDrawFilters(false) 424 , fHasDrawFilters(false)
425 , fScaleFactor(SK_Scalar1) 425 , fScaleFactor(SK_Scalar1)
426 #if SK_SUPPORT_GPU 426 #if SK_SUPPORT_GPU
427 , fGrContextFactory(opts) 427 , fGrContextFactory(opts)
428 , fGrContext(NULL) 428 , fGrContext(nullptr)
429 , fSampleCount(0) 429 , fSampleCount(0)
430 , fUseDFText(false) 430 , fUseDFText(false)
431 #endif 431 #endif
432 { 432 {
433 sk_bzero(fDrawFilters, sizeof(fDrawFilters)); 433 sk_bzero(fDrawFilters, sizeof(fDrawFilters));
434 fViewport.set(0, 0); 434 fViewport.set(0, 0);
435 } 435 }
436 436
437 #if SK_SUPPORT_GPU 437 #if SK_SUPPORT_GPU
438 virtual ~PictureRenderer() { 438 virtual ~PictureRenderer() {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 * Scales the provided canvas to the scale factor set by setScaleFactor. 474 * Scales the provided canvas to the scale factor set by setScaleFactor.
475 */ 475 */
476 void scaleToScaleFactor(SkCanvas*); 476 void scaleToScaleFactor(SkCanvas*);
477 477
478 SkBBHFactory* getFactory(); 478 SkBBHFactory* getFactory();
479 uint32_t recordFlags() const { return 0; } 479 uint32_t recordFlags() const { return 0; }
480 SkCanvas* setupCanvas(); 480 SkCanvas* setupCanvas();
481 virtual SkCanvas* setupCanvas(int width, int height); 481 virtual SkCanvas* setupCanvas(int width, int height);
482 482
483 /** 483 /**
484 * Copy src to dest; if src==NULL, set dest to empty string. 484 * Copy src to dest; if src==nullptr, set dest to empty string.
485 */ 485 */
486 static void CopyString(SkString* dest, const SkString* src); 486 static void CopyString(SkString* dest, const SkString* src);
487 487
488 private: 488 private:
489 SkISize fViewport; 489 SkISize fViewport;
490 SkScalar fScaleFactor; 490 SkScalar fScaleFactor;
491 #if SK_SUPPORT_GPU 491 #if SK_SUPPORT_GPU
492 GrContextFactory fGrContextFactory; 492 GrContextFactory fGrContextFactory;
493 GrContext* fGrContext; 493 GrContext* fGrContext;
494 int fSampleCount; 494 int fSampleCount;
495 bool fUseDFText; 495 bool fUseDFText;
496 #endif 496 #endif
497 497
498 virtual SkString getConfigNameInternal() = 0; 498 virtual SkString getConfigNameInternal() = 0;
499 499
500 typedef SkRefCnt INHERITED; 500 typedef SkRefCnt INHERITED;
501 }; 501 };
502 502
503 /** 503 /**
504 * This class does not do any rendering, but its render function executes record ing, which we want 504 * This class does not do any rendering, but its render function executes record ing, which we want
505 * to time. 505 * to time.
506 */ 506 */
507 class RecordPictureRenderer : public PictureRenderer { 507 class RecordPictureRenderer : public PictureRenderer {
508 public: 508 public:
509 #if SK_SUPPORT_GPU 509 #if SK_SUPPORT_GPU
510 RecordPictureRenderer(const GrContextOptions &opts) : INHERITED(opts) { } 510 RecordPictureRenderer(const GrContextOptions &opts) : INHERITED(opts) { }
511 #endif 511 #endif
512 512
513 bool render(SkBitmap** out = NULL) override; 513 bool render(SkBitmap** out = nullptr) override;
514 514
515 SkString getPerIterTimeFormat() override { return SkString("%.4f"); } 515 SkString getPerIterTimeFormat() override { return SkString("%.4f"); }
516 516
517 SkString getNormalTimeFormat() override { return SkString("%6.4f"); } 517 SkString getNormalTimeFormat() override { return SkString("%6.4f"); }
518 518
519 protected: 519 protected:
520 SkCanvas* setupCanvas(int width, int height) override; 520 SkCanvas* setupCanvas(int width, int height) override;
521 521
522 private: 522 private:
523 SkString getConfigNameInternal() override; 523 SkString getConfigNameInternal() override;
524 524
525 typedef PictureRenderer INHERITED; 525 typedef PictureRenderer INHERITED;
526 }; 526 };
527 527
528 class PipePictureRenderer : public PictureRenderer { 528 class PipePictureRenderer : public PictureRenderer {
529 public: 529 public:
530 #if SK_SUPPORT_GPU 530 #if SK_SUPPORT_GPU
531 PipePictureRenderer(const GrContextOptions &opts) : INHERITED(opts) { } 531 PipePictureRenderer(const GrContextOptions &opts) : INHERITED(opts) { }
532 #endif 532 #endif
533 533
534 bool render(SkBitmap** out = NULL) override; 534 bool render(SkBitmap** out = nullptr) override;
535 535
536 private: 536 private:
537 SkString getConfigNameInternal() override; 537 SkString getConfigNameInternal() override;
538 538
539 typedef PictureRenderer INHERITED; 539 typedef PictureRenderer INHERITED;
540 }; 540 };
541 541
542 class SimplePictureRenderer : public PictureRenderer { 542 class SimplePictureRenderer : public PictureRenderer {
543 public: 543 public:
544 #if SK_SUPPORT_GPU 544 #if SK_SUPPORT_GPU
545 SimplePictureRenderer(const GrContextOptions &opts) : INHERITED(opts) { } 545 SimplePictureRenderer(const GrContextOptions &opts) : INHERITED(opts) { }
546 #endif 546 #endif
547 547
548 virtual void init(const SkPicture* pict, 548 virtual void init(const SkPicture* pict,
549 const SkString* writePath, 549 const SkString* writePath,
550 const SkString* mismatchPath, 550 const SkString* mismatchPath,
551 const SkString* inputFilename, 551 const SkString* inputFilename,
552 bool useChecksumBasedFilenames, 552 bool useChecksumBasedFilenames,
553 bool useMultiPictureDraw) override; 553 bool useMultiPictureDraw) override;
554 554
555 bool render(SkBitmap** out = NULL) override; 555 bool render(SkBitmap** out = nullptr) override;
556 556
557 private: 557 private:
558 SkString getConfigNameInternal() override; 558 SkString getConfigNameInternal() override;
559 559
560 typedef PictureRenderer INHERITED; 560 typedef PictureRenderer INHERITED;
561 }; 561 };
562 562
563 class TiledPictureRenderer : public PictureRenderer { 563 class TiledPictureRenderer : public PictureRenderer {
564 public: 564 public:
565 #if SK_SUPPORT_GPU 565 #if SK_SUPPORT_GPU
566 TiledPictureRenderer(const GrContextOptions &opts); 566 TiledPictureRenderer(const GrContextOptions &opts);
567 #else 567 #else
568 TiledPictureRenderer(); 568 TiledPictureRenderer();
569 #endif 569 #endif
570 570
571 virtual void init(const SkPicture* pict, 571 virtual void init(const SkPicture* pict,
572 const SkString* writePath, 572 const SkString* writePath,
573 const SkString* mismatchPath, 573 const SkString* mismatchPath,
574 const SkString* inputFilename, 574 const SkString* inputFilename,
575 bool useChecksumBasedFilenames, 575 bool useChecksumBasedFilenames,
576 bool useMultiPictureDraw) override; 576 bool useMultiPictureDraw) override;
577 577
578 /** 578 /**
579 * Renders to tiles, rather than a single canvas. 579 * Renders to tiles, rather than a single canvas.
580 * If fWritePath was provided, a separate file is 580 * If fWritePath was provided, a separate file is
581 * created for each tile, named "path0.png", "path1.png", etc. 581 * created for each tile, named "path0.png", "path1.png", etc.
582 */ 582 */
583 bool render(SkBitmap** out = NULL) override; 583 bool render(SkBitmap** out = nullptr) override;
584 584
585 void end() override; 585 void end() override;
586 586
587 void setTileWidth(int width) { 587 void setTileWidth(int width) {
588 fTileWidth = width; 588 fTileWidth = width;
589 } 589 }
590 590
591 int getTileWidth() const { 591 int getTileWidth() const {
592 return fTileWidth; 592 return fTileWidth;
593 } 593 }
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 * into an SkPicturePlayback, which we want to time. 696 * into an SkPicturePlayback, which we want to time.
697 */ 697 */
698 class PlaybackCreationRenderer : public PictureRenderer { 698 class PlaybackCreationRenderer : public PictureRenderer {
699 public: 699 public:
700 #if SK_SUPPORT_GPU 700 #if SK_SUPPORT_GPU
701 PlaybackCreationRenderer(const GrContextOptions &opts) : INHERITED(opts) { } 701 PlaybackCreationRenderer(const GrContextOptions &opts) : INHERITED(opts) { }
702 #endif 702 #endif
703 703
704 void setup() override; 704 void setup() override;
705 705
706 bool render(SkBitmap** out = NULL) override; 706 bool render(SkBitmap** out = nullptr) override;
707 707
708 SkString getPerIterTimeFormat() override { return SkString("%.4f"); } 708 SkString getPerIterTimeFormat() override { return SkString("%.4f"); }
709 709
710 SkString getNormalTimeFormat() override { return SkString("%6.4f"); } 710 SkString getNormalTimeFormat() override { return SkString("%6.4f"); }
711 711
712 private: 712 private:
713 SkAutoTDelete<SkPictureRecorder> fRecorder; 713 SkAutoTDelete<SkPictureRecorder> fRecorder;
714 714
715 SkString getConfigNameInternal() override; 715 SkString getConfigNameInternal() override;
716 716
717 typedef PictureRenderer INHERITED; 717 typedef PictureRenderer INHERITED;
718 }; 718 };
719 719
720 #if SK_SUPPORT_GPU 720 #if SK_SUPPORT_GPU
721 extern PictureRenderer* CreateGatherPixelRefsRenderer(const GrContextOptions& op ts); 721 extern PictureRenderer* CreateGatherPixelRefsRenderer(const GrContextOptions& op ts);
722 #else 722 #else
723 extern PictureRenderer* CreateGatherPixelRefsRenderer(); 723 extern PictureRenderer* CreateGatherPixelRefsRenderer();
724 #endif 724 #endif
725 725
726 } 726 }
727 727
728 #endif // PictureRenderer_DEFINED 728 #endif // PictureRenderer_DEFINED
OLDNEW
« no previous file with comments | « tools/PictureBenchmark.cpp ('k') | tools/PictureRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698