bool ImageFrame::setSizeAndColorSpace(int newWidth, int newHeight, sk_sp<SkColorSpace> colorSpace) { // setSizeAndColorSpace() should only be called once, it leaks memory // otherwise. DCHECK(!width() && !height()); // The image must specify a color space. // TODO(ccameron): This should be set unconditionally, but specifying a // non-renderable SkColorSpace results in errors. // https://bugs.chromium.org/p/skia/issues/detail?id=5907 if (RuntimeEnabledFeatures::colorCorrectRenderingEnabled()) { DCHECK(colorSpace); m_colorSpace = std::move(colorSpace); } else { DCHECK(!colorSpace); } m_bitmap.setInfo(SkImageInfo::MakeN32( newWidth, newHeight, m_premultiplyAlpha ? kPremul_SkAlphaType : kUnpremul_SkAlphaType, m_colorSpace)); if (!m_bitmap.tryAllocPixels(m_allocator, 0)) return false; zeroFillPixelData(); return true; }
bool ImageFrame::setSize(int newWidth, int newHeight) { // setSize() should only be called once, it leaks memory otherwise. ASSERT(!width() && !height()); m_bitmap->bitmap().setConfig(SkBitmap::kARGB_8888_Config, newWidth, newHeight); if (!m_bitmap->bitmap().allocPixels(m_allocator, 0)) return false; zeroFillPixelData(); return true; }
bool ImageFrame::setSize(int newWidth, int newHeight) { // NOTE: This has no way to check for allocation failure if the requested // size was too big... m_backingStore.resize(newWidth * newHeight); m_bytes = m_backingStore.data(); m_size = IntSize(newWidth, newHeight); zeroFillPixelData(); return true; }
bool ImageFrame::setSize(int newWidth, int newHeight) { // setSize() should only be called once, it leaks memory otherwise. ASSERT(!width() && !height()); m_bitmap.setConfig(SkImageInfo::MakeN32Premul(newWidth, newHeight)); if (!m_bitmap.allocPixels(m_allocator, 0)) return false; zeroFillPixelData(); return true; }
bool ImageFrame::setSize(int newWidth, int newHeight) { ASSERT(!width() && !height()); size_t backingStoreSize = newWidth * newHeight; if (!m_backingStore.tryReserveCapacity(backingStoreSize)) return false; m_backingStore.resize(backingStoreSize); m_bytes = m_backingStore.data(); m_size = IntSize(newWidth, newHeight); zeroFillPixelData(); return true; }
bool ImageFrame::setSize(int newWidth, int newHeight) { // This function should only be called once, it will leak memory // otherwise. ASSERT(width() == 0 && height() == 0); m_bitmap.bitmap().setConfig(SkBitmap::kARGB_8888_Config, newWidth, newHeight); if (!m_bitmap.bitmap().allocPixels()) return false; zeroFillPixelData(); return true; }
bool ImageFrame::setSize(int newWidth, int newHeight) { // setSize() should only be called once, it leaks memory otherwise. ASSERT(!width() && !height()); m_size = IntSize(newWidth, newHeight); m_image = QImage(); m_pixmap = QPixmap(newWidth, newHeight); if (m_pixmap.isNull()) return false; zeroFillPixelData(); return true; }
bool ImageFrame::setSize(int newWidth, int newHeight) { // This function should only be called once, it will leak memory // otherwise. ASSERT(width() == 0 && height() == 0); m_size = IntSize(newWidth, newHeight); m_image = QImage(); m_pixmap = QPixmap(newWidth, newHeight); if (m_pixmap.isNull()) return false; zeroFillPixelData(); return true; }