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

Unified Diff: src/image/SkImage_BitmapBase.cpp

Issue 577063004: Refactoring in SkImage implementations backed by a SkBitmap (Closed) Base URL: https://skia.googlesource.com/skia.git@small_refactor_skimageCodec
Patch Set: Get rid of SkImage_Codec Created 6 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
Index: src/image/SkImage_BitmapBase.cpp
diff --git a/src/image/SkImage_BitmapBase.cpp b/src/image/SkImage_BitmapBase.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c399891dc7b1e0620a7be8dbead4b7eb7e68c7b5
--- /dev/null
+++ b/src/image/SkImage_BitmapBase.cpp
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkImage_BitmapBase.h"
+
+#include "SkCanvas.h"
+
+SkImage_BitmapBase::SkImage_BitmapBase(int width, int height) : INHERITED(width, height) {
+}
+
+SkImage_BitmapBase::SkImage_BitmapBase(const SkBitmap& bitmap) : INHERITED(bitmap.width(), bitmap.height()), fBitmap(bitmap) {
reed1 2014/09/18 13:07:16 nit : 100col limit
Rémi Piotaix 2014/09/18 18:27:15 Done.
+}
+
+SkImage_BitmapBase::~SkImage_BitmapBase() {
reed1 2014/09/18 13:07:16 nit : this is unneeded
Rémi Piotaix 2014/09/18 18:27:15 Done.
+}
+
+const SkBitmap& SkImage_BitmapBase::getBitmap() const {
reed1 2014/09/18 13:07:16 nit : this could be in the header
Rémi Piotaix 2014/09/18 18:27:15 Done.
+ return fBitmap;
+}
+
+bool SkImage_BitmapBase::isOpaque() const {
+ return this->getBitmap().isOpaque();
+}
+
+SkShader* SkImage_BitmapBase::onNewShader(SkShader::TileMode tileX,
+ SkShader::TileMode tileY,
+ const SkMatrix* localMatrix) const
+{
+ return SkShader::CreateBitmapShader(this->getBitmap(), tileX, tileY, localMatrix);
+}
+
+void SkImage_BitmapBase::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPaint* paint) const {
+ canvas->drawBitmap(this->getBitmap(), x, y, paint);
+}
+
+void SkImage_BitmapBase::onDrawRectToRect(SkCanvas* canvas, const SkRect* src, const SkRect& dst,
+ const SkPaint* paint) const {
+ canvas->drawBitmapRectToRect(this->getBitmap(), src, dst, paint);
+}

Powered by Google App Engine
This is Rietveld 408576698