[librsvg: 2/14] Add a format check to SharedImageSurface::new()
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 2/14] Add a format check to SharedImageSurface::new()
- Date: Sun, 15 Jul 2018 17:55:31 +0000 (UTC)
commit 45c7dd7991965e07b2ba84898a92fd1f3f594763
Author: Ivan Molodetskikh <yalterz gmail com>
Date: Sun Jul 15 13:14:28 2018 +0300
Add a format check to SharedImageSurface::new()
rsvg_internals/src/surface_utils/shared_surface.rs | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
---
diff --git a/rsvg_internals/src/surface_utils/shared_surface.rs
b/rsvg_internals/src/surface_utils/shared_surface.rs
index fa5d0b04..088c642d 100644
--- a/rsvg_internals/src/surface_utils/shared_surface.rs
+++ b/rsvg_internals/src/surface_utils/shared_surface.rs
@@ -52,9 +52,13 @@ impl SharedImageSurface {
/// Creates a `SharedImageSurface` from a unique `ImageSurface`.
///
/// # Panics
- /// Panics if the `ImageSurface` is not unique, that is, its reference count isn't 1.
+ /// Panics if the surface format isn't `ARgb32` and if the surface is not unique, that is, its
+ /// reference count isn't 1.
#[inline]
pub fn new(surface: ImageSurface) -> Result<Self, cairo::Status> {
+ // get_pixel() assumes ARgb32.
+ assert_eq!(surface.get_format(), cairo::Format::ARgb32);
+
let reference_count =
unsafe { cairo_sys::cairo_surface_get_reference_count(surface.to_raw_none()) };
assert_eq!(reference_count, 1);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]