| OLD | NEW | 
|---|
|  | (Empty) | 
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. |  | 
| 2 // Use of this source code is governed by a BSD-style license that can be |  | 
| 3 // found in the LICENSE file. |  | 
| 4 |  | 
| 5 #ifndef CC_RESOURCES_PICTURE_PILE_BASE_H_ |  | 
| 6 #define CC_RESOURCES_PICTURE_PILE_BASE_H_ |  | 
| 7 |  | 
| 8 #include <bitset> |  | 
| 9 #include <list> |  | 
| 10 #include <utility> |  | 
| 11 |  | 
| 12 #include "base/containers/hash_tables.h" |  | 
| 13 #include "cc/base/cc_export.h" |  | 
| 14 #include "cc/base/region.h" |  | 
| 15 #include "cc/base/tiling_data.h" |  | 
| 16 #include "cc/resources/picture.h" |  | 
| 17 #include "ui/gfx/geometry/size.h" |  | 
| 18 |  | 
| 19 namespace base { |  | 
| 20 namespace debug { |  | 
| 21 class TracedValue; |  | 
| 22 } |  | 
| 23 class Value; |  | 
| 24 } |  | 
| 25 |  | 
| 26 namespace cc { |  | 
| 27 |  | 
| 28 class CC_EXPORT PicturePileBase { |  | 
| 29  public: |  | 
| 30   PicturePileBase(); |  | 
| 31   explicit PicturePileBase(const PicturePileBase* other); |  | 
| 32 |  | 
| 33   gfx::Size tiling_size() const { return tiling_.tiling_size(); } |  | 
| 34   void SetMinContentsScale(float min_contents_scale); |  | 
| 35 |  | 
| 36   // If non-empty, all pictures tiles inside this rect are recorded. There may |  | 
| 37   // be recordings outside this rect, but everything inside the rect is |  | 
| 38   // recorded. |  | 
| 39   gfx::Rect recorded_viewport() const { return recorded_viewport_; } |  | 
| 40 |  | 
| 41   int num_tiles_x() const { return tiling_.num_tiles_x(); } |  | 
| 42   int num_tiles_y() const { return tiling_.num_tiles_y(); } |  | 
| 43   gfx::Rect tile_bounds(int x, int y) const { return tiling_.TileBounds(x, y); } |  | 
| 44   bool HasRecordingAt(int x, int y); |  | 
| 45 |  | 
| 46   bool is_solid_color() const { return is_solid_color_; } |  | 
| 47   SkColor solid_color() const { return solid_color_; } |  | 
| 48 |  | 
| 49   void set_is_mask(bool is_mask) { is_mask_ = is_mask; } |  | 
| 50 |  | 
| 51   static void ComputeTileGridInfo(const gfx::Size& tile_grid_size, |  | 
| 52                                   SkTileGridFactory::TileGridInfo* info); |  | 
| 53 |  | 
| 54   void SetTileGridSize(const gfx::Size& tile_grid_size); |  | 
| 55   TilingData& tiling() { return tiling_; } |  | 
| 56 |  | 
| 57   SkTileGridFactory::TileGridInfo GetTileGridInfoForTesting() const { |  | 
| 58     return tile_grid_info_; |  | 
| 59   } |  | 
| 60 |  | 
| 61   void SetRecordedViewportForTesting(const gfx::Rect& viewport) { |  | 
| 62     recorded_viewport_ = viewport; |  | 
| 63   } |  | 
| 64   void SetHasAnyRecordingsForTesting(bool has_recordings) { |  | 
| 65     has_any_recordings_ = has_recordings; |  | 
| 66   } |  | 
| 67 |  | 
| 68  protected: |  | 
| 69   class CC_EXPORT PictureInfo { |  | 
| 70    public: |  | 
| 71     enum { |  | 
| 72       INVALIDATION_FRAMES_TRACKED = 32 |  | 
| 73     }; |  | 
| 74 |  | 
| 75     PictureInfo(); |  | 
| 76     ~PictureInfo(); |  | 
| 77 |  | 
| 78     bool Invalidate(int frame_number); |  | 
| 79     bool NeedsRecording(int frame_number, int distance_to_visible); |  | 
| 80     void SetPicture(scoped_refptr<Picture> picture); |  | 
| 81     const Picture* GetPicture() const; |  | 
| 82 |  | 
| 83     float GetInvalidationFrequencyForTesting() const { |  | 
| 84       return GetInvalidationFrequency(); |  | 
| 85     } |  | 
| 86 |  | 
| 87    private: |  | 
| 88     void AdvanceInvalidationHistory(int frame_number); |  | 
| 89     float GetInvalidationFrequency() const; |  | 
| 90 |  | 
| 91     int last_frame_number_; |  | 
| 92     scoped_refptr<const Picture> picture_; |  | 
| 93     std::bitset<INVALIDATION_FRAMES_TRACKED> invalidation_history_; |  | 
| 94   }; |  | 
| 95 |  | 
| 96   typedef std::pair<int, int> PictureMapKey; |  | 
| 97   typedef base::hash_map<PictureMapKey, PictureInfo> PictureMap; |  | 
| 98 |  | 
| 99   virtual ~PicturePileBase(); |  | 
| 100 |  | 
| 101   int buffer_pixels() const { return tiling_.border_texels(); } |  | 
| 102   void Clear(); |  | 
| 103 |  | 
| 104   gfx::Rect PaddedRect(const PictureMapKey& key) const; |  | 
| 105   gfx::Rect PadRect(const gfx::Rect& rect) const; |  | 
| 106 |  | 
| 107   // A picture pile is a tiled set of pictures. The picture map is a map of tile |  | 
| 108   // indices to picture infos. |  | 
| 109   PictureMap picture_map_; |  | 
| 110   TilingData tiling_; |  | 
| 111   gfx::Rect recorded_viewport_; |  | 
| 112   float min_contents_scale_; |  | 
| 113   SkTileGridFactory::TileGridInfo tile_grid_info_; |  | 
| 114   SkColor background_color_; |  | 
| 115   int slow_down_raster_scale_factor_for_debug_; |  | 
| 116   bool contents_opaque_; |  | 
| 117   bool contents_fill_bounds_completely_; |  | 
| 118   bool show_debug_picture_borders_; |  | 
| 119   bool clear_canvas_with_debug_color_; |  | 
| 120   // A hint about whether there are any recordings. This may be a false |  | 
| 121   // positive. |  | 
| 122   bool has_any_recordings_; |  | 
| 123   bool is_mask_; |  | 
| 124   bool is_solid_color_; |  | 
| 125   SkColor solid_color_; |  | 
| 126 |  | 
| 127  private: |  | 
| 128   friend class PicturePileImpl; |  | 
| 129 |  | 
| 130   void SetBufferPixels(int buffer_pixels); |  | 
| 131 |  | 
| 132   DISALLOW_COPY_AND_ASSIGN(PicturePileBase); |  | 
| 133 }; |  | 
| 134 |  | 
| 135 }  // namespace cc |  | 
| 136 |  | 
| 137 #endif  // CC_RESOURCES_PICTURE_PILE_BASE_H_ |  | 
| OLD | NEW | 
|---|