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 SkTileGridPicture_DEFINED 9 #define SkTileGridPicture_DEFINED 10 11 #include "SkPicture.h" 12 #include "SkPoint.h" 13 #include "SkSize.h" 14 15 /** 16 * Subclass of SkPicture that override the behavior of the 17 * kOptimizeForClippedPlayback_RecordingFlag by creating an SkTileGrid 18 * structure rather than an R-Tree. The tile grid has lower recording 19 * and playback costs, but is less effective at eliminating extraneous 20 * primitives for arbitrary query rectangles. It is most effective for 21 * tiled playback when the tile structure is known at record time. 22 */ 23 class SK_API SkTileGridPicture : public SkPicture { 24 public: 25 struct TileGridInfo { 26 /** Tile placement interval */ 27 SkISize fTileInterval; 28 29 /** Pixel coverage overlap between adjacent tiles */ 30 SkISize fMargin; 31 32 /** Offset added to device-space bounding box positions to convert 33 * them to tile-grid space. This can be used to adjust the "phase" 34 * of the tile grid to match probable query rectangles that will be 35 * used to search into the tile grid. As long as the offset is smaller 36 * or equal to the margin, there is no need to extend the domain of 37 * the tile grid to prevent data loss. 38 */ 39 SkIPoint fOffset; 40 }; 41 /** 42 * Constructor 43 * @param width recording canvas width in device pixels 44 * @param height recording canvas height in device pixels 45 * @param info description of the tiling layout 46 */ 47 SkTileGridPicture(int width, int height, const TileGridInfo& info); 48 49 virtual SkBBoxHierarchy* createBBoxHierarchy() const SK_OVERRIDE; 50 51 private: 52 int fXTileCount, fYTileCount; 53 TileGridInfo fInfo; 54 }; 55 56 #endif 57