diff options
author | 2024-09-09 19:44:27 +0000 | |
---|---|---|
committer | 2024-09-10 15:46:16 +0000 | |
commit | 84642f815835c014747c1398f1f38ec2692872d2 (patch) | |
tree | af56f88fffe2c7b9a5a4e5435c482f680c1defea | |
parent | 4d05eceb317f418777783268bc944cc2967cf53d (diff) |
Remove references to SkMSec type
Skia wants to remove this from the public API:
https://skia-review.googlesource.com/c/skia/+/897150
Change-Id: Idef3d1d79014a10cfd1f1e2ad740666bebe6d3cf
Flag: EXEMPT refactor
-rw-r--r-- | libs/hwui/SkiaInterpolator.cpp | 28 | ||||
-rw-r--r-- | libs/hwui/jni/GIFMovie.cpp | 10 | ||||
-rw-r--r-- | libs/hwui/jni/Movie.h | 12 | ||||
-rw-r--r-- | libs/hwui/jni/MovieImpl.cpp | 8 |
4 files changed, 31 insertions, 27 deletions
diff --git a/libs/hwui/SkiaInterpolator.cpp b/libs/hwui/SkiaInterpolator.cpp index 5a45ad9085e7..8deac61e8baa 100644 --- a/libs/hwui/SkiaInterpolator.cpp +++ b/libs/hwui/SkiaInterpolator.cpp @@ -47,6 +47,8 @@ static inline Dot14 pin_and_convert(float x) { return static_cast<Dot14>(x * Dot14_ONE); } +using MSec = uint32_t; // millisecond duration + static float SkUnitCubicInterp(float value, float bx, float by, float cx, float cy) { // pin to the unit-square, and convert to 2.14 Dot14 x = pin_and_convert(value); @@ -120,7 +122,7 @@ void SkiaInterpolatorBase::reset(int elemCount, int frameCount) { Totaling fElemCount+2 entries per keyframe */ -bool SkiaInterpolatorBase::getDuration(SkMSec* startTime, SkMSec* endTime) const { +bool SkiaInterpolatorBase::getDuration(MSec* startTime, MSec* endTime) const { if (fFrameCount == 0) { return false; } @@ -134,7 +136,7 @@ bool SkiaInterpolatorBase::getDuration(SkMSec* startTime, SkMSec* endTime) const return true; } -float SkiaInterpolatorBase::ComputeRelativeT(SkMSec time, SkMSec prevTime, SkMSec nextTime, +float SkiaInterpolatorBase::ComputeRelativeT(MSec time, MSec prevTime, MSec nextTime, const float blend[4]) { LOG_FATAL_IF(time < prevTime || time > nextTime); @@ -144,7 +146,7 @@ float SkiaInterpolatorBase::ComputeRelativeT(SkMSec time, SkMSec prevTime, SkMSe // Returns the index of where the item is or the bit not of the index // where the item should go in order to keep arr sorted in ascending order. -int SkiaInterpolatorBase::binarySearch(const SkTimeCode* arr, int count, SkMSec target) { +int SkiaInterpolatorBase::binarySearch(const SkTimeCode* arr, int count, MSec target) { if (count <= 0) { return ~0; } @@ -154,7 +156,7 @@ int SkiaInterpolatorBase::binarySearch(const SkTimeCode* arr, int count, SkMSec while (lo < hi) { int mid = (hi + lo) / 2; - SkMSec elem = arr[mid].fTime; + MSec elem = arr[mid].fTime; if (elem == target) { return mid; } else if (elem < target) { @@ -171,21 +173,21 @@ int SkiaInterpolatorBase::binarySearch(const SkTimeCode* arr, int count, SkMSec return ~(lo + 1); } -SkiaInterpolatorBase::Result SkiaInterpolatorBase::timeToT(SkMSec time, float* T, int* indexPtr, +SkiaInterpolatorBase::Result SkiaInterpolatorBase::timeToT(MSec time, float* T, int* indexPtr, bool* exactPtr) const { LOG_FATAL_IF(fFrameCount <= 0); Result result = kNormal_Result; if (fRepeat != 1.0f) { - SkMSec startTime = 0, endTime = 0; // initialize to avoid warning + MSec startTime = 0, endTime = 0; // initialize to avoid warning this->getDuration(&startTime, &endTime); - SkMSec totalTime = endTime - startTime; - SkMSec offsetTime = time - startTime; + MSec totalTime = endTime - startTime; + MSec offsetTime = time - startTime; endTime = SkScalarFloorToInt(fRepeat * totalTime); if (offsetTime >= endTime) { float fraction = SkScalarFraction(fRepeat); offsetTime = fraction == 0 && fRepeat > 0 ? totalTime - : (SkMSec)SkScalarFloorToInt(fraction * totalTime); + : (MSec)SkScalarFloorToInt(fraction * totalTime); result = kFreezeEnd_Result; } else { int mirror = fFlags & kMirror; @@ -217,11 +219,11 @@ SkiaInterpolatorBase::Result SkiaInterpolatorBase::timeToT(SkMSec time, float* T } LOG_FATAL_IF(index >= fFrameCount); const SkTimeCode* nextTime = &fTimes[index]; - SkMSec nextT = nextTime[0].fTime; + MSec nextT = nextTime[0].fTime; if (exact) { *T = 0; } else { - SkMSec prevT = nextTime[-1].fTime; + MSec prevT = nextTime[-1].fTime; *T = ComputeRelativeT(time, prevT, nextT, nextTime[-1].fBlend); } *indexPtr = index; @@ -251,7 +253,7 @@ void SkiaInterpolator::reset(int elemCount, int frameCount) { static const float gIdentityBlend[4] = {0.33333333f, 0.33333333f, 0.66666667f, 0.66666667f}; -bool SkiaInterpolator::setKeyFrame(int index, SkMSec time, const float values[], +bool SkiaInterpolator::setKeyFrame(int index, MSec time, const float values[], const float blend[4]) { LOG_FATAL_IF(values == nullptr); @@ -272,7 +274,7 @@ bool SkiaInterpolator::setKeyFrame(int index, SkMSec time, const float values[], return success; } -SkiaInterpolator::Result SkiaInterpolator::timeToValues(SkMSec time, float values[]) const { +SkiaInterpolator::Result SkiaInterpolator::timeToValues(MSec time, float values[]) const { float T; int index; bool exact; diff --git a/libs/hwui/jni/GIFMovie.cpp b/libs/hwui/jni/GIFMovie.cpp index ae6ac4ce4ecc..6c82aa1ca27d 100644 --- a/libs/hwui/jni/GIFMovie.cpp +++ b/libs/hwui/jni/GIFMovie.cpp @@ -30,7 +30,7 @@ public: protected: virtual bool onGetInfo(Info*); - virtual bool onSetTime(SkMSec); + virtual bool onSetTime(Movie::MSec); virtual bool onGetBitmap(SkBitmap*); private: @@ -72,7 +72,7 @@ GIFMovie::~GIFMovie() DGifCloseFile(fGIF, nullptr); } -static SkMSec savedimage_duration(const SavedImage* image) +static Movie::MSec savedimage_duration(const SavedImage* image) { for (int j = 0; j < image->ExtensionBlockCount; j++) { @@ -91,7 +91,7 @@ bool GIFMovie::onGetInfo(Info* info) if (nullptr == fGIF) return false; - SkMSec dur = 0; + Movie::MSec dur = 0; for (int i = 0; i < fGIF->ImageCount; i++) dur += savedimage_duration(&fGIF->SavedImages[i]); @@ -102,12 +102,12 @@ bool GIFMovie::onGetInfo(Info* info) return true; } -bool GIFMovie::onSetTime(SkMSec time) +bool GIFMovie::onSetTime(Movie::MSec time) { if (nullptr == fGIF) return false; - SkMSec dur = 0; + Movie::MSec dur = 0; for (int i = 0; i < fGIF->ImageCount; i++) { dur += savedimage_duration(&fGIF->SavedImages[i]); diff --git a/libs/hwui/jni/Movie.h b/libs/hwui/jni/Movie.h index 02113dd58ec8..d633d935f566 100644 --- a/libs/hwui/jni/Movie.h +++ b/libs/hwui/jni/Movie.h @@ -19,6 +19,8 @@ class SkStreamRewindable; class Movie : public SkRefCnt { public: + using MSec = uint32_t; // millisecond duration + /** Try to create a movie from the stream. If the stream format is not supported, return NULL. */ @@ -36,7 +38,7 @@ public: */ static Movie* DecodeMemory(const void* data, size_t length); - SkMSec duration(); + MSec duration(); int width(); int height(); int isOpaque(); @@ -46,21 +48,21 @@ public: bitmap/frame from the previous state (i.e. true means you need to redraw). */ - bool setTime(SkMSec); + bool setTime(MSec); // return the right bitmap for the current time code const SkBitmap& bitmap(); protected: struct Info { - SkMSec fDuration; + MSec fDuration; int fWidth; int fHeight; bool fIsOpaque; }; virtual bool onGetInfo(Info*) = 0; - virtual bool onSetTime(SkMSec) = 0; + virtual bool onSetTime(MSec) = 0; virtual bool onGetBitmap(SkBitmap*) = 0; // visible for subclasses @@ -68,7 +70,7 @@ protected: private: Info fInfo; - SkMSec fCurrTime; + MSec fCurrTime; SkBitmap fBitmap; bool fNeedBitmap; diff --git a/libs/hwui/jni/MovieImpl.cpp b/libs/hwui/jni/MovieImpl.cpp index abb75fa99c94..a31a15f061b1 100644 --- a/libs/hwui/jni/MovieImpl.cpp +++ b/libs/hwui/jni/MovieImpl.cpp @@ -11,7 +11,7 @@ // We should never see this in normal operation since our time values are // 0-based. So we use it as a sentinel. -#define UNINITIALIZED_MSEC ((SkMSec)-1) +#define UNINITIALIZED_MSEC ((Movie::MSec)-1) Movie::Movie() { @@ -26,7 +26,7 @@ void Movie::ensureInfo() memset(&fInfo, 0, sizeof(fInfo)); // failure } -SkMSec Movie::duration() +Movie::MSec Movie::duration() { this->ensureInfo(); return fInfo.fDuration; @@ -50,9 +50,9 @@ int Movie::isOpaque() return fInfo.fIsOpaque; } -bool Movie::setTime(SkMSec time) +bool Movie::setTime(Movie::MSec time) { - SkMSec dur = this->duration(); + Movie::MSec dur = this->duration(); if (time > dur) time = dur; |