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

Unified Diff: src/utils/SkDeferredCanvas.cpp

Issue 355193006: stop calling SkCanvas::getDevice (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: guard gpu code in no-gpu build Created 6 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
« no previous file with comments | « src/core/SkCanvas.cpp ('k') | tests/DeferredCanvasTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/utils/SkDeferredCanvas.cpp
diff --git a/src/utils/SkDeferredCanvas.cpp b/src/utils/SkDeferredCanvas.cpp
index 641974b1ed1e3d1b3e7cb97184a68b169bc9b9f8..86f80761c0ec346120739b489207b6e7c930f457 100644
--- a/src/utils/SkDeferredCanvas.cpp
+++ b/src/utils/SkDeferredCanvas.cpp
@@ -30,8 +30,8 @@ enum PlaybackMode {
kSilent_PlaybackMode,
};
-static bool shouldDrawImmediately(const SkBitmap* bitmap, const SkPaint* paint,
- size_t bitmapSizeThreshold) {
+static bool should_draw_immediately(const SkBitmap* bitmap, const SkPaint* paint,
+ size_t bitmapSizeThreshold) {
if (bitmap && ((bitmap->getTexture() && !bitmap->isImmutable()) ||
(bitmap->getSize() > bitmapSizeThreshold))) {
return true;
@@ -150,8 +150,6 @@ public:
bool hasPendingCommands();
size_t storageAllocatedForRecording() const;
size_t freeMemoryIfPossible(size_t bytesToFree);
- size_t getBitmapSizeThreshold() const;
- void setBitmapSizeThreshold(size_t sizeThreshold);
void flushPendingCommands(PlaybackMode);
void skipPendingCommands();
void setMaxRecordingStorage(size_t);
@@ -263,7 +261,6 @@ private:
bool fCanDiscardCanvasContents;
size_t fMaxRecordingStorageBytes;
size_t fPreviousStorageAllocated;
- size_t fBitmapSizeThreshold;
};
SkDeferredDevice::SkDeferredDevice(SkSurface* surface) {
@@ -286,7 +283,6 @@ void SkDeferredDevice::init() {
fFreshFrame = true;
fCanDiscardCanvasContents = false;
fPreviousStorageAllocated = 0;
- fBitmapSizeThreshold = kDeferredCanvasBitmapSizeThreshold;
fMaxRecordingStorageBytes = kDefaultMaxRecordingStorageBytes;
fNotificationClient = NULL;
this->beginRecording();
@@ -378,14 +374,6 @@ size_t SkDeferredDevice::freeMemoryIfPossible(size_t bytesToFree) {
return val;
}
-size_t SkDeferredDevice::getBitmapSizeThreshold() const {
- return fBitmapSizeThreshold;
-}
-
-void SkDeferredDevice::setBitmapSizeThreshold(size_t sizeThreshold) {
- fBitmapSizeThreshold = sizeThreshold;
-}
-
size_t SkDeferredDevice::storageAllocatedForRecording() const {
return (fPipeController.storageAllocatedForRecording()
+ fPipeWriter.storageAllocatedForRecording());
@@ -509,11 +497,9 @@ public:
}
}
private:
- void init(SkDeferredCanvas& canvas, const SkBitmap* bitmap, const SkPaint* paint)
- {
- SkDeferredDevice* device = static_cast<SkDeferredDevice*>(canvas.getDevice());
- if (canvas.isDeferredDrawing() && (NULL != device) &&
- shouldDrawImmediately(bitmap, paint, device->getBitmapSizeThreshold())) {
+ void init(SkDeferredCanvas& canvas, const SkBitmap* bitmap, const SkPaint* paint) {
+ if (canvas.isDeferredDrawing() &&
+ should_draw_immediately(bitmap, paint, canvas.getBitmapSizeThreshold())) {
canvas.setDeferredDrawing(false);
fCanvas = &canvas;
} else {
@@ -534,6 +520,7 @@ SkDeferredCanvas::SkDeferredCanvas(SkDeferredDevice* device) : SkCanvas (device)
}
void SkDeferredCanvas::init() {
+ fBitmapSizeThreshold = kDeferredCanvasBitmapSizeThreshold;
fDeferredDrawing = true; // On by default
}
@@ -551,9 +538,7 @@ size_t SkDeferredCanvas::freeMemoryIfPossible(size_t bytesToFree) {
}
void SkDeferredCanvas::setBitmapSizeThreshold(size_t sizeThreshold) {
- SkDeferredDevice* deferredDevice = this->getDeferredDevice();
- SkASSERT(deferredDevice);
- deferredDevice->setBitmapSizeThreshold(sizeThreshold);
+ fBitmapSizeThreshold = sizeThreshold;
}
void SkDeferredCanvas::recordedDrawCommand() {
« no previous file with comments | « src/core/SkCanvas.cpp ('k') | tests/DeferredCanvasTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698