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

Unified Diff: src/gpu/GrYUVProvider.h

Issue 1315353006: refactor parts of SkGr.cpp for use by SkImages (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix nits Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/gpu/SkGr.h ('k') | src/gpu/GrYUVProvider.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrYUVProvider.h
diff --git a/src/gpu/GrYUVProvider.h b/src/gpu/GrYUVProvider.h
new file mode 100644
index 0000000000000000000000000000000000000000..869e1fd00d92c214b6bd58052734001cd2533b07
--- /dev/null
+++ b/src/gpu/GrYUVProvider.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrYUVProvider_DEFINED
+#define GrYUVProvider_DEFINED
+
+#include "GrTypes.h"
+#include "SkImageInfo.h"
+
+class GrContext;
+class GrTexture;
+
+/**
+ * There are at least 2 different ways to extract/retrieve YUV planar data...
+ * - SkPixelRef
+ * - SkImageGeneartor
+ *
+ * To share common functionality around using the planar data, we use this abstract base-class
+ * to represent accessing that data.
+ */
+class GrYUVProvider {
+public:
+ virtual ~GrYUVProvider() {}
+
+ /**
+ * On success, this returns a texture that has converted the YUV data from the provider
+ * into a form that is supported by the GPU (typically transformed into RGB). If useCache
+ * is true, then the texture will automatically have a key added, so it can be retrieved
+ * from the cache (assuming it is requested by a provider w/ the same genID).
+ *
+ * On failure (e.g. the provider had no data), this returns NULL.
+ */
+ GrTexture* refAsTexture(GrContext*, const GrSurfaceDesc&, bool useCache);
+
+ virtual uint32_t onGetID() = 0;
+
+ enum {
+ kY_Index = 0,
+ kU_Index = 1,
+ kV_Index = 2,
+
+ kPlaneCount = 3
+ };
+
+ // These are not meant to be called by a client, only by the implementation
+
+ /**
+ * Return the 3 dimensions for each plane and return true. On failure, return false and
+ * ignore the sizes parameter. Typical failure is that the provider does not contain YUV
+ * data, and may just be an RGB src.
+ */
+ virtual bool onGetYUVSizes(SkISize sizes[kPlaneCount]) = 0;
+
+ /**
+ * On success, return true, and set sizes, rowbytes and colorspace to the appropriate values.
+ * planes[] will have already been allocated by the client (based on the worst-case sizes
+ * returned by onGetYUVSizes(). This method copies its planar data into those buffers.
+ *
+ * On failure, return false and ignore other parameters.
+ */
+ virtual bool onGetYUVPlanes(SkISize sizes[kPlaneCount], void* planes[kPlaneCount],
+ size_t rowBytes[kPlaneCount], SkYUVColorSpace*) = 0;
+};
+
+#endif
« no previous file with comments | « include/gpu/SkGr.h ('k') | src/gpu/GrYUVProvider.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698