Validate SkSpecialSurface raster info
BUG=chromium:716311 Change-Id: I01ea2e77ba8920f735395dd46ef2cea78a858308 Reviewed-on: https://skia-review.googlesource.com/15230 Reviewed-by: Mike Reed <reed@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Florin Malita <fmalita@chromium.org>
This commit is contained in:
parent
e80e6183e5
commit
f40b24913a
@ -93,11 +93,18 @@ private:
|
||||
|
||||
sk_sp<SkSpecialSurface> SkSpecialSurface::MakeFromBitmap(const SkIRect& subset, SkBitmap& bm,
|
||||
const SkSurfaceProps* props) {
|
||||
if (subset.isEmpty() || !SkSurfaceValidateRasterInfo(bm.info(), bm.rowBytes())) {
|
||||
return nullptr;
|
||||
}
|
||||
return sk_make_sp<SkSpecialSurface_Raster>(bm.info(), sk_ref_sp(bm.pixelRef()), subset, props);
|
||||
}
|
||||
|
||||
sk_sp<SkSpecialSurface> SkSpecialSurface::MakeRaster(const SkImageInfo& info,
|
||||
const SkSurfaceProps* props) {
|
||||
if (!SkSurfaceValidateRasterInfo(info)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sk_sp<SkPixelRef> pr = SkMallocPixelRef::MakeZeroed(info, 0, nullptr);
|
||||
if (!pr) {
|
||||
return nullptr;
|
||||
|
@ -10,6 +10,8 @@
|
||||
|
||||
#include "SkSurfaceProps.h"
|
||||
|
||||
struct SkImageInfo;
|
||||
|
||||
static inline SkSurfaceProps SkSurfacePropsCopyOrDefault(const SkSurfaceProps* props) {
|
||||
if (props) {
|
||||
return *props;
|
||||
@ -22,4 +24,8 @@ static inline SkPixelGeometry SkSurfacePropsDefaultPixelGeometry() {
|
||||
return SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType).pixelGeometry();
|
||||
}
|
||||
|
||||
constexpr size_t kIgnoreRowBytesValue = static_cast<size_t>(~0);
|
||||
|
||||
bool SkSurfaceValidateRasterInfo(const SkImageInfo&, size_t rb = kIgnoreRowBytesValue);
|
||||
|
||||
#endif
|
||||
|
@ -11,12 +11,8 @@
|
||||
#include "SkDevice.h"
|
||||
#include "SkMallocPixelRef.h"
|
||||
|
||||
static const size_t kIgnoreRowBytesValue = (size_t)~0;
|
||||
|
||||
class SkSurface_Raster : public SkSurface_Base {
|
||||
public:
|
||||
static bool Valid(const SkImageInfo&, size_t rb = kIgnoreRowBytesValue);
|
||||
|
||||
SkSurface_Raster(const SkImageInfo&, void*, size_t rb,
|
||||
void (*releaseProc)(void* pixels, void* context), void* context,
|
||||
const SkSurfaceProps*);
|
||||
@ -39,7 +35,7 @@ private:
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool SkSurface_Raster::Valid(const SkImageInfo& info, size_t rowBytes) {
|
||||
bool SkSurfaceValidateRasterInfo(const SkImageInfo& info, size_t rowBytes) {
|
||||
if (info.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
@ -186,7 +182,7 @@ sk_sp<SkSurface> SkSurface::MakeRasterDirectReleaseProc(const SkImageInfo& info,
|
||||
if (nullptr == releaseProc) {
|
||||
context = nullptr;
|
||||
}
|
||||
if (!SkSurface_Raster::Valid(info, rb)) {
|
||||
if (!SkSurfaceValidateRasterInfo(info, rb)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (nullptr == pixels) {
|
||||
@ -203,7 +199,7 @@ sk_sp<SkSurface> SkSurface::MakeRasterDirect(const SkImageInfo& info, void* pixe
|
||||
|
||||
sk_sp<SkSurface> SkSurface::MakeRaster(const SkImageInfo& info, size_t rowBytes,
|
||||
const SkSurfaceProps* props) {
|
||||
if (!SkSurface_Raster::Valid(info)) {
|
||||
if (!SkSurfaceValidateRasterInfo(info)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user