aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkPictureImageGenerator.h
diff options
context:
space:
mode:
authorGravatar Matt Sarett <msarett@google.com>2017-02-14 13:50:43 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-02-14 21:32:10 +0000
commit9df70bb74db8294283e8d2d8e20c95d290d2a34d (patch)
tree47f70a2a36d254599db76e77cb6c93a31b895b7d /src/core/SkPictureImageGenerator.h
parent6f449692c148c6b36d65c4bfa2941e3b09e25c38 (diff)
Picture backed images must have a bit depth and color space
Enforce that picture backed images created by the public API must have a non-null SkColorSpace. SkPictureShader uses a private call to get around this restriction. BUG=skia: Change-Id: I2fc11a8ffe583035d09e83abf40b827fbf575321 Reviewed-on: https://skia-review.googlesource.com/8415 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Matt Sarett <msarett@google.com>
Diffstat (limited to 'src/core/SkPictureImageGenerator.h')
-rw-r--r--src/core/SkPictureImageGenerator.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/core/SkPictureImageGenerator.h b/src/core/SkPictureImageGenerator.h
new file mode 100644
index 0000000000..cfb36a3601
--- /dev/null
+++ b/src/core/SkPictureImageGenerator.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkImageGenerator.h"
+#include "SkTLazy.h"
+
+class SkPictureImageGenerator : SkImageGenerator {
+public:
+ static SkImageGenerator* Create(const SkISize&, const SkPicture*, const SkMatrix*,
+ const SkPaint*, SkImage::BitDepth, sk_sp<SkColorSpace>);
+
+protected:
+ bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, SkPMColor ctable[],
+ int* ctableCount) override;
+ bool onComputeScaledDimensions(SkScalar scale, SupportedSizes*) override;
+ bool onGenerateScaledPixels(const SkPixmap&) override;
+
+#if SK_SUPPORT_GPU
+ GrTexture* onGenerateTexture(GrContext*, const SkImageInfo&, const SkIPoint&) override;
+#endif
+
+private:
+ SkPictureImageGenerator(const SkImageInfo& info, const SkPicture*, const SkMatrix*,
+ const SkPaint*);
+
+ sk_sp<const SkPicture> fPicture;
+ SkMatrix fMatrix;
+ SkTLazy<SkPaint> fPaint;
+
+ typedef SkImageGenerator INHERITED;
+};