[evince/wip/gpoo/rgba-cherry-picking: 2/2] backends: Use GdkRGBA instead of GdkColor in pdf
- From: Germán Poo-Caamaño <gpoo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evince/wip/gpoo/rgba-cherry-picking: 2/2] backends: Use GdkRGBA instead of GdkColor in pdf
- Date: Mon, 11 Oct 2021 20:09:40 +0000 (UTC)
commit 5df2cafe10d8120caa0a1813fee9bbd5c15d506a
Author: Qiu Wenbo <qiuwenbo kylinos com cn>
Date: Sun Aug 15 21:19:36 2021 +0800
backends: Use GdkRGBA instead of GdkColor in pdf
Update on internal functions that do not break the API.
Signed-off-by: Qiu Wenbo <qiuwenbo kylinos com cn>
backend/pdf/ev-poppler.c | 37 +++++++++++++++++++------------------
1 file changed, 19 insertions(+), 18 deletions(-)
---
diff --git a/backend/pdf/ev-poppler.c b/backend/pdf/ev-poppler.c
index 8f851edb..351d57bc 100644
--- a/backend/pdf/ev-poppler.c
+++ b/backend/pdf/ev-poppler.c
@@ -3074,16 +3074,17 @@ pdf_document_document_forms_iface_init (EvDocumentFormsInterface *iface)
/* Annotations */
static void
-poppler_annot_color_to_gdk_color (PopplerAnnot *poppler_annot,
- GdkColor *color)
+poppler_annot_color_to_gdk_rgba (PopplerAnnot *poppler_annot,
+ GdkRGBA *color)
{
PopplerColor *poppler_color;
poppler_color = poppler_annot_get_color (poppler_annot);
if (poppler_color) {
- color->red = poppler_color->red;
- color->green = poppler_color->green;
- color->blue = poppler_color->blue;
+ color->red = CLAMP ((double) poppler_color->red / 65535.0, 0.0, 1.0);
+ color->green = CLAMP ((double) poppler_color->green / 65535.0, 0.0, 1.0),
+ color->blue = CLAMP ((double) poppler_color->blue / 65535.0, 0.0, 1.0),
+ color->alpha = 1.0;
g_free (poppler_color);
} /* TODO: else use a default color */
@@ -3303,7 +3304,7 @@ ev_annot_from_poppler_annot (PopplerAnnot *poppler_annot,
gchar *modified;
gchar *contents;
gchar *name;
- GdkColor color;
+ GdkRGBA color;
contents = poppler_annot_get_contents (poppler_annot);
if (contents) {
@@ -3325,8 +3326,8 @@ ev_annot_from_poppler_annot (PopplerAnnot *poppler_annot,
}
g_free (modified);
- poppler_annot_color_to_gdk_color (poppler_annot, &color);
- ev_annotation_set_color (ev_annot, &color);
+ poppler_annot_color_to_gdk_rgba (poppler_annot, &color);
+ ev_annotation_set_rgba (ev_annot, &color);
if (poppler_annot_can_have_popup_window (poppler_annot)) {
PopplerAnnotMarkup *markup;
@@ -3612,7 +3613,7 @@ pdf_document_annotations_add_annotation (EvDocumentAnnotations *document_annotat
PopplerRectangle poppler_rect;
gdouble height;
PopplerColor poppler_color;
- GdkColor color;
+ GdkRGBA color;
EvRectangle rect;
pdf_document = PDF_DOCUMENT (document_annotations);
@@ -3670,10 +3671,10 @@ pdf_document_annotations_add_annotation (EvDocumentAnnotations *document_annotat
g_assert_not_reached ();
}
- ev_annotation_get_color (annot, &color);
- poppler_color.red = color.red;
- poppler_color.green = color.green;
- poppler_color.blue = color.blue;
+ ev_annotation_get_rgba (annot, &color);
+ poppler_color.red = CLAMP ((guint) (color.red * 65535), 0, 65535);
+ poppler_color.green = CLAMP ((guint) (color.green * 65535), 0, 65535);
+ poppler_color.blue = CLAMP ((guint) (color.blue * 65535), 0, 65535);
poppler_annot_set_color (poppler_annot, &poppler_color);
if (EV_IS_ANNOTATION_MARKUP (annot)) {
@@ -3797,12 +3798,12 @@ pdf_document_annotations_save_annotation (EvDocumentAnnotations *document_annota
if (mask & EV_ANNOTATIONS_SAVE_COLOR) {
PopplerColor color;
- GdkColor ev_color;
+ GdkRGBA ev_color;
- ev_annotation_get_color (annot, &ev_color);
- color.red = ev_color.red;
- color.green = ev_color.green;
- color.blue = ev_color.blue;
+ ev_annotation_get_rgba (annot, &ev_color);
+ color.red = CLAMP ((guint) (ev_color.red * 65535), 0, 65535);
+ color.green = CLAMP ((guint) (ev_color.green * 65535), 0, 65535);
+ color.blue = CLAMP ((guint) (ev_color.blue * 65535), 0, 65535);
poppler_annot_set_color (poppler_annot, &color);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]