Index: skia/ext/layer_allocator_cairo.h |
diff --git a/skia/ext/layer_allocator_cairo.h b/skia/ext/layer_allocator_cairo.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..8f912adb746c717ccfcfa400ba8ed7d01270ee7e |
--- /dev/null |
+++ b/skia/ext/layer_allocator_cairo.h |
@@ -0,0 +1,47 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef SKIA_EXT_LAYER_ALLOCATOR_CAIRO_H_ |
+#define SKIA_EXT_LAYER_ALLOCATOR_CAIRO_H_ |
+ |
+#include "skia/ext/platform_surface.h" |
+ |
+#include "third_party/skia/include/core/SkRasterCanvasLayerAllocator.h" |
+ |
+#include <unordered_map> |
+ |
+namespace skia { |
+ |
+/* |
+ * On a stock Linux build, a PlatformCanvas is backed by a Cairo image |
+ * surface; a PlatformSurface is a pointer to a Cairo context. |
+ */ |
+class LayerAllocator : public SkRasterCanvasLayerAllocator { |
+ public: |
+ LayerAllocator(); |
+ ~LayerAllocator() override; |
+ |
+ /// Returns cairo_t*. |
+ void* getNativeContext(void* buffer, |
+ const SkMatrix& transform, |
+ const SkIRect& clip_bounds) override; |
+ |
+ protected: |
+ /// Expects a cairo_surface_t* as (optional) initialData. |
+ /// Returns the data pointer from a cairo_image_surface. |
+ /// |deallocator| will cairo_surface_destroy() and cairo_destroy() |
+ /// the layer. |
+ void* allocateLayer(const SkImageInfo& info, size_t* rowBytes, |
+ void (**deallocator)(void*), |
+ void** deallocatorPayload, |
+ void* initialData) override; |
+ |
+ private: |
+ typedef std::unordered_map<void*, cairo_t*> context_map_t; |
+ context_map_t contexts_; |
+}; |
+ |
+} |
+ |
+#endif // SKIA_EXT_LAYER_ALLOCATOR_CAIRO_H_ |