rename SkMipMap to SkMipmap

Change-Id: I1fa8a0482a717847236a30b4851061f4074b7755
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/302644
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Mike Reed <reed@google.com>
This commit is contained in:
Mike Reed 2020-07-14 17:16:32 -04:00 committed by Skia Commit-Bot
parent 779813a239
commit 13711ebe68
48 changed files with 193 additions and 195 deletions

View File

@ -7,16 +7,16 @@
#include "bench/Benchmark.h"
#include "include/core/SkBitmap.h"
#include "src/core/SkMipMap.h"
#include "src/core/SkMipmap.h"
class MipMapBench: public Benchmark {
class MipmapBench: public Benchmark {
SkBitmap fBitmap;
SkString fName;
const int fW, fH;
bool fHalfFoat;
public:
MipMapBench(int w, int h, bool halfFloat = false)
MipmapBench(int w, int h, bool halfFloat = false)
: fW(w), fH(h), fHalfFoat(halfFloat)
{
fName.printf("mipmap_build_%dx%d", w, h);
@ -42,7 +42,7 @@ protected:
void onDraw(int loops, SkCanvas*) override {
for (int i = 0; i < loops * 4; i++) {
SkMipMap::Build(fBitmap, nullptr)->unref();
SkMipmap::Build(fBitmap, nullptr)->unref();
}
}
@ -53,15 +53,15 @@ private:
// Build variants that exercise the width and heights being even or odd at each level, as the
// impl specializes on each of these.
//
DEF_BENCH( return new MipMapBench(511, 511); )
DEF_BENCH( return new MipMapBench(512, 511); )
DEF_BENCH( return new MipMapBench(511, 512); )
DEF_BENCH( return new MipMapBench(512, 512); )
DEF_BENCH( return new MipmapBench(511, 511); )
DEF_BENCH( return new MipmapBench(512, 511); )
DEF_BENCH( return new MipmapBench(511, 512); )
DEF_BENCH( return new MipmapBench(512, 512); )
DEF_BENCH( return new MipMapBench(512, 512, true); )
DEF_BENCH( return new MipMapBench(511, 511, true); )
DEF_BENCH( return new MipmapBench(512, 512, true); )
DEF_BENCH( return new MipmapBench(511, 511, true); )
DEF_BENCH( return new MipMapBench(2048, 2048); )
DEF_BENCH( return new MipMapBench(2047, 2047); )
DEF_BENCH( return new MipMapBench(2048, 2047); )
DEF_BENCH( return new MipMapBench(2047, 2048); )
DEF_BENCH( return new MipmapBench(2048, 2048); )
DEF_BENCH( return new MipmapBench(2047, 2047); )
DEF_BENCH( return new MipmapBench(2048, 2047); )
DEF_BENCH( return new MipmapBench(2047, 2048); )

View File

@ -24,7 +24,7 @@
#include "include/gpu/GrContext.h"
#include "include/gpu/GrRecordingContext.h"
#include "src/core/SkCompressedDataUtils.h"
#include "src/core/SkMipMap.h"
#include "src/core/SkMipmap.h"
#include "src/gpu/GrContextPriv.h"
#include "src/gpu/GrDataUtils.h"
#include "src/gpu/GrRecordingContextPriv.h"
@ -108,7 +108,7 @@ static sk_sp<SkData> make_compressed_data(SkISize dimensions,
sk_sp<SkData> tmp = SkData::MakeUninitialized(totalSize);
char* pixels = (char*) tmp->writable_data();
int numMipLevels = SkMipMap::ComputeLevelCount(dimensions.width(), dimensions.height()) + 1;
int numMipLevels = SkMipmap::ComputeLevelCount(dimensions.width(), dimensions.height()) + 1;
size_t offset = 0;
@ -247,7 +247,7 @@ private:
}
SkISize levelDimensions = fImgDimensions;
int numMipLevels = SkMipMap::ComputeLevelCount(levelDimensions.width(),
int numMipLevels = SkMipmap::ComputeLevelCount(levelDimensions.width(),
levelDimensions.height()) + 1;
SkPaint imagePaint;

View File

@ -12,7 +12,7 @@
#include "include/gpu/GrContext.h"
#include "include/gpu/GrRecordingContext.h"
#include "src/core/SkCompressedDataUtils.h"
#include "src/core/SkMipMap.h"
#include "src/core/SkMipmap.h"
#include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/gl/GrGLDefines.h"
#include "src/image/SkImage_Base.h"
@ -115,7 +115,7 @@ static sk_sp<SkData> load_ktx(const char* filename, ImageInfo* imageInfo) {
if (numberOfMipmapLevels == 1) {
imageInfo->fMipMapped = GrMipMapped::kNo;
} else {
int numRequiredMipLevels = SkMipMap::ComputeLevelCount(pixelWidth, pixelHeight)+1;
int numRequiredMipLevels = SkMipmap::ComputeLevelCount(pixelWidth, pixelHeight)+1;
if (numberOfMipmapLevels != numRequiredMipLevels) {
return nullptr;
}
@ -256,7 +256,7 @@ static sk_sp<SkData> load_dds(const char* filename, ImageInfo* imageInfo) {
if (header.dwMipMapCount == 1) {
imageInfo->fMipMapped = GrMipMapped::kNo;
} else {
int numRequiredLevels = SkMipMap::ComputeLevelCount(header.dwWidth, header.dwHeight)+1;
int numRequiredLevels = SkMipmap::ComputeLevelCount(header.dwWidth, header.dwHeight)+1;
if (header.dwMipMapCount != (unsigned) numRequiredLevels) {
return nullptr;
}

View File

@ -19,7 +19,7 @@
#include "include/core/SkSize.h"
#include "include/core/SkString.h"
#include "include/private/SkNx.h"
#include "src/core/SkMipMap.h"
#include "src/core/SkMipmap.h"
#include "tools/ToolUtils.h"
#include <math.h>
@ -141,10 +141,10 @@ protected:
SkPixmap prevPM;
baseBM.peekPixels(&prevPM);
sk_sp<SkMipMap> mm(SkMipMap::Build(baseBM, nullptr));
sk_sp<SkMipmap> mm(SkMipmap::Build(baseBM, nullptr));
int index = 0;
SkMipMap::Level level;
SkMipmap::Level level;
SkScalar scale = 0.5f;
while (mm->extractLevel(SkSize::Make(scale, scale), &level)) {
SkBitmap bm = func(prevPM, level.fPixmap);
@ -249,10 +249,10 @@ protected:
SkScalar x = 4;
SkScalar y = 4;
sk_sp<SkMipMap> mm(SkMipMap::Build(baseBM, nullptr));
sk_sp<SkMipmap> mm(SkMipmap::Build(baseBM, nullptr));
int index = 0;
SkMipMap::Level level;
SkMipmap::Level level;
SkScalar scale = 0.5f;
while (mm->extractLevel(SkSize::Make(scale, scale), &level)) {
SkBitmap bm;

View File

@ -52,7 +52,7 @@ bench_sources = [
"$_bench/GameBench.cpp",
"$_bench/GeometryBench.cpp",
"$_bench/GrMemoryPoolBench.cpp",
"$_bench/GrMipMapBench.cpp",
"$_bench/GrMipmapBench.cpp",
"$_bench/GrQuadBench.cpp",
"$_bench/GrResourceCacheBench.cpp",
"$_bench/GradientBench.cpp",
@ -77,7 +77,7 @@ bench_sources = [
"$_bench/MatrixConvolutionBench.cpp",
"$_bench/MemsetBench.cpp",
"$_bench/MergeBench.cpp",
"$_bench/MipMapBench.cpp",
"$_bench/MipmapBench.cpp",
"$_bench/MorphologyBench.cpp",
"$_bench/MutexBench.cpp",
"$_bench/PDFBench.cpp",

View File

@ -266,8 +266,8 @@ skia_core_sources = [
"$_src/core/SkMessageBus.h",
"$_src/core/SkMiniRecorder.cpp",
"$_src/core/SkMiniRecorder.h",
"$_src/core/SkMipMap.cpp",
"$_src/core/SkMipMap.h",
"$_src/core/SkMipmap.cpp",
"$_src/core/SkMipmap.h",
"$_src/core/SkModeColorFilter.cpp",
"$_src/core/SkModeColorFilter.h",
"$_src/core/SkNextID.h",

View File

@ -17,7 +17,7 @@
#include "include/core/SkTileMode.h"
struct SkMask;
class SkMipMap;
class SkMipmap;
struct SkIRect;
struct SkRect;
class SkPaint;
@ -1166,7 +1166,7 @@ public:
private:
sk_sp<SkPixelRef> fPixelRef;
SkPixmap fPixmap;
sk_sp<SkMipMap> fMips;
sk_sp<SkMipmap> fMips;
friend class SkImage_Raster;
friend class SkReadBuffer; // unflatten

View File

@ -26,7 +26,7 @@ class SkData;
class SkCanvas;
class SkImageFilter;
class SkImageGenerator;
class SkMipMap;
class SkMipmap;
class SkPaint;
class SkPicture;
class SkSurface;
@ -63,10 +63,10 @@ public:
int countLevels() const;
SkPixmap level(int index) const;
sk_sp<SkMipMap> detach();
sk_sp<SkMipmap> detach();
private:
sk_sp<SkMipMap> fMM;
sk_sp<SkMipmap> fMM;
};
/** \class SkImage
@ -1210,7 +1210,7 @@ public:
* If data == nullptr, the mipmap levels are computed automatically.
* If data != nullptr, then the caller has provided the data for each level.
*/
sk_sp<SkImage> withMipmaps(sk_sp<SkMipMap> data) const;
sk_sp<SkImage> withMipmaps(sk_sp<SkMipmap> data) const;
/** Returns SkImage backed by GPU texture associated with context. Returned SkImage is
compatible with SkSurface created with dstColorSpace. The returned SkImage respects

View File

@ -533,7 +533,7 @@ public:
* If numLevels is 1 a non-mipMapped texture will result. If a mipMapped texture is desired
* the data for all the mipmap levels must be provided. In the mipmapped case all the
* colortypes of the provided pixmaps must be the same. Additionally, all the miplevels
* must be sized correctly (please see SkMipMap::ComputeLevelSize and ComputeLevelCount).
* must be sized correctly (please see SkMipmap::ComputeLevelSize and ComputeLevelCount).
* Note: the pixmap's alphatypes and colorspaces are ignored.
* For the Vulkan backend the layout of the created VkImage will be:
* VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
@ -579,7 +579,7 @@ public:
* If the backend texture is mip mapped, the data for all the mipmap levels must be provided.
* In the mipmapped case all the colortypes of the provided pixmaps must be the same.
* Additionally, all the miplevels must be sized correctly (please see
* SkMipMap::ComputeLevelSize and ComputeLevelCount).
* SkMipmap::ComputeLevelSize and ComputeLevelCount).
* Note: the pixmap's alphatypes and colorspaces are ignored.
* For the Vulkan backend after a successful update the layout of the created VkImage will be:
* VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
@ -633,7 +633,7 @@ public:
* The finishedProc will always get called even if we failed to create the GrBackendTexture
* If numLevels is 1 a non-mipMapped texture will result. If a mipMapped texture is desired
* the data for all the mipmap levels must be provided. Additionally, all the miplevels
* must be sized correctly (please see SkMipMap::ComputeLevelSize and ComputeLevelCount).
* must be sized correctly (please see SkMipmap::ComputeLevelSize and ComputeLevelCount).
* For the Vulkan backend the layout of the created VkImage will be:
* VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
*/

View File

@ -23,7 +23,7 @@
#include "src/core/SkConvertPixels.h"
#include "src/core/SkMask.h"
#include "src/core/SkMaskFilterBase.h"
#include "src/core/SkMipMap.h"
#include "src/core/SkMipmap.h"
#include "src/core/SkPixelRefPriv.h"
#include "src/core/SkPixmapPriv.h"
#include "src/core/SkReadBuffer.h"

View File

@ -9,7 +9,7 @@
#include "include/core/SkPixelRef.h"
#include "include/core/SkRect.h"
#include "src/core/SkBitmapCache.h"
#include "src/core/SkMipMap.h"
#include "src/core/SkMipmap.h"
#include "src/core/SkResourceCache.h"
#include "src/image/SkImage_Base.h"
@ -230,7 +230,7 @@ public:
};
struct MipMapRec : public SkResourceCache::Rec {
MipMapRec(const SkBitmapCacheDesc& desc, const SkMipMap* result)
MipMapRec(const SkBitmapCacheDesc& desc, const SkMipmap* result)
: fKey(desc)
, fMipMap(result)
{
@ -250,7 +250,7 @@ struct MipMapRec : public SkResourceCache::Rec {
static bool Finder(const SkResourceCache::Rec& baseRec, void* contextMip) {
const MipMapRec& rec = static_cast<const MipMapRec&>(baseRec);
const SkMipMap* mm = SkRef(rec.fMipMap);
const SkMipmap* mm = SkRef(rec.fMipMap);
// the call to ref() above triggers a "lock" in the case of discardable memory,
// which means we can now check for null (in case the lock failed).
if (nullptr == mm->data()) {
@ -258,20 +258,20 @@ struct MipMapRec : public SkResourceCache::Rec {
return false;
}
// the call must call unref() when they are done.
*(const SkMipMap**)contextMip = mm;
*(const SkMipmap**)contextMip = mm;
return true;
}
private:
MipMapKey fKey;
const SkMipMap* fMipMap;
const SkMipmap* fMipMap;
};
}
const SkMipMap* SkMipMapCache::FindAndRef(const SkBitmapCacheDesc& desc,
const SkMipmap* SkMipmapCache::FindAndRef(const SkBitmapCacheDesc& desc,
SkResourceCache* localCache) {
MipMapKey key(desc);
const SkMipMap* result;
const SkMipmap* result;
if (!CHECK_LOCAL(localCache, find, Find, key, MipMapRec::Finder, &result)) {
result = nullptr;
@ -284,13 +284,13 @@ static SkResourceCache::DiscardableFactory get_fact(SkResourceCache* localCache)
: SkResourceCache::GetDiscardableFactory();
}
const SkMipMap* SkMipMapCache::AddAndRef(const SkImage_Base* image, SkResourceCache* localCache) {
const SkMipmap* SkMipmapCache::AddAndRef(const SkImage_Base* image, SkResourceCache* localCache) {
SkBitmap src;
if (!image->getROPixels(&src)) {
return nullptr;
}
SkMipMap* mipmap = SkMipMap::Build(src, get_fact(localCache));
SkMipmap* mipmap = SkMipmap::Build(src, get_fact(localCache));
if (mipmap) {
MipMapRec* rec = new MipMapRec(SkBitmapCacheDesc::Make(image), mipmap);
CHECK_LOCAL(localCache, add, Add, rec);

View File

@ -15,7 +15,7 @@ class SkBitmap;
class SkImage;
class SkImage_Base;
struct SkImageInfo;
class SkMipMap;
class SkMipmap;
class SkPixmap;
class SkResourceCache;
@ -56,11 +56,11 @@ private:
static void PrivateDeleteRec(Rec*);
};
class SkMipMapCache {
class SkMipmapCache {
public:
static const SkMipMap* FindAndRef(const SkBitmapCacheDesc&,
static const SkMipmap* FindAndRef(const SkBitmapCacheDesc&,
SkResourceCache* localCache = nullptr);
static const SkMipMap* AddAndRef(const SkImage_Base*,
static const SkMipmap* AddAndRef(const SkImage_Base*,
SkResourceCache* localCache = nullptr);
};

View File

@ -12,17 +12,17 @@
#include "src/core/SkBitmapCache.h"
#include "src/core/SkBitmapController.h"
#include "src/core/SkMatrixPriv.h"
#include "src/core/SkMipMap.h"
#include "src/core/SkMipmap.h"
#include "src/image/SkImage_Base.h"
// Try to load from the base image, or from the cache
static sk_sp<const SkMipMap> try_load_mips(const SkImage_Base* image) {
sk_sp<const SkMipMap> mips = image->refMips();
static sk_sp<const SkMipmap> try_load_mips(const SkImage_Base* image) {
sk_sp<const SkMipmap> mips = image->refMips();
if (!mips) {
mips.reset(SkMipMapCache::FindAndRef(SkBitmapCacheDesc::Make(image)));
mips.reset(SkMipmapCache::FindAndRef(SkBitmapCacheDesc::Make(image)));
}
if (!mips) {
mips.reset(SkMipMapCache::AddAndRef(image));
mips.reset(SkMipmapCache::AddAndRef(image));
}
return mips;
}
@ -81,7 +81,7 @@ bool SkBitmapController::State::processMediumRequest(const SkImage_Base* image)
const SkSize scale = SkSize::Make(SkScalarInvert(invScaleSize.width()),
SkScalarInvert(invScaleSize.height()));
SkMipMap::Level level;
SkMipmap::Level level;
if (fCurrMip->extractLevel(scale, &level)) {
const SkSize& invScaleFixup = level.fScale;
fInvMatrix.postScale(invScaleFixup.width(), invScaleFixup.height());
@ -135,7 +135,7 @@ SkMipmapAccessor::SkMipmapAccessor(const SkImage_Base* image, const SkMatrix& in
if (!inv.decomposeScale(&scale, nullptr)) {
fResolvedMode = SkMipmapMode::kNone;
} else {
level = SkMipMap::ComputeLevel({1/scale.width(), 1/scale.height()});
level = SkMipmap::ComputeLevel({1/scale.width(), 1/scale.height()});
if (level <= 0) {
fResolvedMode = SkMipmapMode::kNone;
level = 0;
@ -157,7 +157,7 @@ SkMipmapAccessor::SkMipmapAccessor(const SkImage_Base* image, const SkMatrix& in
load_upper_from_base();
fResolvedMode = SkMipmapMode::kNone;
} else {
SkMipMap::Level levelRec;
SkMipmap::Level levelRec;
SkASSERT(fResolvedMode != SkMipmapMode::kNone);
if (levelNum > 0) {

View File

@ -13,7 +13,7 @@
#include "include/core/SkImage.h"
#include "include/core/SkMatrix.h"
#include "src/core/SkBitmapCache.h"
#include "src/core/SkMipMap.h"
#include "src/core/SkMipmap.h"
class SkImage_Base;
@ -40,7 +40,7 @@ public:
// Pixmap storage.
SkBitmap fResultBitmap;
sk_sp<const SkMipMap> fCurrMip;
sk_sp<const SkMipmap> fCurrMip;
};
@ -70,7 +70,7 @@ private:
// these manage lifetime for the buffers
SkBitmap fBaseStorage;
sk_sp<const SkMipMap> fCurrMip;
sk_sp<const SkMipmap> fCurrMip;
};
#endif

View File

@ -13,7 +13,7 @@
#include "src/core/SkBitmapCache.h"
#include "src/core/SkBitmapController.h"
#include "src/core/SkBitmapProcState.h"
#include "src/core/SkMipMap.h"
#include "src/core/SkMipmap.h"
#include "src/core/SkOpts.h"
#include "src/core/SkResourceCache.h"
#include "src/core/SkUtils.h"

View File

@ -17,7 +17,6 @@
#include "src/core/SkArenaAlloc.h"
#include "src/core/SkBitmapController.h"
#include "src/core/SkMatrixPriv.h"
#include "src/core/SkMipMap.h"
typedef SkFixed3232 SkFractionalInt;
#define SkScalarToFractionalInt(x) SkScalarToFixed3232(x)

View File

@ -11,7 +11,7 @@
#include "include/core/SkData.h"
#include "include/private/SkColorData.h"
#include "src/core/SkMathPriv.h"
#include "src/core/SkMipMap.h"
#include "src/core/SkMipmap.h"
struct ETC1Block {
uint32_t fHigh;
@ -247,7 +247,7 @@ size_t SkCompressedDataSize(SkImage::CompressionType type, SkISize dimensions,
int numMipLevels = 1;
if (mipMapped) {
numMipLevels = SkMipMap::ComputeLevelCount(dimensions.width(), dimensions.height()) + 1;
numMipLevels = SkMipmap::ComputeLevelCount(dimensions.width(), dimensions.height()) + 1;
}
size_t totalSize = 0;

View File

@ -5,8 +5,6 @@
* found in the LICENSE file.
*/
#include "src/core/SkMipMap.h"
#include "include/core/SkBitmap.h"
#include "include/core/SkTypes.h"
#include "include/private/SkColorData.h"
@ -16,6 +14,7 @@
#include "include/private/SkTo.h"
#include "include/private/SkVx.h"
#include "src/core/SkMathPriv.h"
#include "src/core/SkMipmap.h"
#include <new>
//
@ -384,7 +383,7 @@ template <typename F> void downsample_3_3(void* dst, const void* src, size_t src
///////////////////////////////////////////////////////////////////////////////////////////////////
size_t SkMipMap::AllocLevelsSize(int levelCount, size_t pixelSize) {
size_t SkMipmap::AllocLevelsSize(int levelCount, size_t pixelSize) {
if (levelCount < 0) {
return 0;
}
@ -395,7 +394,7 @@ size_t SkMipMap::AllocLevelsSize(int levelCount, size_t pixelSize) {
return SkTo<int32_t>(size);
}
SkMipMap* SkMipMap::Build(const SkPixmap& src, SkDiscardableFactoryProc fact,
SkMipmap* SkMipmap::Build(const SkPixmap& src, SkDiscardableFactoryProc fact,
bool computeContents) {
typedef void FilterProc(void*, const void* srcPtr, size_t srcRB, int count);
@ -556,20 +555,20 @@ SkMipMap* SkMipMap::Build(const SkPixmap& src, SkDiscardableFactoryProc fact,
size += SkColorTypeMinRowBytes(ct, mipSize.fWidth) * mipSize.fHeight;
}
size_t storageSize = SkMipMap::AllocLevelsSize(countLevels, size);
size_t storageSize = SkMipmap::AllocLevelsSize(countLevels, size);
if (0 == storageSize) {
return nullptr;
}
SkMipMap* mipmap;
SkMipmap* mipmap;
if (fact) {
SkDiscardableMemory* dm = fact(storageSize);
if (nullptr == dm) {
return nullptr;
}
mipmap = new SkMipMap(storageSize, dm);
mipmap = new SkMipmap(storageSize, dm);
} else {
mipmap = new SkMipMap(sk_malloc_throw(storageSize), storageSize);
mipmap = new SkMipmap(sk_malloc_throw(storageSize), storageSize);
}
// init
@ -587,7 +586,7 @@ SkMipMap* SkMipMap::Build(const SkPixmap& src, SkDiscardableFactoryProc fact,
SkPixmap srcPM(src);
// Depending on architecture and other factors, the pixel data alignment may need to be as
// large as 8 (for F16 pixels). See the comment on SkMipMap::Level.
// large as 8 (for F16 pixels). See the comment on SkMipmap::Level.
SkASSERT(SkIsAlign8((uintptr_t)addr));
for (int i = 0; i < countLevels; ++i) {
@ -653,7 +652,7 @@ SkMipMap* SkMipMap::Build(const SkPixmap& src, SkDiscardableFactoryProc fact,
return mipmap;
}
int SkMipMap::ComputeLevelCount(int baseWidth, int baseHeight) {
int SkMipmap::ComputeLevelCount(int baseWidth, int baseHeight) {
if (baseWidth < 1 || baseHeight < 1) {
return 0;
}
@ -665,7 +664,7 @@ int SkMipMap::ComputeLevelCount(int baseWidth, int baseHeight) {
const int largestAxis = std::max(baseWidth, baseHeight);
if (largestAxis < 2) {
// SkMipMap::Build requires a minimum size of 2.
// SkMipmap::Build requires a minimum size of 2.
return 0;
}
const int leadingZeros = SkCLZ(static_cast<uint32_t>(largestAxis));
@ -676,9 +675,9 @@ int SkMipMap::ComputeLevelCount(int baseWidth, int baseHeight) {
// and that sizeof(uint32_t)'s implementation-defined behavior is 4.
int mipLevelCount = significantBits;
// SkMipMap does not include the base mip level.
// SkMipmap does not include the base mip level.
// For example, it contains levels 1-x instead of 0-x.
// This is because the image used to create SkMipMap is the base level.
// This is because the image used to create SkMipmap is the base level.
// So subtract 1 from the mip level count.
if (mipLevelCount > 0) {
--mipLevelCount;
@ -687,7 +686,7 @@ int SkMipMap::ComputeLevelCount(int baseWidth, int baseHeight) {
return mipLevelCount;
}
SkISize SkMipMap::ComputeLevelSize(int baseWidth, int baseHeight, int level) {
SkISize SkMipmap::ComputeLevelSize(int baseWidth, int baseHeight, int level) {
if (baseWidth < 1 || baseHeight < 1) {
return SkISize::Make(0, 0);
}
@ -700,10 +699,10 @@ SkISize SkMipMap::ComputeLevelSize(int baseWidth, int baseHeight, int level) {
// max(1, floor(original_height / 2^i)
// (or original_width) where i is the mipmap level.
// SkMipMap does not include the base mip level.
// SkMipmap does not include the base mip level.
// For example, it contains levels 1-x instead of 0-x.
// This is because the image used to create SkMipMap is the base level.
// So subtract 1 from the mip level to get the index stored by SkMipMap.
// This is because the image used to create SkMipmap is the base level.
// So subtract 1 from the mip level to get the index stored by SkMipmap.
int width = std::max(1, baseWidth >> (level + 1));
int height = std::max(1, baseHeight >> (level + 1));
@ -714,7 +713,7 @@ SkISize SkMipMap::ComputeLevelSize(int baseWidth, int baseHeight, int level) {
// Returns fractional level value. floor(level) is the index of the larger level.
// < 0 means failure.
float SkMipMap::ComputeLevel(SkSize scaleSize) {
float SkMipmap::ComputeLevel(SkSize scaleSize) {
SkASSERT(scaleSize.width() >= 0 && scaleSize.height() >= 0);
#ifndef SK_SUPPORT_LEGACY_ANISOTROPIC_MIPMAP_SCALE
@ -739,7 +738,7 @@ float SkMipMap::ComputeLevel(SkSize scaleSize) {
return L;
}
bool SkMipMap::extractLevel(SkSize scaleSize, Level* levelPtr) const {
bool SkMipmap::extractLevel(SkSize scaleSize, Level* levelPtr) const {
if (nullptr == fLevels) {
return false;
}
@ -763,7 +762,7 @@ bool SkMipMap::extractLevel(SkSize scaleSize, Level* levelPtr) const {
// Helper which extracts a pixmap from the src bitmap
//
SkMipMap* SkMipMap::Build(const SkBitmap& src, SkDiscardableFactoryProc fact) {
SkMipmap* SkMipmap::Build(const SkBitmap& src, SkDiscardableFactoryProc fact) {
SkPixmap srcPixmap;
if (!src.peekPixels(&srcPixmap)) {
return nullptr;
@ -771,11 +770,11 @@ SkMipMap* SkMipMap::Build(const SkBitmap& src, SkDiscardableFactoryProc fact) {
return Build(srcPixmap, fact);
}
int SkMipMap::countLevels() const {
int SkMipmap::countLevels() const {
return fCount;
}
bool SkMipMap::getLevel(int index, Level* levelPtr) const {
bool SkMipmap::getLevel(int index, Level* levelPtr) const {
if (nullptr == fLevels) {
return false;
}

View File

@ -5,8 +5,8 @@
* found in the LICENSE file.
*/
#ifndef SkMipMap_DEFINED
#define SkMipMap_DEFINED
#ifndef SkMipmap_DEFINED
#define SkMipmap_DEFINED
#include "include/core/SkPixmap.h"
#include "include/core/SkScalar.h"
@ -21,24 +21,24 @@ class SkDiscardableMemory;
typedef SkDiscardableMemory* (*SkDiscardableFactoryProc)(size_t bytes);
/*
* SkMipMap will generate mipmap levels when given a base mipmap level image.
* SkMipmap will generate mipmap levels when given a base mipmap level image.
*
* Any function which deals with mipmap levels indices will start with index 0
* being the first mipmap level which was generated. Said another way, it does
* not include the base level in its range.
*/
class SkMipMap : public SkCachedData {
class SkMipmap : public SkCachedData {
public:
// Allocate and fill-in a mipmap. If computeContents is false, we just allocated
// and compute the sizes/rowbytes, but leave the pixel-data uninitialized.
static SkMipMap* Build(const SkPixmap& src, SkDiscardableFactoryProc,
static SkMipmap* Build(const SkPixmap& src, SkDiscardableFactoryProc,
bool computeContents = true);
static SkMipMap* Build(const SkBitmap& src, SkDiscardableFactoryProc);
static SkMipmap* Build(const SkBitmap& src, SkDiscardableFactoryProc);
// Determines how many levels a SkMipMap will have without creating that mipmap.
// Determines how many levels a SkMipmap will have without creating that mipmap.
// This does not include the base mipmap level that the user provided when
// creating the SkMipMap.
// creating the SkMipmap.
static int ComputeLevelCount(int baseWidth, int baseHeight);
static int ComputeLevelCount(SkISize s) { return ComputeLevelCount(s.width(), s.height()); }
@ -79,8 +79,8 @@ private:
Level* fLevels; // managed by the baseclass, may be null due to onDataChanged.
int fCount;
SkMipMap(void* malloc, size_t size) : INHERITED(malloc, size) {}
SkMipMap(size_t size, SkDiscardableMemory* dm) : INHERITED(size, dm) {}
SkMipmap(void* malloc, size_t size) : INHERITED(malloc, size) {}
SkMipmap(size_t size, SkDiscardableMemory* dm) : INHERITED(size, dm) {}
static size_t AllocLevelsSize(int levelCount, size_t pixelSize);

View File

@ -13,7 +13,7 @@
#include "src/core/SkDiscardableMemory.h"
#include "src/core/SkImageFilter_Base.h"
#include "src/core/SkMessageBus.h"
#include "src/core/SkMipMap.h"
#include "src/core/SkMipmap.h"
#include "src/core/SkOpts.h"
#include <stddef.h>

View File

@ -11,7 +11,7 @@
#include "include/core/SkTraceMemoryDump.h"
#include "include/gpu/GrBackendSemaphore.h"
#include "include/private/SkImageInfoPriv.h"
#include "src/core/SkMipMap.h"
#include "src/core/SkMipmap.h"
#include "src/core/SkTaskGroup.h"
#include "src/gpu/GrClientMappedBufferManager.h"
#include "src/gpu/GrContextPriv.h"
@ -621,7 +621,7 @@ GrBackendTexture GrContext::createBackendTexture(const SkPixmap srcData[], int n
GrMipMapped mipMapped = GrMipMapped::kNo;
int numExpectedLevels = 1;
if (numProvidedLevels > 1) {
numExpectedLevels = SkMipMap::ComputeLevelCount(baseWidth, baseHeight) + 1;
numExpectedLevels = SkMipmap::ComputeLevelCount(baseWidth, baseHeight) + 1;
mipMapped = GrMipMapped::kYes;
}
@ -682,7 +682,7 @@ bool GrContext::updateBackendTexture(const GrBackendTexture& backendTexture,
int numExpectedLevels = 1;
if (backendTexture.hasMipMaps()) {
numExpectedLevels = SkMipMap::ComputeLevelCount(backendTexture.width(),
numExpectedLevels = SkMipmap::ComputeLevelCount(backendTexture.width(),
backendTexture.height()) + 1;
}
if (numLevels != numExpectedLevels) {

View File

@ -11,7 +11,7 @@
#include "src/core/SkColorSpaceXformSteps.h"
#include "src/core/SkCompressedDataUtils.h"
#include "src/core/SkConvertPixels.h"
#include "src/core/SkMipMap.h"
#include "src/core/SkMipmap.h"
#include "src/core/SkTLazy.h"
#include "src/core/SkTraceEvent.h"
#include "src/core/SkUtils.h"
@ -301,7 +301,7 @@ void GrFillInCompressedData(SkImage::CompressionType type, SkISize dimensions,
int numMipLevels = 1;
if (mipMapped == GrMipMapped::kYes) {
numMipLevels = SkMipMap::ComputeLevelCount(dimensions.width(), dimensions.height()) + 1;
numMipLevels = SkMipmap::ComputeLevelCount(dimensions.width(), dimensions.height()) + 1;
}
size_t offset = 0;

View File

@ -13,7 +13,7 @@
#include "include/gpu/GrDirectContext.h"
#include "src/core/SkCompressedDataUtils.h"
#include "src/core/SkMathPriv.h"
#include "src/core/SkMipMap.h"
#include "src/core/SkMipmap.h"
#include "src/gpu/GrAuditTrail.h"
#include "src/gpu/GrBackendUtils.h"
#include "src/gpu/GrCaps.h"
@ -813,7 +813,7 @@ bool GrGpu::MipMapsAreCorrect(SkISize dimensions,
const BackendTextureData* data) {
int numMipLevels = 1;
if (mipMapped == GrMipMapped::kYes) {
numMipLevels = SkMipMap::ComputeLevelCount(dimensions.width(), dimensions.height()) + 1;
numMipLevels = SkMipmap::ComputeLevelCount(dimensions.width(), dimensions.height()) + 1;
}
if (!data || data->type() == BackendTextureData::Type::kColor) {

View File

@ -17,7 +17,7 @@
#include "src/core/SkAutoPixmapStorage.h"
#include "src/core/SkCompressedDataUtils.h"
#include "src/core/SkImagePriv.h"
#include "src/core/SkMipMap.h"
#include "src/core/SkMipmap.h"
#include "src/core/SkTraceEvent.h"
#include "src/gpu/GrCaps.h"
#include "src/gpu/GrContextPriv.h"
@ -286,7 +286,7 @@ sk_sp<GrTextureProxy> GrProxyProvider::createProxyFromBitmap(const SkBitmap& bit
sk_sp<GrTextureProxy> proxy;
if (mipMapped == GrMipMapped::kNo ||
0 == SkMipMap::ComputeLevelCount(copyBitmap.width(), copyBitmap.height())) {
0 == SkMipmap::ComputeLevelCount(copyBitmap.width(), copyBitmap.height())) {
proxy = this->createNonMippedProxyFromBitmap(copyBitmap, fit, budgeted);
} else {
proxy = this->createMippedProxyFromBitmap(copyBitmap, budgeted);
@ -349,7 +349,7 @@ sk_sp<GrTextureProxy> GrProxyProvider::createMippedProxyFromBitmap(const SkBitma
return nullptr;
}
sk_sp<SkMipMap> mipmaps(SkMipMap::Build(bitmap.pixmap(), nullptr));
sk_sp<SkMipmap> mipmaps(SkMipmap::Build(bitmap.pixmap(), nullptr));
if (!mipmaps) {
return nullptr;
}
@ -366,7 +366,7 @@ sk_sp<GrTextureProxy> GrProxyProvider::createMippedProxyFromBitmap(const SkBitma
texels[0].fRowBytes = bitmap.rowBytes();
for (int i = 1; i < mipLevelCount; ++i) {
SkMipMap::Level generatedMipLevel;
SkMipmap::Level generatedMipLevel;
mipmaps->getLevel(i - 1, &generatedMipLevel);
texels[i].fPixels = generatedMipLevel.fPixmap.addr();
texels[i].fRowBytes = generatedMipLevel.fPixmap.rowBytes();
@ -413,8 +413,8 @@ sk_sp<GrTextureProxy> GrProxyProvider::createProxy(const GrBackendFormat& format
}
if (GrMipMapped::kYes == mipMapped) {
// SkMipMap doesn't include the base level in the level count so we have to add 1
int mipCount = SkMipMap::ComputeLevelCount(dimensions.fWidth, dimensions.fHeight) + 1;
// SkMipmap doesn't include the base level in the level count so we have to add 1
int mipCount = SkMipmap::ComputeLevelCount(dimensions.fWidth, dimensions.fHeight) + 1;
if (1 == mipCount) {
mipMapped = GrMipMapped::kNo;
}

View File

@ -11,7 +11,7 @@
#include "include/gpu/GrContext.h"
#include "include/gpu/GrRecordingContext.h"
#include "src/core/SkMathPriv.h"
#include "src/core/SkMipMap.h"
#include "src/core/SkMipmap.h"
#include "src/gpu/GrCaps.h"
#include "src/gpu/GrClip.h"
#include "src/gpu/GrContextPriv.h"

View File

@ -10,7 +10,7 @@
#include "include/gpu/GrContext.h"
#include "include/gpu/GrTypes.h"
#include "include/private/GrResourceKey.h"
#include "src/core/SkMipMap.h"
#include "src/core/SkMipmap.h"
#include "src/gpu/GrCaps.h"
#include "src/gpu/GrContextPriv.h"
#include "src/gpu/GrGpu.h"
@ -48,7 +48,7 @@ GrTexture::GrTexture(GrGpu* gpu,
if (GrMipMapsStatus::kNotAllocated == fMipMapsStatus) {
fMaxMipMapLevel = 0;
} else {
fMaxMipMapLevel = SkMipMap::ComputeLevelCount(this->width(), this->height());
fMaxMipMapLevel = SkMipmap::ComputeLevelCount(this->width(), this->height());
}
}

View File

@ -8,7 +8,7 @@
#include "src/gpu/GrTextureProducer.h"
#include "include/gpu/GrRecordingContext.h"
#include "src/core/SkMipMap.h"
#include "src/core/SkMipmap.h"
#include "src/core/SkRectPriv.h"
#include "src/gpu/GrClip.h"
#include "src/gpu/GrContextPriv.h"

View File

@ -25,7 +25,7 @@
#include "src/core/SkImagePriv.h"
#include "src/core/SkMaskFilterBase.h"
#include "src/core/SkMessageBus.h"
#include "src/core/SkMipMap.h"
#include "src/core/SkMipmap.h"
#include "src/core/SkPaintPriv.h"
#include "src/core/SkResourceCache.h"
#include "src/core/SkTraceEvent.h"

View File

@ -10,7 +10,7 @@
#include "include/gpu/GrBackendSurface.h"
#include "include/gpu/d3d/GrD3DBackendContext.h"
#include "src/core/SkConvertPixels.h"
#include "src/core/SkMipMap.h"
#include "src/core/SkMipmap.h"
#include "src/gpu/GrBackendUtils.h"
#include "src/gpu/GrDataUtils.h"
#include "src/gpu/GrTexturePriv.h"
@ -321,7 +321,7 @@ sk_sp<GrTexture> GrD3DGpu::onCreateCompressedTexture(SkISize dimensions,
int mipLevelCount = 1;
if (mipMapped == GrMipMapped::kYes) {
mipLevelCount = SkMipMap::ComputeLevelCount(dimensions.width(), dimensions.height()) + 1;
mipLevelCount = SkMipmap::ComputeLevelCount(dimensions.width(), dimensions.height()) + 1;
}
GrMipMapsStatus mipMapsStatus = mipLevelCount > 1 ? GrMipMapsStatus::kValid
: GrMipMapsStatus::kNotAllocated;
@ -924,7 +924,7 @@ bool GrD3DGpu::createTextureResourceForBackendSurface(DXGI_FORMAT dxgiFormat,
int numMipLevels = 1;
if (mipMapped == GrMipMapped::kYes) {
numMipLevels = SkMipMap::ComputeLevelCount(dimensions.width(), dimensions.height()) + 1;
numMipLevels = SkMipmap::ComputeLevelCount(dimensions.width(), dimensions.height()) + 1;
}
// create the texture
@ -1068,7 +1068,7 @@ bool GrD3DGpu::onUpdateBackendTexture(const GrBackendTexture& backendTexture,
D3D12_RESOURCE_DESC desc = d3dResource->GetDesc();
unsigned int mipLevelCount = 1;
if (backendTexture.fMipMapped == GrMipMapped::kYes) {
mipLevelCount = SkMipMap::ComputeLevelCount(backendTexture.dimensions().width(),
mipLevelCount = SkMipmap::ComputeLevelCount(backendTexture.dimensions().width(),
backendTexture.dimensions().height()) + 1;
}
SkASSERT(mipLevelCount == info.fLevelCount);

View File

@ -30,7 +30,7 @@
#include "src/gpu/dawn/GrDawnUtil.h"
#include "src/core/SkAutoMalloc.h"
#include "src/core/SkMipMap.h"
#include "src/core/SkMipmap.h"
#include "src/sksl/SkSLCompiler.h"
#if !defined(SK_BUILD_FOR_WIN)
@ -327,7 +327,7 @@ GrBackendTexture GrDawnGpu::onCreateBackendTexture(SkISize dimensions,
int numMipLevels = 1;
if (mipMapped == GrMipMapped::kYes) {
numMipLevels = SkMipMap::ComputeLevelCount(dimensions.width(), dimensions.height()) + 1;
numMipLevels = SkMipmap::ComputeLevelCount(dimensions.width(), dimensions.height()) + 1;
}
desc.size.width = dimensions.width();

View File

@ -18,7 +18,7 @@
#include "src/core/SkAutoMalloc.h"
#include "src/core/SkCompressedDataUtils.h"
#include "src/core/SkConvertPixels.h"
#include "src/core/SkMipMap.h"
#include "src/core/SkMipmap.h"
#include "src/core/SkTraceEvent.h"
#include "src/gpu/GrBackendUtils.h"
#include "src/gpu/GrContextPriv.h"
@ -980,7 +980,7 @@ bool GrGLGpu::uploadColorToTex(GrGLFormat textureFormat,
std::unique_ptr<char[]> pixelStorage;
size_t bpp = 0;
int numLevels = SkMipMap::ComputeLevelCount(texDims) + 1;
int numLevels = SkMipmap::ComputeLevelCount(texDims) + 1;
SkSTArray<16, GrMipLevel> levels;
levels.resize(numLevels);
SkISize levelDims = texDims;
@ -1016,7 +1016,7 @@ void GrGLGpu::uploadTexData(SkISize texDims,
SkASSERT(!texDims.isEmpty());
SkASSERT(!dstRect.isEmpty());
SkASSERT(SkIRect::MakeSize(texDims).contains(dstRect));
SkASSERT(mipLevelCount > 0 && mipLevelCount <= SkMipMap::ComputeLevelCount(texDims) + 1);
SkASSERT(mipLevelCount > 0 && mipLevelCount <= SkMipmap::ComputeLevelCount(texDims) + 1);
SkASSERT(mipLevelCount == 1 || dstRect == SkIRect::MakeSize(texDims));
const GrGLCaps& caps = this->glCaps();
@ -1073,7 +1073,7 @@ bool GrGLGpu::uploadCompressedTexData(SkImage::CompressionType compressionType,
int numMipLevels = 1;
if (mipMapped == GrMipMapped::kYes) {
numMipLevels = SkMipMap::ComputeLevelCount(dimensions.width(), dimensions.height())+1;
numMipLevels = SkMipmap::ComputeLevelCount(dimensions.width(), dimensions.height())+1;
}
// TODO: Make sure that the width and height that we pass to OpenGL
@ -3422,7 +3422,7 @@ bool GrGLGpu::onRegenerateMipMapLevels(GrTexture* texture) {
int width = texture->width();
int height = texture->height();
int levelCount = SkMipMap::ComputeLevelCount(width, height) + 1;
int levelCount = SkMipmap::ComputeLevelCount(width, height) + 1;
SkASSERT(levelCount == texture->texturePriv().maxMipMapLevel() + 1);
// Create (if necessary), then bind temporary FBO:
@ -3580,7 +3580,7 @@ GrBackendTexture GrGLGpu::onCreateBackendTexture(SkISize dimensions,
int numMipLevels = 1;
if (mipMapped == GrMipMapped::kYes) {
numMipLevels = SkMipMap::ComputeLevelCount(dimensions.width(), dimensions.height()) + 1;
numMipLevels = SkMipmap::ComputeLevelCount(dimensions.width(), dimensions.height()) + 1;
}
// Compressed formats go through onCreateCompressedBackendTexture
@ -3634,7 +3634,7 @@ bool GrGLGpu::onUpdateBackendTexture(const GrBackendTexture& backendTexture,
int numMipLevels = 1;
if (backendTexture.hasMipMaps()) {
numMipLevels =
SkMipMap::ComputeLevelCount(backendTexture.width(), backendTexture.height()) + 1;
SkMipmap::ComputeLevelCount(backendTexture.width(), backendTexture.height()) + 1;
}
GrGLFormat glFormat = GrGLFormatFromGLEnum(info.fFormat);

View File

@ -10,7 +10,7 @@
#include "include/private/GrTypesPriv.h"
#include "src/core/SkCompressedDataUtils.h"
#include "src/core/SkConvertPixels.h"
#include "src/core/SkMipMap.h"
#include "src/core/SkMipmap.h"
#include "src/gpu/GrBackendUtils.h"
#include "src/gpu/GrDataUtils.h"
#include "src/gpu/GrRenderTargetPriv.h"
@ -511,7 +511,7 @@ sk_sp<GrTexture> GrMtlGpu::onCreateCompressedTexture(SkISize dimensions,
int numMipLevels = 1;
if (mipMapped == GrMipMapped::kYes) {
numMipLevels = SkMipMap::ComputeLevelCount(dimensions.width(), dimensions.height()) + 1;
numMipLevels = SkMipmap::ComputeLevelCount(dimensions.width(), dimensions.height()) + 1;
}
// This TexDesc refers to the texture that will be read by the client. Thus even if msaa is

View File

@ -14,7 +14,7 @@
#include "include/private/SkTo.h"
#include "src/core/SkCompressedDataUtils.h"
#include "src/core/SkConvertPixels.h"
#include "src/core/SkMipMap.h"
#include "src/core/SkMipmap.h"
#include "src/gpu/GrBackendUtils.h"
#include "src/gpu/GrContextPriv.h"
#include "src/gpu/GrDataUtils.h"
@ -719,7 +719,7 @@ static size_t fill_in_regions(GrVkCaps* vkCaps, SkTArray<VkBufferImageCopy>* reg
VkDeviceSize bufferOffset) {
int numMipLevels = 1;
if (mipMapped == GrMipMapped::kYes) {
numMipLevels = SkMipMap::ComputeLevelCount(dimensions.width(), dimensions.height()) + 1;
numMipLevels = SkMipmap::ComputeLevelCount(dimensions.width(), dimensions.height()) + 1;
}
regions->reserve(numMipLevels);
@ -1124,7 +1124,7 @@ sk_sp<GrTexture> GrVkGpu::onCreateCompressedTexture(SkISize dimensions,
int numMipLevels = 1;
if (mipMapped == GrMipMapped::kYes) {
numMipLevels = SkMipMap::ComputeLevelCount(dimensions.width(), dimensions.height())+1;
numMipLevels = SkMipmap::ComputeLevelCount(dimensions.width(), dimensions.height())+1;
}
// Compressed textures with MIP levels or multiple samples are not supported as of now.
@ -1433,8 +1433,8 @@ bool GrVkGpu::onRegenerateMipMapLevels(GrTexture* tex) {
VkImageBlit blitRegion;
memset(&blitRegion, 0, sizeof(VkImageBlit));
// SkMipMap doesn't include the base level in the level count so we have to add 1
uint32_t levelCount = SkMipMap::ComputeLevelCount(tex->width(), tex->height()) + 1;
// SkMipmap doesn't include the base level in the level count so we have to add 1
uint32_t levelCount = SkMipmap::ComputeLevelCount(tex->width(), tex->height()) + 1;
SkASSERT(levelCount == vkTex->mipLevels());
// change layout of the layers so we can write to them.
@ -1579,7 +1579,7 @@ bool GrVkGpu::createVkImageForBackendSurface(VkFormat vkFormat,
int numMipLevels = 1;
if (mipMapped == GrMipMapped::kYes) {
numMipLevels = SkMipMap::ComputeLevelCount(dimensions.width(), dimensions.height()) + 1;
numMipLevels = SkMipmap::ComputeLevelCount(dimensions.width(), dimensions.height()) + 1;
}
VkImageUsageFlags usageFlags = 0;

View File

@ -6,7 +6,7 @@
*/
#include "include/gpu/GrContext.h"
#include "src/core/SkMipMap.h"
#include "src/core/SkMipmap.h"
#include "src/gpu/GrContextPriv.h"
#include "src/gpu/GrPipeline.h"
#include "src/gpu/GrRenderTarget.h"

View File

@ -12,7 +12,7 @@
#include "src/gpu/vk/GrVkImageView.h"
#include "src/gpu/vk/GrVkUtil.h"
#include "src/core/SkMipMap.h"
#include "src/core/SkMipmap.h"
#include "include/gpu/vk/GrVkTypes.h"

View File

@ -20,7 +20,7 @@
#include "src/core/SkImageFilterCache.h"
#include "src/core/SkImageFilter_Base.h"
#include "src/core/SkImagePriv.h"
#include "src/core/SkMipMap.h"
#include "src/core/SkMipmap.h"
#include "src/core/SkNextID.h"
#include "src/core/SkSpecialImage.h"
#include "src/image/SkImage_Base.h"
@ -654,7 +654,7 @@ SkIRect SkImage_getSubset(const SkImage* image) {
///////////////////////////////////////////////////////////////////////////////////////////////////
SkMipmapBuilder::SkMipmapBuilder(const SkImageInfo& info) {
fMM = sk_sp<SkMipMap>(SkMipMap::Build({info, nullptr, 0}, nullptr, false));
fMM = sk_sp<SkMipmap>(SkMipmap::Build({info, nullptr, 0}, nullptr, false));
}
SkMipmapBuilder::~SkMipmapBuilder() {}
@ -666,14 +666,14 @@ int SkMipmapBuilder::countLevels() const {
SkPixmap SkMipmapBuilder::level(int index) const {
SkPixmap pm;
SkMipMap::Level level;
SkMipmap::Level level;
if (fMM && fMM->getLevel(index, &level)) {
pm = level.fPixmap;
}
return pm;
}
sk_sp<SkMipMap> SkMipmapBuilder::detach() {
sk_sp<SkMipmap> SkMipmapBuilder::detach() {
return std::move(fMM);
}
@ -681,7 +681,7 @@ bool SkImage::hasMipmaps() const {
return as_IB(this)->onPeekMips() != nullptr;
}
sk_sp<SkImage> SkImage::withMipmaps(sk_sp<SkMipMap> data) const {
sk_sp<SkImage> SkImage::withMipmaps(sk_sp<SkMipmap> data) const {
auto result = as_IB(this)->onMakeWithMipmaps(std::move(data));
if (!result) {
result = sk_ref_sp((const_cast<SkImage*>(this)));

View File

@ -10,7 +10,7 @@
#include "include/core/SkImage.h"
#include "include/core/SkSurface.h"
#include "src/core/SkMipMap.h"
#include "src/core/SkMipmap.h"
#include <atomic>
#if SK_SUPPORT_GPU
@ -47,9 +47,9 @@ public:
virtual bool onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes,
int srcX, int srcY, CachingHint) const = 0;
virtual SkMipMap* onPeekMips() const { return nullptr; }
virtual SkMipmap* onPeekMips() const { return nullptr; }
sk_sp<SkMipMap> refMips() const {
sk_sp<SkMipmap> refMips() const {
return sk_ref_sp(this->onPeekMips());
}
@ -136,7 +136,7 @@ public:
virtual sk_sp<SkImage> onReinterpretColorSpace(sk_sp<SkColorSpace>) const = 0;
// on failure, returns nullptr
virtual sk_sp<SkImage> onMakeWithMipmaps(sk_sp<SkMipMap>) const {
virtual sk_sp<SkImage> onMakeWithMipmaps(sk_sp<SkMipmap>) const {
return nullptr;
}

View File

@ -16,7 +16,7 @@
#include "include/private/SkImageInfoPriv.h"
#include "src/core/SkAutoPixmapStorage.h"
#include "src/core/SkBitmapCache.h"
#include "src/core/SkMipMap.h"
#include "src/core/SkMipmap.h"
#include "src/core/SkScopeExit.h"
#include "src/core/SkTraceEvent.h"
#include "src/gpu/GrAHardwareBufferImageGenerator.h"

View File

@ -13,7 +13,7 @@
#include "include/gpu/GrContext.h"
#include "include/gpu/GrRecordingContext.h"
#include "src/core/SkAutoPixmapStorage.h"
#include "src/core/SkMipMap.h"
#include "src/core/SkMipmap.h"
#include "src/core/SkScopeExit.h"
#include "src/gpu/GrBitmapTextureMaker.h"
#include "src/gpu/GrClip.h"

View File

@ -123,14 +123,14 @@ public:
void onUnpinAsTexture(GrContext*) const override;
#endif
SkMipMap* onPeekMips() const override { return fBitmap.fMips.get(); }
SkMipmap* onPeekMips() const override { return fBitmap.fMips.get(); }
sk_sp<SkImage> onMakeWithMipmaps(sk_sp<SkMipMap> mips) const override {
sk_sp<SkImage> onMakeWithMipmaps(sk_sp<SkMipmap> mips) const override {
auto img = new SkImage_Raster(fBitmap);
if (mips) {
img->fBitmap.fMips = std::move(mips);
} else {
img->fBitmap.fMips.reset(SkMipMap::Build(fBitmap.pixmap(), nullptr));
img->fBitmap.fMips.reset(SkMipmap::Build(fBitmap.pixmap(), nullptr));
}
return sk_sp<SkImage>(img);
}

View File

@ -9,7 +9,7 @@
#include "include/gpu/GrDirectContext.h"
#include "src/core/SkAutoPixmapStorage.h"
#include "src/core/SkCompressedDataUtils.h"
#include "src/core/SkMipMap.h"
#include "src/core/SkMipmap.h"
#include "src/gpu/GrBackendUtils.h"
#include "src/gpu/GrContextPriv.h"
#include "src/image/SkImage_Base.h"
@ -77,7 +77,7 @@ static void check_compressed_mipmaps(GrContext* context, sk_sp<SkImage> img,
int numMipLevels = 1;
if (mipMapped == GrMipMapped::kYes) {
numMipLevels = SkMipMap::ComputeLevelCount(32, 32)+1;
numMipLevels = SkMipmap::ComputeLevelCount(32, 32)+1;
}
for (int i = 0, rectSize = 32; i < numMipLevels; ++i, rectSize /= 2) {
@ -171,7 +171,7 @@ static std::unique_ptr<const char[]> make_compressed_data(SkImage::CompressionTy
int numMipLevels = 1;
if (mipMapped == GrMipMapped::kYes) {
numMipLevels = SkMipMap::ComputeLevelCount(dimensions.width(), dimensions.height()) + 1;
numMipLevels = SkMipmap::ComputeLevelCount(dimensions.width(), dimensions.height()) + 1;
}
SkTArray<size_t> mipMapOffsets(numMipLevels);

View File

@ -7,7 +7,7 @@
#include "include/core/SkBitmap.h"
#include "include/utils/SkRandom.h"
#include "src/core/SkMipMap.h"
#include "src/core/SkMipmap.h"
#include "tests/Test.h"
#include "tools/Resources.h"
@ -24,22 +24,22 @@ DEF_TEST(MipMap, reporter) {
int width = 1 + rand.nextU() % 1000;
int height = 1 + rand.nextU() % 1000;
make_bitmap(&bm, width, height);
sk_sp<SkMipMap> mm(SkMipMap::Build(bm, nullptr));
sk_sp<SkMipmap> mm(SkMipmap::Build(bm, nullptr));
REPORTER_ASSERT(reporter, mm->countLevels() == SkMipMap::ComputeLevelCount(width, height));
REPORTER_ASSERT(reporter, mm->countLevels() == SkMipmap::ComputeLevelCount(width, height));
REPORTER_ASSERT(reporter, !mm->extractLevel(SkSize::Make(SK_Scalar1, SK_Scalar1),
nullptr));
REPORTER_ASSERT(reporter, !mm->extractLevel(SkSize::Make(SK_Scalar1 * 2, SK_Scalar1 * 2),
nullptr));
SkMipMap::Level prevLevel;
SkMipmap::Level prevLevel;
sk_bzero(&prevLevel, sizeof(prevLevel));
SkScalar scale = SK_Scalar1;
for (int j = 0; j < 30; ++j) {
scale = scale * 2 / 3;
SkMipMap::Level level;
SkMipmap::Level level;
if (mm->extractLevel(SkSize::Make(scale, scale), &level)) {
REPORTER_ASSERT(reporter, level.fPixmap.addr());
REPORTER_ASSERT(reporter, level.fPixmap.width() > 0);
@ -61,21 +61,21 @@ static void test_mipmap_generation(int width, int height, int expectedMipLevelCo
SkBitmap bm;
bm.allocN32Pixels(width, height);
bm.eraseColor(SK_ColorWHITE);
sk_sp<SkMipMap> mm(SkMipMap::Build(bm, nullptr));
sk_sp<SkMipmap> mm(SkMipmap::Build(bm, nullptr));
const int mipLevelCount = mm->countLevels();
REPORTER_ASSERT(reporter, mipLevelCount == expectedMipLevelCount);
REPORTER_ASSERT(reporter, mipLevelCount == SkMipMap::ComputeLevelCount(width, height));
REPORTER_ASSERT(reporter, mipLevelCount == SkMipmap::ComputeLevelCount(width, height));
for (int i = 0; i < mipLevelCount; ++i) {
SkMipMap::Level level;
SkMipmap::Level level;
REPORTER_ASSERT(reporter, mm->getLevel(i, &level));
// Make sure the mipmaps contain valid data and that the sizes are correct
REPORTER_ASSERT(reporter, level.fPixmap.addr());
SkISize size = SkMipMap::ComputeLevelSize(width, height, i);
SkISize size = SkMipmap::ComputeLevelSize(width, height, i);
REPORTER_ASSERT(reporter, level.fPixmap.width() == size.width());
REPORTER_ASSERT(reporter, level.fPixmap.height() == size.height());
// + 1 because SkMipMap does not include the base mipmap level.
// + 1 because SkMipmap does not include the base mipmap level.
int twoToTheMipLevel = 1 << (i + 1);
int currentWidth = width / twoToTheMipLevel;
int currentHeight = height / twoToTheMipLevel;
@ -87,11 +87,11 @@ static void test_mipmap_generation(int width, int height, int expectedMipLevelCo
DEF_TEST(MipMap_DirectLevelAccess, reporter) {
// create mipmap with invalid size
{
// SkMipMap current requires the dimensions be greater than 2x2
// SkMipmap current requires the dimensions be greater than 2x2
SkBitmap bm;
bm.allocN32Pixels(1, 1);
bm.eraseColor(SK_ColorWHITE);
sk_sp<SkMipMap> mm(SkMipMap::Build(bm, nullptr));
sk_sp<SkMipmap> mm(SkMipmap::Build(bm, nullptr));
REPORTER_ASSERT(reporter, mm == nullptr);
}
@ -121,7 +121,7 @@ DEF_TEST(MipMap_ComputeLevelCount, reporter) {
{-100, -100, 0},
// Test mipmaps with 0, 1, 2 as dimensions
// (SkMipMap::Build requires a min size of 1)
// (SkMipmap::Build requires a min size of 1)
//
// 0
{0, 100, 0},
@ -151,7 +151,7 @@ DEF_TEST(MipMap_ComputeLevelCount, reporter) {
};
for (auto& currentTest : tests) {
int levelCount = SkMipMap::ComputeLevelCount(currentTest.fWidth, currentTest.fHeight);
int levelCount = SkMipmap::ComputeLevelCount(currentTest.fWidth, currentTest.fHeight);
REPORTER_ASSERT(reporter, currentTest.fExpectedLevelCount == levelCount);
}
}
@ -171,7 +171,7 @@ DEF_TEST(MipMap_ComputeLevelSize, reporter) {
{-100, -100, 0, SkISize::Make(0, 0)},
// Test mipmaps with 0, 1, 2 as dimensions
// (SkMipMap::Build requires a min size of 1)
// (SkMipmap::Build requires a min size of 1)
//
// 0
{0, 100, 0, SkISize::Make(0, 0)},
@ -197,7 +197,7 @@ DEF_TEST(MipMap_ComputeLevelSize, reporter) {
};
for (auto& currentTest : tests) {
SkISize levelSize = SkMipMap::ComputeLevelSize(currentTest.fBaseWidth,
SkISize levelSize = SkMipmap::ComputeLevelSize(currentTest.fBaseWidth,
currentTest.fBaseHeight,
currentTest.fLevel);
REPORTER_ASSERT(reporter, currentTest.fExpectedMipMapLevelSize == levelSize);
@ -208,7 +208,7 @@ DEF_TEST(MipMap_F16, reporter) {
SkBitmap bmp;
bmp.allocPixels(SkImageInfo::Make(10, 10, kRGBA_F16_SkColorType, kPremul_SkAlphaType));
bmp.eraseColor(0);
sk_sp<SkMipMap> mipmap(SkMipMap::Build(bmp, nullptr));
sk_sp<SkMipmap> mipmap(SkMipmap::Build(bmp, nullptr));
}
#include "include/core/SkCanvas.h"

View File

@ -22,7 +22,7 @@
#include "include/core/SkCanvas.h"
#include "include/core/SkSurface.h"
#include "src/core/SkMessageBus.h"
#include "src/core/SkMipMap.h"
#include "src/core/SkMipmap.h"
#include "src/gpu/SkGr.h"
#include "tests/Test.h"
#include "tests/TestUtils.h"

View File

@ -11,7 +11,7 @@
#include "include/core/SkPictureRecorder.h"
#include "include/core/SkSurface.h"
#include "src/core/SkBitmapCache.h"
#include "src/core/SkMipMap.h"
#include "src/core/SkMipmap.h"
#include "src/core/SkResourceCache.h"
#include "src/image/SkImage_Base.h"
#include "src/lazy/SkDiscardableMemoryPool.h"
@ -46,14 +46,14 @@ static void test_mipmapcache(skiatest::Reporter* reporter, SkResourceCache* cach
sk_sp<SkImage> img = SkImage::MakeFromBitmap(src);
const auto desc = SkBitmapCacheDesc::Make(img.get());
const SkMipMap* mipmap = SkMipMapCache::FindAndRef(desc, cache);
const SkMipmap* mipmap = SkMipmapCache::FindAndRef(desc, cache);
REPORTER_ASSERT(reporter, nullptr == mipmap);
mipmap = SkMipMapCache::AddAndRef(as_IB(img.get()), cache);
mipmap = SkMipmapCache::AddAndRef(as_IB(img.get()), cache);
REPORTER_ASSERT(reporter, mipmap);
{
const SkMipMap* mm = SkMipMapCache::FindAndRef(desc, cache);
const SkMipmap* mm = SkMipmapCache::FindAndRef(desc, cache);
REPORTER_ASSERT(reporter, mm);
REPORTER_ASSERT(reporter, mm == mipmap);
mm->unref();
@ -67,7 +67,7 @@ static void test_mipmapcache(skiatest::Reporter* reporter, SkResourceCache* cach
check_data(reporter, mipmap, 1, kInCache, kNotLocked);
// find us again
mipmap = SkMipMapCache::FindAndRef(desc, cache);
mipmap = SkMipmapCache::FindAndRef(desc, cache);
check_data(reporter, mipmap, 2, kInCache, kLocked);
cache->purgeAll();
@ -86,23 +86,23 @@ static void test_mipmap_notify(skiatest::Reporter* reporter, SkResourceCache* ca
src[i].allocN32Pixels(5, 5);
src[i].setImmutable();
img[i] = SkImage::MakeFromBitmap(src[i]);
SkMipMapCache::AddAndRef(as_IB(img[i].get()), cache)->unref();
SkMipmapCache::AddAndRef(as_IB(img[i].get()), cache)->unref();
desc[i] = SkBitmapCacheDesc::Make(img[i].get());
}
for (int i = 0; i < N; ++i) {
const SkMipMap* mipmap = SkMipMapCache::FindAndRef(desc[i], cache);
const SkMipmap* mipmap = SkMipmapCache::FindAndRef(desc[i], cache);
// We're always using a local cache, so we know we won't be purged by other threads
REPORTER_ASSERT(reporter, mipmap);
SkSafeUnref(mipmap);
img[i].reset(); // delete the image, which *should not* remove us from the cache
mipmap = SkMipMapCache::FindAndRef(desc[i], cache);
mipmap = SkMipmapCache::FindAndRef(desc[i], cache);
REPORTER_ASSERT(reporter, mipmap);
SkSafeUnref(mipmap);
src[i].reset(); // delete the underlying pixelref, which *should* remove us from the cache
mipmap = SkMipMapCache::FindAndRef(desc[i], cache);
mipmap = SkMipmapCache::FindAndRef(desc[i], cache);
REPORTER_ASSERT(reporter, !mipmap);
}
}

View File

@ -14,7 +14,7 @@
#include "include/core/SkYUVASizeInfo.h"
#include "include/gpu/GrDirectContext.h"
#include "src/core/SkCachedData.h"
#include "src/core/SkMipMap.h"
#include "src/core/SkMipmap.h"
#include "src/core/SkTaskGroup.h"
#include "src/gpu/GrContextPriv.h"
#include "src/image/SkImage_Base.h"
@ -51,7 +51,7 @@ const std::unique_ptr<SkPixmap[]> DDLPromiseImageHelper::PromiseImageInfo::norma
pixmaps[0] = fBaseLevel.pixmap();
if (fMipLevels) {
for (int i = 0; i < fMipLevels->countLevels(); ++i) {
SkMipMap::Level mipLevel;
SkMipmap::Level mipLevel;
fMipLevels->getLevel(i, &mipLevel);
pixmaps[i+1] = mipLevel.fPixmap;
}
@ -65,7 +65,7 @@ int DDLPromiseImageHelper::PromiseImageInfo::numMipLevels() const {
}
void DDLPromiseImageHelper::PromiseImageInfo::setMipLevels(const SkBitmap& baseLevel,
std::unique_ptr<SkMipMap> mipLevels) {
std::unique_ptr<SkMipmap> mipLevels) {
fBaseLevel = baseLevel;
fMipLevels = std::move(mipLevels);
}
@ -484,7 +484,7 @@ int DDLPromiseImageHelper::addImage(SkImage* image) {
// SKP) we don't know if a given SkImage will require mipmapping. To work around this
// we just try to create all the backend textures as mipmapped but, failing that, fall
// back to un-mipped.
std::unique_ptr<SkMipMap> mipmaps(SkMipMap::Build(tmp.pixmap(), nullptr));
std::unique_ptr<SkMipmap> mipmaps(SkMipmap::Build(tmp.pixmap(), nullptr));
newImageInfo.setMipLevels(tmp, std::move(mipmaps));
}

View File

@ -20,7 +20,7 @@
class GrContext;
class SkImage;
class SkMipMap;
class SkMipmap;
class SkPicture;
class SkTaskGroup;
struct SkYUVAIndex;
@ -213,7 +213,7 @@ private:
return fCallbackContexts[index]->promiseImageTexture();
}
void setMipLevels(const SkBitmap& baseLevel, std::unique_ptr<SkMipMap> mipLevels);
void setMipLevels(const SkBitmap& baseLevel, std::unique_ptr<SkMipmap> mipLevels);
void setYUVData(sk_sp<SkCachedData> yuvData,
SkYUVAIndex yuvaIndices[SkYUVAIndex::kIndexCount],
@ -236,7 +236,7 @@ private:
// CPU-side cache of a normal SkImage's mipmap levels
SkBitmap fBaseLevel;
std::unique_ptr<SkMipMap> fMipLevels;
std::unique_ptr<SkMipmap> fMipLevels;
// CPU-side cache of a YUV SkImage's contents
sk_sp<SkCachedData> fYUVData; // when !null, this is a YUV image

View File

@ -11,7 +11,7 @@
#include <string>
#include "src/core/SkAutoPixmapStorage.h"
#include "src/core/SkMipMap.h"
#include "src/core/SkMipmap.h"
#include "src/core/SkUtils.h"
#include "tools/flags/CommandLineFlags.h"
@ -156,7 +156,7 @@ static bool setup_backend_objects(GrContext* context,
pixmap = &rgbaPixmap;
}
int mipLevelCount = GrMipMapped::kYes == options.fMipMapping
? SkMipMap::ComputeLevelCount(bm.width(), bm.height())
? SkMipmap::ComputeLevelCount(bm.width(), bm.height())
: 1;
std::unique_ptr<GrMipLevel[]> texels(new GrMipLevel[mipLevelCount]);
@ -213,7 +213,7 @@ static bool setup_backend_objects(GrContext* context,
{
int mipLevelCount =
GrMipMapped::kYes == options.fOffScreenMipMapping
? SkMipMap::ComputeLevelCount(offscreenDims.width(), offscreenDims.height())
? SkMipmap::ComputeLevelCount(offscreenDims.width(), offscreenDims.height())
: 1;
std::unique_ptr<GrMipLevel[]> texels(new GrMipLevel[mipLevelCount]);