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

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

Issue 16284007: add skpdiff tool to compare bitmaps (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: add commmand line opts 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
« no previous file with comments | « Makefile ('k') | experimental/skpdiff/SkCLImageDiffer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2013 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #ifndef SkCLImageDiffer_DEFINED
9 #define SkCLImageDiffer_DEFINED
10
11 #include <CL/cl.h>
12 #include "SkTDArray.h"
13
14 #include "SkImageDiffer.h"
15
16 class SkStream;
17
18 /**
19 * An SkImageDiffer that requires initialization with an OpenCL device and conte xt.
20 */
21 class SkCLImageDiffer : public SkImageDiffer {
22 public:
23 SkCLImageDiffer();
24
25 /**
26 * Initializes the OpenCL resources this differ needs to work
27 * @param device An OpenCL device
28 * @param context An OpenCL context of the given device
29 * @return True on success, false otherwise
30 */
31 virtual bool init(cl_device_id device, cl_context context);
32
33 protected:
34 /**
35 * Called by init after fDevice, fContext, and fCommandQueue are successfull y initialized
36 * @return True on success, false otherwise
37 */
38 virtual bool onInit() = 0;
39
40 /**
41 * Loads an OpenCL kernel from the file with the given named entry point. Th is only works after
42 * init is called.
43 * @param file The file path of the kernel
44 * @param name The name of the entry point of the desired kernel in the f ile
45 * @param kernel A pointer to return the loaded kernel into
46 * @return True on success, false otherwise
47 */
48 bool loadKernelFile(const char file[], const char name[], cl_kernel* kernel) ;
49
50 /**
51 * Loads an OpenCL kernel from the stream with the given named entry point. This only works
52 * after init is called.
53 * @param stream The stream that contains the kernel
54 * @param name The name of the entry point of the desired kernel in the stream
55 * @param kernel A pointer to return the loaded kernel into
56 * @return True on success, false otherwise
57 */
58 bool loadKernelStream(SkStream* stream, const char name[], cl_kernel* kernel );
59
60 /**
61 * Loads an OpenCL kernel from the source string with the given named entry point. This only
62 * works after init is called.
63 * @param source The string that contains the kernel
64 * @param name The name of the entry point of the desired kernel in the source string
65 * @param kernel A pointer to return the loaded kernel into
66 * @return True on success, false otherwise
67 */
68 bool loadKernelSource(const char source[], const char name[], cl_kernel* ker nel);
69
70 /**
71 * Loads a read only copy of the given bitmap into device memory and returns the block of
72 * memory. This only works after init is called.
73 * @param bitmap The bitmap to load into memory
74 * @param image A pointer to return the allocated image to
75 * @return True on success, false otherwise
76 */
77 bool makeImage2D(SkBitmap* bitmap, cl_mem* image);
78
79 cl_device_id fDevice;
80 cl_context fContext;
81 cl_command_queue fCommandQueue;
82
83 private:
84
85 typedef SkImageDiffer INHERITED;
86 };
87
88 /**
89 * A OpenCL differ that measures the percentage of different corresponding pixel s. If the two images
90 * are not the same size or have no pixels, the result will always be zero.
91 */
92 class SkDifferentPixelsImageDiffer : public SkCLImageDiffer {
93 public:
94 virtual const char* getName() SK_OVERRIDE;
95 virtual int queueDiff(SkBitmap* baseline, SkBitmap* test) SK_OVERRIDE;
96 virtual bool isFinished(int id) SK_OVERRIDE;
97 virtual double getResult(int id) SK_OVERRIDE;
98
99 protected:
100 virtual bool onInit() SK_OVERRIDE;
101
102 private:
103 struct QueuedDiff {
104 bool finished;
105 double result;
106 cl_mem baseline;
107 cl_mem test;
108 cl_mem resultsBuffer;
109 };
110
111 SkTDArray<QueuedDiff> fQueuedDiffs;
112 cl_kernel fKernel;
113
114 typedef SkCLImageDiffer INHERITED;
115 };
116
117 #endif
OLDNEW
« no previous file with comments | « Makefile ('k') | experimental/skpdiff/SkCLImageDiffer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698