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

Unified Diff: src/core/SkBitmapController.h

Issue 1153123003: refactor bitmapshader to use a controller (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
Index: src/core/SkBitmapController.h
diff --git a/src/core/SkBitmapController.h b/src/core/SkBitmapController.h
new file mode 100644
index 0000000000000000000000000000000000000000..bc3c69691c508c056541a75076a12767b2ea3174
--- /dev/null
+++ b/src/core/SkBitmapController.h
@@ -0,0 +1,62 @@
+/*
+ * 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 SkBitmapController_DEFINED
+#define SkBitmapController_DEFINED
+
+#include "SkBitmap.h"
+#include "SkFilterQuality.h"
+#include "SkMatrix.h"
+
+/**
+ * Handles request to scale, filter, and lock a bitmap to be rasterized.
+ */
+class SkBitmapController : ::SkNoncopyable {
+public:
+ class State : ::SkNoncopyable {
+ public:
+ virtual ~State() {}
+
+ const SkBitmap& lockedBitmap() const { return fLockedBitmap; }
+ const SkMatrix& invMatrix() const { return fInvMatrix; }
+ SkFilterQuality quality() const { return fQuality; }
+
+ protected:
+ SkBitmap fLockedBitmap;
+ SkMatrix fInvMatrix;
+ SkFilterQuality fQuality;
+
+ private:
+ friend class SkBitmapController;
+ };
+
+ virtual ~SkBitmapController() {}
+
+ State* requestBitmap(const SkBitmap&, const SkMatrix& inverse, SkFilterQuality,
+ void* storage, size_t storageSize);
+
+ State* requestBitmap(const SkBitmap& bm, const SkMatrix& inverse, SkFilterQuality quality) {
+ return this->requestBitmap(bm, inverse, quality, NULL, 0);
+ }
+
+protected:
+ virtual State* onRequestBitmap(const SkBitmap&, const SkMatrix& inverse, SkFilterQuality,
+ void* storage, size_t storageSize) = 0;
+};
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+class SkDefaultBitmapController : public SkBitmapController {
+public:
+ SkDefaultBitmapController() {}
+
+protected:
+ State* onRequestBitmap(const SkBitmap&, const SkMatrix& inverse, SkFilterQuality,
+ void* storage, size_t storageSize) override;
+};
+
+#endif

Powered by Google App Engine
This is Rietveld 408576698