Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(313)

Side by Side Diff: experimental/skpdiff/SkImageDiffer.h

Issue 16284007: add skpdiff tool to compare bitmaps (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 #ifndef SkImageDiffer_DEFINED
djsollen 2013/06/12 13:32:04 add the standard google copyright at the top of th
Zach Reizner 2013/06/12 21:57:47 Done.
2 #define SkImageDiffer_DEFINED
3
4 #include <CL/cl.h>
5 #include "SkTDArray.h"
6
7
8 class SkBitmap;
9 class SkStream;
10
11 struct RunProfile {
djsollen 2013/06/12 13:32:04 remove this
Zach Reizner 2013/06/12 21:57:47 Done.
12
13 };
14
15 struct QueuedDiff {
djsollen 2013/06/12 13:32:04 Does this need to exist or can it be folded into L
Zach Reizner 2013/06/12 21:57:47 Done.
16 bool finished;
17 double result;
18 };
19
20 class ImageDiffer {
bsalomon 2013/06/12 13:55:11 Comments describing these classes would be really
bsalomon 2013/06/12 13:55:11 Should probably be SkImageDiffer
Zach Reizner 2013/06/12 21:57:47 Done.
21 public:
22 ImageDiffer();
23 virtual ~ImageDiffer();
24
25 virtual const char* getName() = 0;
26
27 bool isGood() { return fIsGood; }
28
29 int queueDiffOfFile(const char baseline[], const char test[]);
djsollen 2013/06/12 13:32:04 to be consistent wit the rest of skia use const ch
bsalomon 2013/06/12 13:55:11 Is our rule const char* for null term strings? We
Zach Reizner 2013/06/12 21:57:47 I saw const char[] in the sources I was copying st
30
31 virtual int queueDiff(SkBitmap * baseline, SkBitmap * test) = 0;
djsollen 2013/06/12 13:32:04 no space -- SkBitmap* also add comment about what
Zach Reizner 2013/06/12 21:57:47 Done.
32
33 /**
34 * Gets whether a queued diff of the given id has finished
35 * @param id The id of the queued diff to query
36 * @return True if the queued diff is finished and has results, false oth erwise
37 */
38 virtual bool isFinished(int id) = 0;
39
40 /**
41 * Gets the results of the queued diff of the given id. The results are only meaningful after
42 * the queued diff has finished.
43 * @param id The id of the queued diff to query
44 * @return A score between of how different the compared images are, with lower numbers being
45 * more different.
46 */
47 virtual double getResult(int id) = 0;
48
49 protected:
50 bool fIsGood;
51 };
52
53
54
55 class CLImageDiffer : public ImageDiffer {
djsollen 2013/06/12 13:32:04 So at first glance I would move this and Different
Zach Reizner 2013/06/12 21:57:47 Done.
56 public:
57 CLImageDiffer();
58 virtual bool init(cl_device_id device, cl_context context) SK_OVERRIDE;
59
60 protected:
61 virtual bool onInit() = 0;
62
63 bool loadKernelFile(const char file[], const char name[], cl_kernel* kernel) ;
64 bool loadKernelStream(SkStream* stream, const char name[], cl_kernel* kernel );
65 bool loadKernelSource(const char source[], const char name[], cl_kernel* ker nel);
66
67 bool makeImage2D(SkBitmap* bitmap, cl_mem* image);
68
69 cl_device_id fDevice;
70 cl_context fContext;
71 cl_command_queue fCommandQueue;
72 private:
bsalomon 2013/06/12 13:55:11 skia style is to have a \n before public, private,
Zach Reizner 2013/06/12 21:57:47 Done.
73
74
75
76 typedef ImageDiffer INHERITED;
77 };
78
79
80
81
82 class DifferentPixelsImageDiffer : public CLImageDiffer {
83 public:
84 virtual const char* getName() SK_OVERRIDE;
85 virtual int queueDiff(SkBitmap * baseline, SkBitmap * test) SK_OVERRIDE;
86 virtual bool isFinished(int id) SK_OVERRIDE;
87 virtual double getResult(int id) SK_OVERRIDE;
88
89 protected:
90 virtual bool onInit() SK_OVERRIDE;
91
92 private:
93 struct LocalQueuedDiff : public QueuedDiff
94 {
bsalomon 2013/06/12 13:55:11 { goes on prev line
Zach Reizner 2013/06/12 21:57:47 Done.
95 cl_mem baseline;
96 cl_mem test;
97 cl_mem resultsBuffer;
98 };
99
100
101 SkTDArray<LocalQueuedDiff> fQueuedDiffs;
102 cl_kernel fKernel;
103
104 typedef CLImageDiffer INHERITED;
105 };
106
107 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698