aboutsummaryrefslogtreecommitdiffstats
path: root/include/core
diff options
context:
space:
mode:
authorLucas Crowthers <lucasc@codeaurora.org>2012-12-03 17:21:30 -0500
committerSteve Kondik <shade@chemlab.org>2013-03-04 15:46:32 -0800
commit705eb622415dc3db0d1740ff29aa0fbf4e8aafa5 (patch)
treeb2c036b96b9eb54bc9d35aa46e0cbf893afe86f0 /include/core
parent425325c48d72df437bd734ba0820403204fa79ae (diff)
downloadexternal_skia-705eb622415dc3db0d1740ff29aa0fbf4e8aafa5.zip
external_skia-705eb622415dc3db0d1740ff29aa0fbf4e8aafa5.tar.gz
external_skia-705eb622415dc3db0d1740ff29aa0fbf4e8aafa5.tar.bz2
Skia: Introduce caching of unscaled Bitmaps.
This allows skia to choose whether to use the prescaled bitmap or the unscaled bitmap depending on which would be optimal in the current situation. This commit also introduces two functions necessary for properly resizing Rects when using the non-pre-scaled bitmaps. CRs-fixed: 451681 Change-Id: I36779d8a680a3ced7c28da492e879de02c7e87a5
Diffstat (limited to 'include/core')
-rw-r--r--include/core/SkBitmap.h16
-rw-r--r--include/core/SkCanvas.h5
2 files changed, 21 insertions, 0 deletions
diff --git a/include/core/SkBitmap.h b/include/core/SkBitmap.h
index 2d5fc41..e125924 100644
--- a/include/core/SkBitmap.h
+++ b/include/core/SkBitmap.h
@@ -551,6 +551,17 @@ public:
void flatten(SkFlattenableWriteBuffer&) const;
void unflatten(SkFlattenableReadBuffer&);
+ /** Get the unscaled version of this SkBitmap (may be null; in fact it usually will be)
+ */
+ SkBitmap* unscaledBitmap() const { return fUnscaledBitmap; }
+
+ /** Assign an unscaled bitmap so we can do some transforms with it
+ * TODO do some basic error-checking (make sure URIs match?)
+ */
+ SkBitmap* setUnscaledBitmap(SkBitmap* unscaledBitmap) { return fUnscaledBitmap = unscaledBitmap; }
+
+ void freeUnscaledBitmap();
+
SkDEBUGCODE(void validate() const;)
class Allocator : public SkRefCnt {
@@ -611,6 +622,11 @@ private:
// pixels (e.g. as a gpu texture)
mutable int fRawPixelGenerationID;
+ // Holds shadow copy of this bitmap in cases where it was pre-upscaled, and
+ // we want to retain the original for possible performance improvements in
+ // later transformations
+ mutable SkBitmap* fUnscaledBitmap;
+
enum Flags {
kImageIsOpaque_Flag = 0x01,
kImageIsVolatile_Flag = 0x02,
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h
index 1b9f055..97d6800 100644
--- a/include/core/SkCanvas.h
+++ b/include/core/SkCanvas.h
@@ -894,6 +894,9 @@ public:
void setExternalMatrix(const SkMatrix* = NULL);
+ virtual void drawBitmapScalarRect(const SkBitmap& bitmap, const SkRect* src,
+ const SkRect& dst, const SkPaint* paint = NULL);
+
///////////////////////////////////////////////////////////////////////////
/** After calling saveLayer(), there can be any number of devices that make
@@ -983,6 +986,8 @@ private:
const SkPaint* paint);
void internalDrawBitmapRect(const SkBitmap& bitmap, const SkIRect* src,
const SkRect& dst, const SkPaint* paint);
+ void internalDrawBitmapScalarRect(const SkBitmap& bitmap, const SkRect* src,
+ const SkRect& dst, const SkPaint* paint);
void internalDrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
const SkRect& dst, const SkPaint* paint);
void internalDrawPaint(const SkPaint& paint);