User code (i.e. WebKit) is now responsible for the lifetime scope of the notification client.
With http://trac.webkit.org/changeset/125804 skia-side ref counting has become unnecessary and undesirable.
Review URL: https://codereview.appspot.com/
6443146
git-svn-id: http://skia.googlecode.com/svn/trunk@5169
2bbb7eff-a529-9590-31e7-
b0007b416f81
protected:
virtual void initDeferredCanvas(SkDeferredCanvas& canvas) SK_OVERRIDE {
- canvas.setNotificationClient(SkNEW(SimpleNotificationClient))->unref();
+ canvas.setNotificationClient(&fNotificationClient);
}
virtual void drawInDeferredCanvas(SkDeferredCanvas& canvas) SK_OVERRIDE {
virtual void finalizeDeferredCanvas(SkDeferredCanvas& canvas) SK_OVERRIDE {
canvas.clear(0x0);
+ canvas.setNotificationClient(NULL);
}
private:
typedef DeferredCanvasBench INHERITED;
+ SimpleNotificationClient fNotificationClient;
};
/**
* Specify a NotificationClient to be used by this canvas. Calling
* setNotificationClient will release the previously set
- * NotificationClient, if any. Takes a reference on the notification
- * client.
+ * NotificationClient, if any. SkDeferredCanvas does not take ownership
+ * of the notification client. Therefore user code is resposible
+ * for its destruction. The notification client must be unregistered
+ * by calling setNotificationClient(NULL) if it is destroyed before
+ * this canvas.
* Note: Must be called after the device is set with setDevice.
*
* @param notificationClient interface for dispatching notifications
virtual SkDrawFilter* setDrawFilter(SkDrawFilter* filter) SK_OVERRIDE;
public:
- class NotificationClient : public SkRefCnt {
+ class NotificationClient {
public:
- SK_DECLARE_INST_COUNT(NotificationClient)
-
/**
* Called before executing one or several draw commands, which means
* once per flush when deferred rendering is enabled.
#include "SkPaint.h"
#include "SkShader.h"
-SK_DEFINE_INST_COUNT(SkDeferredCanvas::NotificationClient)
-
enum {
// Deferred canvas will auto-flush when recording reaches this limit
kDefaultMaxRecordingStorageBytes = 64*1024*1024,
fMaxRecordingStorageBytes = kDefaultMaxRecordingStorageBytes;
fNotificationClient = notificationClient;
- SkSafeRef(fNotificationClient);
fImmediateDevice = immediateDevice; // ref counted via fImmediateCanvas
fImmediateCanvas = SkNEW_ARGS(SkCanvas, (fImmediateDevice));
fPipeController.setPlaybackCanvas(fImmediateCanvas);
DeferredDevice::~DeferredDevice() {
this->flushPending();
SkSafeUnref(fImmediateCanvas);
- SkSafeUnref(fNotificationClient);
}
void DeferredDevice::setMaxRecordingStorage(size_t maxStorage) {
void DeferredDevice::setNotificationClient(
SkDeferredCanvas::NotificationClient* notificationClient) {
- SkRefCnt_SafeAssign(fNotificationClient, notificationClient);
+ fNotificationClient = notificationClient;
}
void DeferredDevice::contentsCleared() {