Index: experimental/skpdiff/SkImageDiffer.h |
diff --git a/experimental/skpdiff/SkImageDiffer.h b/experimental/skpdiff/SkImageDiffer.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..6608feb48220fb0a1ef0bdb6dcad287fd020512a |
--- /dev/null |
+++ b/experimental/skpdiff/SkImageDiffer.h |
@@ -0,0 +1,107 @@ |
+#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.
|
+#define SkImageDiffer_DEFINED |
+ |
+#include <CL/cl.h> |
+#include "SkTDArray.h" |
+ |
+ |
+class SkBitmap; |
+class SkStream; |
+ |
+struct RunProfile { |
djsollen
2013/06/12 13:32:04
remove this
Zach Reizner
2013/06/12 21:57:47
Done.
|
+ |
+}; |
+ |
+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.
|
+ bool finished; |
+ double result; |
+}; |
+ |
+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.
|
+public: |
+ ImageDiffer(); |
+ virtual ~ImageDiffer(); |
+ |
+ virtual const char* getName() = 0; |
+ |
+ bool isGood() { return fIsGood; } |
+ |
+ 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
|
+ |
+ 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.
|
+ |
+ /** |
+ * Gets whether a queued diff of the given id has finished |
+ * @param id The id of the queued diff to query |
+ * @return True if the queued diff is finished and has results, false otherwise |
+ */ |
+ virtual bool isFinished(int id) = 0; |
+ |
+ /** |
+ * Gets the results of the queued diff of the given id. The results are only meaningful after |
+ * the queued diff has finished. |
+ * @param id The id of the queued diff to query |
+ * @return A score between of how different the compared images are, with lower numbers being |
+ * more different. |
+ */ |
+ virtual double getResult(int id) = 0; |
+ |
+protected: |
+ bool fIsGood; |
+}; |
+ |
+ |
+ |
+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.
|
+public: |
+ CLImageDiffer(); |
+ virtual bool init(cl_device_id device, cl_context context) SK_OVERRIDE; |
+ |
+protected: |
+ virtual bool onInit() = 0; |
+ |
+ bool loadKernelFile(const char file[], const char name[], cl_kernel* kernel); |
+ bool loadKernelStream(SkStream* stream, const char name[], cl_kernel* kernel); |
+ bool loadKernelSource(const char source[], const char name[], cl_kernel* kernel); |
+ |
+ bool makeImage2D(SkBitmap* bitmap, cl_mem* image); |
+ |
+ cl_device_id fDevice; |
+ cl_context fContext; |
+ cl_command_queue fCommandQueue; |
+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.
|
+ |
+ |
+ |
+ typedef ImageDiffer INHERITED; |
+}; |
+ |
+ |
+ |
+ |
+class DifferentPixelsImageDiffer : public CLImageDiffer { |
+public: |
+ virtual const char* getName() SK_OVERRIDE; |
+ virtual int queueDiff(SkBitmap * baseline, SkBitmap * test) SK_OVERRIDE; |
+ virtual bool isFinished(int id) SK_OVERRIDE; |
+ virtual double getResult(int id) SK_OVERRIDE; |
+ |
+protected: |
+ virtual bool onInit() SK_OVERRIDE; |
+ |
+private: |
+ struct LocalQueuedDiff : public QueuedDiff |
+ { |
bsalomon
2013/06/12 13:55:11
{ goes on prev line
Zach Reizner
2013/06/12 21:57:47
Done.
|
+ cl_mem baseline; |
+ cl_mem test; |
+ cl_mem resultsBuffer; |
+ }; |
+ |
+ |
+ SkTDArray<LocalQueuedDiff> fQueuedDiffs; |
+ cl_kernel fKernel; |
+ |
+ typedef CLImageDiffer INHERITED; |
+}; |
+ |
+#endif |