diff options
Diffstat (limited to 'chromium/cc/resources/picture.h')
-rw-r--r-- | chromium/cc/resources/picture.h | 87 |
1 files changed, 57 insertions, 30 deletions
diff --git a/chromium/cc/resources/picture.h b/chromium/cc/resources/picture.h index 085fb6a4531..78833d17e91 100644 --- a/chromium/cc/resources/picture.h +++ b/chromium/cc/resources/picture.h @@ -16,14 +16,17 @@ #include "base/logging.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" +#include "base/threading/thread_checker.h" #include "cc/base/cc_export.h" #include "cc/base/region.h" -#include "skia/ext/lazy_pixel_ref.h" #include "skia/ext/refptr.h" -#include "third_party/skia/include/core/SkPixelRef.h" -#include "third_party/skia/include/core/SkTileGridPicture.h" +#include "third_party/skia/include/core/SkBBHFactory.h" +#include "third_party/skia/include/core/SkPicture.h" +#include "third_party/skia/include/record/SkRecording.h" #include "ui/gfx/rect.h" +class SkPixelRef; + namespace base { class Value; } @@ -40,10 +43,24 @@ class CC_EXPORT Picture : public base::RefCountedThreadSafe<Picture> { public: typedef std::pair<int, int> PixelRefMapKey; - typedef std::vector<skia::LazyPixelRef*> PixelRefs; + typedef std::vector<SkPixelRef*> PixelRefs; typedef base::hash_map<PixelRefMapKey, PixelRefs> PixelRefMap; - static scoped_refptr<Picture> Create(gfx::Rect layer_rect); + enum RecordingMode { + RECORD_NORMALLY, + RECORD_WITH_SK_NULL_CANVAS, + RECORD_WITH_PAINTING_DISABLED, + RECORD_WITH_SKRECORD, + RECORDING_MODE_COUNT, // Must be the last entry. + }; + + static scoped_refptr<Picture> Create( + const gfx::Rect& layer_rect, + ContentLayerClient* client, + const SkTileGridFactory::TileGridInfo& tile_grid_info, + bool gather_pixels_refs, + int num_raster_threads, + RecordingMode recording_mode); static scoped_refptr<Picture> CreateFromValue(const base::Value* value); static scoped_refptr<Picture> CreateFromSkpValue(const base::Value* value); @@ -51,25 +68,17 @@ class CC_EXPORT Picture gfx::Rect OpaqueRect() const { return opaque_rect_; } // Get thread-safe clone for rasterizing with on a specific thread. - scoped_refptr<Picture> GetCloneForDrawingOnThread( - unsigned thread_index) const; - - // Make thread-safe clones for rasterizing with. - void CloneForDrawing(int num_threads); - - // Record a paint operation. To be able to safely use this SkPicture for - // playback on a different thread this can only be called once. - void Record(ContentLayerClient* client, - const SkTileGridPicture::TileGridInfo& tile_grid_info); - - // Gather pixel refs from recording. - void GatherPixelRefs(const SkTileGridPicture::TileGridInfo& tile_grid_info); + Picture* GetCloneForDrawingOnThread(unsigned thread_index); // Has Record() been called yet? bool HasRecording() const { return picture_.get() != NULL; } - // Apply this scale and raster the negated region into the canvas. See comment - // in PicturePileImpl::RasterCommon for explanation on negated content region. + bool IsSuitableForGpuRasterization() const; + + // Apply this scale and raster the negated region into the canvas. + // |negated_content_region| specifies the region to be clipped out of the + // raster operation, i.e., the parts of the canvas which will not get drawn + // to. int Raster(SkCanvas* canvas, SkDrawPictureCallback* callback, const Region& negated_content_region, @@ -81,18 +90,21 @@ class CC_EXPORT Picture scoped_ptr<base::Value> AsValue() const; + // This iterator imprecisely returns the set of pixel refs that are needed to + // raster this layer rect from this picture. Internally, pixel refs are + // clumped into tile grid buckets, so there may be false positives. class CC_EXPORT PixelRefIterator { public: PixelRefIterator(); - PixelRefIterator(gfx::Rect layer_rect, const Picture* picture); + PixelRefIterator(const gfx::Rect& layer_rect, const Picture* picture); ~PixelRefIterator(); - skia::LazyPixelRef* operator->() const { + SkPixelRef* operator->() const { DCHECK_LT(current_index_, current_pixel_refs_->size()); return (*current_pixel_refs_)[current_index_]; } - skia::LazyPixelRef* operator*() const { + SkPixelRef* operator*() const { DCHECK_LT(current_index_, current_pixel_refs_->size()); return (*current_pixel_refs_)[current_index_]; } @@ -114,28 +126,41 @@ class CC_EXPORT Picture int current_y_; }; - void EmitTraceSnapshot(); - void EmitTraceSnapshotAlias(Picture* original); + void EmitTraceSnapshot() const; + void EmitTraceSnapshotAlias(Picture* original) const; bool WillPlayBackBitmaps() const { return picture_->willPlayBackBitmaps(); } private: - explicit Picture(gfx::Rect layer_rect); + explicit Picture(const gfx::Rect& layer_rect); // This constructor assumes SkPicture is already ref'd and transfers // ownership to this picture. Picture(const skia::RefPtr<SkPicture>&, - gfx::Rect layer_rect, - gfx::Rect opaque_rect, + const gfx::Rect& layer_rect, + const gfx::Rect& opaque_rect, const PixelRefMap& pixel_refs); // This constructor will call AdoptRef on the SkPicture. Picture(SkPicture*, - gfx::Rect layer_rect, - gfx::Rect opaque_rect); + const gfx::Rect& layer_rect, + const gfx::Rect& opaque_rect); ~Picture(); + // Make thread-safe clones for rasterizing with. + void CloneForDrawing(int num_threads); + + // Record a paint operation. To be able to safely use this SkPicture for + // playback on a different thread this can only be called once. + void Record(ContentLayerClient* client, + const SkTileGridFactory::TileGridInfo& tile_grid_info, + RecordingMode recording_mode); + + // Gather pixel refs from recording. + void GatherPixelRefs(const SkTileGridFactory::TileGridInfo& tile_grid_info); + gfx::Rect layer_rect_; gfx::Rect opaque_rect_; skia::RefPtr<SkPicture> picture_; + scoped_ptr<const EXPERIMENTAL::SkPlayback> playback_; typedef std::vector<scoped_refptr<Picture> > PictureVector; PictureVector clones_; @@ -150,6 +175,8 @@ class CC_EXPORT Picture scoped_refptr<base::debug::ConvertableToTraceFormat> AsTraceableRecordData() const; + base::ThreadChecker raster_thread_checker_; + friend class base::RefCountedThreadSafe<Picture>; friend class PixelRefIterator; DISALLOW_COPY_AND_ASSIGN(Picture); |