1 /*
2  * Copyright 2012 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 #ifndef CopyTilesRenderer_DEFINED
9 #define CopyTilesRenderer_DEFINED
10 
11 #include "PictureRenderer.h"
12 #include "SkTypes.h"
13 
14 class SkPicture;
15 class SkString;
16 
17 namespace sk_tools {
18     /**
19      *  PictureRenderer that draws the picture and then extracts it into tiles. For large pictures,
20      *  it will divide the picture into large tiles and draw the picture once for each large tile.
21      */
22     class CopyTilesRenderer : public TiledPictureRenderer {
23 
24     public:
25 #if SK_SUPPORT_GPU
26         CopyTilesRenderer(const GrContext::Options &opts, int x, int y);
27 #else
28         CopyTilesRenderer(int x, int y);
29 #endif
30         virtual void init(const SkPicture* pict,
31                           const SkString* writePath,
32                           const SkString* mismatchPath,
33                           const SkString* inputFilename,
34                           bool useChecksumBasedFilenames,
35                           bool useMultiPictureDraw) override;
36 
37         /**
38          *  Similar to TiledPictureRenderer, this will draw a PNG for each tile. However, the
39          *  numbering (and actual tiles) will be different.
40          */
41         bool render(SkBitmap** out) override;
42 
supportsTimingIndividualTiles()43         bool supportsTimingIndividualTiles() override { return false; }
44 
45     private:
46         int fXTilesPerLargeTile;
47         int fYTilesPerLargeTile;
48 
49         int fLargeTileWidth;
50         int fLargeTileHeight;
51 
52         SkString getConfigNameInternal() override;
53 
54         typedef TiledPictureRenderer INHERITED;
55     };
56 } // sk_tools
57 #endif // CopyTilesRenderer_DEFINED
58