return fInfo;
}
+ int width() const { return fInfo.width(); }
+ int height() const { return fInfo.height(); }
void* pixels() const { return fPixels; }
SkColorTable* colorTable() const { return fCTable.get(); }
size_t rowBytes() const { return fRowBytes; }
class SkSpecialSurface_Raster : public SkSpecialSurface_Base {
public:
- SkSpecialSurface_Raster(sk_sp<SkPixelRef> pr,
+ SkSpecialSurface_Raster(const SkImageInfo& info,
+ sk_sp<SkPixelRef> pr,
const SkIRect& subset,
const SkSurfaceProps* props)
: INHERITED(subset, props) {
- const SkImageInfo& info = pr->info();
-
+ SkASSERT(info.width() == pr->width() && info.height() == pr->height());
fBitmap.setInfo(info, info.minRowBytes());
fBitmap.setPixelRef(std::move(pr), 0, 0);
sk_sp<SkSpecialSurface> SkSpecialSurface::MakeFromBitmap(const SkIRect& subset, SkBitmap& bm,
const SkSurfaceProps* props) {
- return sk_make_sp<SkSpecialSurface_Raster>(sk_ref_sp(bm.pixelRef()), subset, props);
+ return sk_make_sp<SkSpecialSurface_Raster>(bm.info(), sk_ref_sp(bm.pixelRef()), subset, props);
}
sk_sp<SkSpecialSurface> SkSpecialSurface::MakeRaster(const SkImageInfo& info,
return nullptr;
}
- const SkIRect subset = SkIRect::MakeWH(pr->info().width(), pr->info().height());
+ const SkIRect subset = SkIRect::MakeWH(info.width(), info.height());
- return sk_make_sp<SkSpecialSurface_Raster>(std::move(pr), subset, props);
+ return sk_make_sp<SkSpecialSurface_Raster>(info, std::move(pr), subset, props);
}
#if SK_SUPPORT_GPU
// fixes https://bug.skia.org/5096
static bool is_not_subset(const SkBitmap& bm) {
SkASSERT(bm.pixelRef());
- SkISize dim = bm.pixelRef()->info().dimensions();
+ SkISize dim = SkISize::Make(bm.pixelRef()->width(), bm.pixelRef()->height());
SkASSERT(dim != bm.dimensions() || bm.pixelRefOrigin().isZero());
return dim == bm.dimensions();
}
SkSurface_Raster(const SkImageInfo&, void*, size_t rb,
void (*releaseProc)(void* pixels, void* context), void* context,
const SkSurfaceProps*);
- SkSurface_Raster(sk_sp<SkPixelRef>, const SkSurfaceProps*);
+ SkSurface_Raster(const SkImageInfo& info, sk_sp<SkPixelRef>, const SkSurfaceProps*);
SkCanvas* onNewCanvas() override;
sk_sp<SkSurface> onNewSurface(const SkImageInfo&) override;
fWeOwnThePixels = false; // We are "Direct"
}
-SkSurface_Raster::SkSurface_Raster(sk_sp<SkPixelRef> pr, const SkSurfaceProps* props)
- : INHERITED(pr->info().width(), pr->info().height(), props)
+SkSurface_Raster::SkSurface_Raster(const SkImageInfo& info, sk_sp<SkPixelRef> pr,
+ const SkSurfaceProps* props)
+ : INHERITED(pr->width(), pr->height(), props)
{
- const SkImageInfo& info = pr->info();
-
fBitmap.setInfo(info, pr->rowBytes());
fRowBytes = pr->rowBytes(); // we track this, so that subsequent re-allocs will match
fBitmap.setPixelRef(std::move(pr), 0, 0);
if (rowBytes) {
SkASSERT(pr->rowBytes() == rowBytes);
}
- return sk_make_sp<SkSurface_Raster>(std::move(pr), props);
+ return sk_make_sp<SkSurface_Raster>(info, std::move(pr), props);
}
SkIRect subset = bitmap.getSubset();
SkASSERT(bitmap.pixelRef());
SkBitmap tmp;
- tmp.setInfo(bitmap.pixelRef()->info(), bitmap.rowBytes());
+ SkImageInfo pixelRefInfo =
+ bitmap.info().makeWH(bitmap.pixelRef()->width(), bitmap.pixelRef()->height());
+ tmp.setInfo(pixelRefInfo, bitmap.rowBytes());
tmp.setPixelRef(sk_ref_sp(bitmap.pixelRef()), 0, 0);
auto img = SkImage::MakeFromBitmap(tmp);
if (img) {