[gnome-documents/gnome-3-12] documents: store images in cairo surfaces
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents/gnome-3-12] documents: store images in cairo surfaces
- Date: Fri, 25 Apr 2014 12:37:35 +0000 (UTC)
commit 47f3cbb50bb28e2f7bfa53ba270818ee060a0d39
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Tue Aug 6 15:46:23 2013 +0200
documents: store images in cairo surfaces
This adds support for HiDpi.
src/documents.js | 19 ++++++++++++-------
src/view.js | 8 ++++----
2 files changed, 16 insertions(+), 11 deletions(-)
---
diff --git a/src/documents.js b/src/documents.js
index c0f9e3f..f9d7c27 100644
--- a/src/documents.js
+++ b/src/documents.js
@@ -230,7 +230,7 @@ const DocCommon = new Lang.Class({
this.author = null;
this.mtime = null;
this.resourceUrn = null;
- this.pixbuf = null;
+ this.surface = null;
this.origPixbuf = null;
this.defaultAppName = null;
@@ -328,9 +328,10 @@ const DocCommon = new Lang.Class({
icon = Utils.iconFromRdfType(this.rdfType);
let iconInfo =
- Gtk.IconTheme.get_default().lookup_by_gicon(icon, Utils.getIconSize(),
- Gtk.IconLookupFlags.FORCE_SIZE |
- Gtk.IconLookupFlags.GENERIC_FALLBACK);
+ Gtk.IconTheme.get_default().lookup_by_gicon_for_scale(icon, Utils.getIconSize(),
+ Application.application.getScaleFactor(),
+ Gtk.IconLookupFlags.FORCE_SIZE |
+ Gtk.IconLookupFlags.GENERIC_FALLBACK);
let pixbuf = null;
if (iconInfo != null) {
@@ -451,8 +452,9 @@ const DocCommon = new Lang.Class({
function(object, res) {
try {
let stream = object.read_finish(res);
+ let scale = Application.application.getScaleFactor();
GdkPixbuf.Pixbuf.new_from_stream_at_scale_async(stream,
- Utils.getIconSize(), Utils.getIconSize(),
+ Utils.getIconSize() * scale, Utils.getIconSize() * scale,
true, null, Lang.bind(this,
function(object, res) {
try {
@@ -485,7 +487,8 @@ const DocCommon = new Lang.Class({
},
_createSymbolicEmblem: function(name) {
- let pix = Gd.create_symbolic_icon(name, Utils.getIconSize());
+ let pix = Gd.create_symbolic_icon(name, Utils.getIconSize() *
+ Application.application.getScaleFactor());
if (!pix)
pix = new Gio.ThemedIcon({ name: name });
@@ -550,7 +553,9 @@ const DocCommon = new Lang.Class({
thumbnailedPixbuf = emblemedPixbuf;
}
- this.pixbuf = thumbnailedPixbuf;
+ this.surface = Gdk.cairo_surface_create_from_pixbuf(thumbnailedPixbuf,
+ Application.application.getScaleFactor(),
+ Application.application.getGdkWindow());
this.emit('info-updated');
},
diff --git a/src/view.js b/src/view.js
index b22004c..ad671f3 100644
--- a/src/view.js
+++ b/src/view.js
@@ -19,9 +19,9 @@
*
*/
+const Cairo = imports.gi.cairo;
const Gd = imports.gi.Gd;
const Gdk = imports.gi.Gdk;
-const GdkPixbuf = imports.gi.GdkPixbuf;
const Gettext = imports.gettext;
const GLib = imports.gi.GLib;
const GObject = imports.gi.GObject;
@@ -114,7 +114,7 @@ const ViewModel = new Lang.Class({
GObject.TYPE_STRING,
GObject.TYPE_STRING,
GObject.TYPE_STRING,
- GdkPixbuf.Pixbuf,
+ Cairo.Surface,
GObject.TYPE_LONG,
GObject.TYPE_BOOLEAN,
GObject.TYPE_UINT ]);
@@ -144,7 +144,7 @@ const ViewModel = new Lang.Class({
this.model.set(iter,
[ 0, 1, 2, 3, 4, 5 ],
[ doc.id, doc.uri, doc.name,
- doc.author, doc.pixbuf, doc.mtime ]);
+ doc.author, doc.surface, doc.mtime ]);
let treePath = this.model.get_path(iter);
let treeRowRef = Gtk.TreeRowReference.new(this.model, treePath);
@@ -160,7 +160,7 @@ const ViewModel = new Lang.Class({
this.model.set(objectIter,
[ 0, 1, 2, 3, 4, 5 ],
[ doc.id, doc.uri, doc.name,
- doc.author, doc.pixbuf, doc.mtime ]);
+ doc.author, doc.surface, doc.mtime ]);
}));
},
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]