diff options
author | robertphillips <robertphillips@google.com> | 2014-08-29 08:03:56 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-08-29 08:03:56 -0700 |
commit | a8d7f0b13cd4c6d773fcf055fe17db75d260fa05 (patch) | |
tree | 37e85b212ccd5761b9a736282e75ebf838840798 /include | |
parent | 77d724c07878b21602e96e095f6a446c429a079a (diff) |
Try out scalar picture sizes
This paves the way for removing the 'fTile' parameter from SkPictureShader (although that should be a different CL). If we like this we could also move to providing an entire cull SkRect.
R=reed@google.com, mtklein@google.com, fmalita@google.com, fmalita@chromium.org
Author: robertphillips@google.com
Review URL: https://codereview.chromium.org/513983002
Diffstat (limited to 'include')
-rw-r--r-- | include/core/SkPicture.h | 33 | ||||
-rw-r--r-- | include/core/SkPictureRecorder.h | 26 |
2 files changed, 32 insertions, 27 deletions
diff --git a/include/core/SkPicture.h b/include/core/SkPicture.h index 30d08211db..6a5404085e 100644 --- a/include/core/SkPicture.h +++ b/include/core/SkPicture.h @@ -120,19 +120,16 @@ public: */ void draw(SkCanvas* canvas, SkDrawPictureCallback* = NULL) const; - /** Return the width of the picture's recording canvas. This - value reflects what was passed to setSize(), and does not necessarily - reflect the bounds of what has been recorded into the picture. - @return the width of the picture's recording canvas - */ - int width() const { return fWidth; } +#ifdef SK_LEGACY_PICTURE_SIZE_API + int width() const { return SkScalarCeilToInt(fCullWidth); } + int height() const { return SkScalarCeilToInt(fCullHeight); } +#endif - /** Return the height of the picture's recording canvas. This - value reflects what was passed to setSize(), and does not necessarily - reflect the bounds of what has been recorded into the picture. - @return the height of the picture's recording canvas + /** Return the cull rect used when creating this picture: { 0, 0, cullWidth, cullHeight }. + It does not necessarily reflect the bounds of what has been recorded into the picture. + @return the cull rect used to create this picture */ - int height() const { return fHeight; } + const SkRect cullRect() const { return SkRect::MakeWH(fCullWidth, fCullHeight); } /** Return a non-zero, unique value representing the picture. This call is only valid when not recording. Between a beginRecording/endRecording @@ -180,7 +177,7 @@ public: If false is returned, SkPictInfo is unmodified. */ static bool InternalOnly_StreamIsSKP(SkStream*, SkPictInfo*); - static bool InternalOnly_BufferIsSKP(SkReadBuffer&, SkPictInfo*); + static bool InternalOnly_BufferIsSKP(SkReadBuffer*, SkPictInfo*); /** Return true if the picture is suitable for rendering on the GPU. */ @@ -244,19 +241,21 @@ private: // V32: Removed SkPaintOptionsAndroid from SkPaint // V33: Serialize only public API of effects. // V34: Add SkTextBlob serialization. + // V35: Store SkRect (rather then width & height) in header // Note: If the picture version needs to be increased then please follow the // steps to generate new SKPs in (only accessible to Googlers): http://goo.gl/qATVcw // Only SKPs within the min/current picture version range (inclusive) can be read. static const uint32_t MIN_PICTURE_VERSION = 19; - static const uint32_t CURRENT_PICTURE_VERSION = 34; + static const uint32_t CURRENT_PICTURE_VERSION = 35; mutable uint32_t fUniqueID; // TODO: make SkPictureData const when clone method goes away SkAutoTDelete<SkPictureData> fData; - int fWidth, fHeight; + const SkScalar fCullWidth; + const SkScalar fCullHeight; mutable SkAutoTUnref<const AccelData> fAccelData; mutable SkTDArray<DeletionListener*> fDeletionListeners; // pointers are refed @@ -266,9 +265,9 @@ private: // Create a new SkPicture from an existing SkPictureData. The new picture // takes ownership of 'data'. - SkPicture(SkPictureData* data, int width, int height); + SkPicture(SkPictureData* data, SkScalar width, SkScalar height); - SkPicture(int width, int height, const SkPictureRecord& record, bool deepCopyOps); + SkPicture(SkScalar width, SkScalar height, const SkPictureRecord& record, bool deepCopyOps); // An OperationList encapsulates a set of operation offsets into the picture byte // stream along with the CTMs needed for those operation. @@ -303,7 +302,7 @@ private: typedef SkRefCnt INHERITED; // Takes ownership of the SkRecord, refs the (optional) BBH. - SkPicture(int width, int height, SkRecord*, SkBBoxHierarchy*); + SkPicture(SkScalar width, SkScalar height, SkRecord*, SkBBoxHierarchy*); // Return as a new SkPicture that's backed by SkRecord. static SkPicture* Forwardport(const SkPicture&); diff --git a/include/core/SkPictureRecorder.h b/include/core/SkPictureRecorder.h index bd8614813b..a3f7d48332 100644 --- a/include/core/SkPictureRecorder.h +++ b/include/core/SkPictureRecorder.h @@ -28,16 +28,23 @@ public: SkPictureRecorder(); ~SkPictureRecorder(); +#ifdef SK_LEGACY_PICTURE_SIZE_API + SkCanvas* beginRecording(int width, int height, + SkBBHFactory* bbhFactory = NULL, + uint32_t recordFlags = 0) { + return this->beginRecording(SkIntToScalar(width), SkIntToScalar(height), + bbhFactory, recordFlags); + } +#endif + /** Returns the canvas that records the drawing commands. - @param width the base width for the picture, as if the recording - canvas' bitmap had this width. - @param height the base width for the picture, as if the recording - canvas' bitmap had this height. + @param width the width of the cull rect used when recording this picture. + @param height the height of the cull rect used when recording this picture. @param bbhFactory factory to create desired acceleration structure @param recordFlags optional flags that control recording. @return the canvas. */ - SkCanvas* beginRecording(int width, int height, + SkCanvas* beginRecording(SkScalar width, SkScalar height, SkBBHFactory* bbhFactory = NULL, uint32_t recordFlags = 0); @@ -47,12 +54,12 @@ public: // then we use EXPERIMENTAL_beginRecording(). // Old slower backend. - SkCanvas* DEPRECATED_beginRecording(int width, int height, + SkCanvas* DEPRECATED_beginRecording(SkScalar width, SkScalar height, SkBBHFactory* bbhFactory = NULL, uint32_t recordFlags = 0); // New faster backend. - SkCanvas* EXPERIMENTAL_beginRecording(int width, int height, + SkCanvas* EXPERIMENTAL_beginRecording(SkScalar width, SkScalar height, SkBBHFactory* bbhFactory = NULL); /** Returns the recording canvas if one is active, or NULL if recording is @@ -87,9 +94,8 @@ private: friend class SkPictureRecorderReplayTester; // for unit testing void partialReplay(SkCanvas* canvas) const; - int fWidth; - int fHeight; - + SkScalar fCullWidth; + SkScalar fCullHeight; SkAutoTUnref<SkBBoxHierarchy> fBBH; // One of these two canvases will be non-NULL. |