[shotwell/wip/optimize: 2/6] Do not use abstract functions to lookup constants



commit f60bf3588df63f121c77b4aed45195fd4554e95c
Author: Jens Georg <mail jensge org>
Date:   Tue Mar 14 23:43:22 2017 +0100

    Do not use abstract functions to lookup constants
    
    Signed-off-by: Jens Georg <mail jensge org>
    
    https://bugzilla.gnome.org/show_bug.cgi?id=742563

 src/ColorTransformation.vala |   21 +++++++++------------
 1 files changed, 9 insertions(+), 12 deletions(-)
---
diff --git a/src/ColorTransformation.vala b/src/ColorTransformation.vala
index 5fab75c..8f20894 100644
--- a/src/ColorTransformation.vala
+++ b/src/ColorTransformation.vala
@@ -369,16 +369,21 @@ public class PixelTransformationBundle {
 
 public abstract class PixelTransformation {
     private PixelTransformationType type;
+    private PixelFormat preferred_format;
     
-    public PixelTransformation(PixelTransformationType type) {
+    public PixelTransformation(PixelTransformationType type,
+                               PixelFormat preferred_format) {
         this.type = type;
+        this.preferred_format = preferred_format;
     }
     
     public PixelTransformationType get_transformation_type() {
         return type;
     }
     
-    public abstract PixelFormat get_preferred_format();
+    public PixelFormat get_preferred_format() {
+        return this.preferred_format;
+    }
 
     public virtual CompositionMode get_composition_mode() {
         return CompositionMode.NONE;
@@ -418,7 +423,7 @@ public class RGBTransformation : PixelTransformation {
     protected bool identity = true;
     
     public RGBTransformation(PixelTransformationType type) {
-        base(type);
+        base(type, PixelFormat.RGB);
         
         // Can't initialize these in their member declarations because of a valac bug that
         // I've been unable to produce a minimal test case for to report (JN).  May be 
@@ -431,10 +436,6 @@ public class RGBTransformation : PixelTransformation {
         0.0f, 0.0f, 0.0f, 1.0f };
     }
 
-    public override PixelFormat get_preferred_format() {
-        return PixelFormat.RGB;
-    }
-
     public override CompositionMode get_composition_mode() {
         return CompositionMode.RGB_MATRIX;
     }
@@ -597,13 +598,9 @@ public class RGBTransformation : PixelTransformation {
 
 public abstract class HSVTransformation : PixelTransformation {
     public HSVTransformation(PixelTransformationType type) {
-        base(type);
+        base(type, PixelFormat.HSV);
     }
     
-    public override PixelFormat get_preferred_format() {
-        return PixelFormat.HSV;
-    }
-
     public override RGBAnalyticPixel transform_pixel_rgb(RGBAnalyticPixel p) {
         return (transform_pixel_hsv(p.to_hsv())).to_rgb();
     }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]