aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-08-16 14:58:06 +0000
committerGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-08-16 14:58:06 +0000
commita22e2117e44efa4298dd0eb6df304a8166c8e9c3 (patch)
tree727738c19786a7c5caf1e09ccfe431b652d8b302
parent1f47f4f7325971dd53991e2bb02da94fa7c6d962 (diff)
Extended Inst counting to find "unknown" leaked object (SkTMaskGamma)
-rw-r--r--include/core/SkImage.h2
-rw-r--r--include/core/SkInstCnt.h15
-rw-r--r--include/core/SkSurface.h2
-rw-r--r--include/utils/SkBoundaryPatch.h5
-rw-r--r--include/utils/SkLayer.h2
-rw-r--r--include/views/SkEventSink.h6
-rw-r--r--include/views/SkView.h8
-rw-r--r--include/views/animated/SkWidgetViews.h4
-rw-r--r--samplecode/SampleApp.cpp2
-rw-r--r--samplecode/SampleApp.h4
-rw-r--r--src/core/SkBitmapHeap.cpp3
-rw-r--r--src/core/SkBitmapHeap.h7
-rw-r--r--src/core/SkMaskGamma.h4
-rw-r--r--src/core/SkPictureFlat.cpp2
-rw-r--r--src/core/SkPictureFlat.h4
-rw-r--r--src/core/SkPtrRecorder.cpp1
-rw-r--r--src/core/SkPtrRecorder.h4
-rw-r--r--src/core/SkScalerContext.cpp16
-rw-r--r--src/image/SkImage.cpp2
-rw-r--r--src/image/SkSurface.cpp2
-rw-r--r--src/utils/SkBoundaryPatch.cpp2
-rw-r--r--src/utils/SkLayer.cpp2
-rw-r--r--src/views/SkEventSink.cpp2
-rw-r--r--src/views/SkView.cpp727
-rw-r--r--src/views/animated/SkWidgetViews.cpp480
-rw-r--r--tests/AAClipTest.cpp3
-rw-r--r--tests/RefDictTest.cpp6
-rw-r--r--tests/Test.cpp2
-rw-r--r--tests/Test.h1
-rw-r--r--tests/UtilsTest.cpp6
30 files changed, 713 insertions, 613 deletions
diff --git a/include/core/SkImage.h b/include/core/SkImage.h
index 8fdd9b1152..89e3181d58 100644
--- a/include/core/SkImage.h
+++ b/include/core/SkImage.h
@@ -37,6 +37,8 @@ class SkColorSpace;
*/
class SkImage : public SkRefCnt {
public:
+ SK_DECLARE_INST_COUNT(SkImage)
+
enum ColorType {
kAlpha_8_ColorType,
kRGB_565_ColorType,
diff --git a/include/core/SkInstCnt.h b/include/core/SkInstCnt.h
index 72227c9a97..9be51ea634 100644
--- a/include/core/SkInstCnt.h
+++ b/include/core/SkInstCnt.h
@@ -27,14 +27,20 @@ extern bool gPrintInstCount;
// The non-root classes just register themselves with their parent
#define SK_DECLARE_INST_COUNT(className) \
SK_DECLARE_INST_COUNT_INTERNAL(className, \
- INHERITED::AddInstChild(CheckInstanceCount);)
+ INHERITED::AddInstChild(CheckInstanceCount);,\
+ /**/)
+
+#define SK_DECLARE_INST_COUNT_TEMPLATE(className) \
+ SK_DECLARE_INST_COUNT_INTERNAL(className, \
+ INHERITED::AddInstChild(CheckInstanceCount);, \
+ typename)
// The root classes registers a function to print out the memory stats when
// the app ends
#define SK_DECLARE_INST_COUNT_ROOT(className) \
- SK_DECLARE_INST_COUNT_INTERNAL(className, atexit(exitPrint);)
+ SK_DECLARE_INST_COUNT_INTERNAL(className, atexit(exitPrint);, /**/)
-#define SK_DECLARE_INST_COUNT_INTERNAL(className, initStep) \
+#define SK_DECLARE_INST_COUNT_INTERNAL(className, initStep, templateType) \
class SkInstanceCountHelper { \
public: \
typedef int (*PFCheckInstCnt)(int level, bool cleanUp); \
@@ -93,7 +99,7 @@ extern bool gPrintInstCount;
return SkInstanceCountHelper::gInstanceCount; \
} \
\
- static void AddInstChild(SkInstanceCountHelper::PFCheckInstCnt \
+ static void AddInstChild(templateType SkInstanceCountHelper::PFCheckInstCnt \
childCheckInstCnt) { \
if (CheckInstanceCount != childCheckInstCnt && \
NULL != SkInstanceCountHelper::gChildren) { \
@@ -109,6 +115,7 @@ extern bool gPrintInstCount;
#else
#define SK_DECLARE_INST_COUNT(className)
+#define SK_DECLARE_INST_COUNT_TEMPLATE(className)
#define SK_DECLARE_INST_COUNT_ROOT(className)
#define SK_DEFINE_INST_COUNT(className)
#endif
diff --git a/include/core/SkSurface.h b/include/core/SkSurface.h
index 0c20d4a229..884045fd39 100644
--- a/include/core/SkSurface.h
+++ b/include/core/SkSurface.h
@@ -26,6 +26,8 @@ class GrRenderTarget;
*/
class SkSurface : public SkRefCnt {
public:
+ SK_DECLARE_INST_COUNT(SkSurface)
+
/**
* Create a new surface, using the specified pixels/rowbytes as its
* backend.
diff --git a/include/utils/SkBoundaryPatch.h b/include/utils/SkBoundaryPatch.h
index 9d4b5ad1ef..7997cf8abe 100644
--- a/include/utils/SkBoundaryPatch.h
+++ b/include/utils/SkBoundaryPatch.h
@@ -13,6 +13,8 @@
class SkBoundary : public SkRefCnt {
public:
+ SK_DECLARE_INST_COUNT(SkBoundary)
+
// These must be 0, 1, 2, 3 for efficiency in the subclass implementations
enum Edge {
kTop = 0,
@@ -22,6 +24,9 @@ public:
};
// Edge index goes clockwise around the boundary, beginning at the "top"
virtual SkPoint eval(Edge, SkScalar unitInterval) = 0;
+
+private:
+ typedef SkRefCnt INHERITED;
};
class SkBoundaryPatch {
diff --git a/include/utils/SkLayer.h b/include/utils/SkLayer.h
index 9cba463462..70fa01bfe7 100644
--- a/include/utils/SkLayer.h
+++ b/include/utils/SkLayer.h
@@ -23,6 +23,8 @@ class SkCanvas;
class SkLayer : public SkRefCnt {
public:
+ SK_DECLARE_INST_COUNT(SkLayer)
+
SkLayer();
SkLayer(const SkLayer&);
virtual ~SkLayer();
diff --git a/include/views/SkEventSink.h b/include/views/SkEventSink.h
index 69981facff..8ef92b408a 100644
--- a/include/views/SkEventSink.h
+++ b/include/views/SkEventSink.h
@@ -21,7 +21,9 @@ struct SkTagList;
*/
class SkEventSink : public SkRefCnt {
public:
- SkEventSink();
+ SK_DECLARE_INST_COUNT(SkEventSink)
+
+ SkEventSink();
virtual ~SkEventSink();
/**
@@ -103,6 +105,8 @@ private:
// for our private link-list
SkEventSink* fNextSink;
+
+ typedef SkRefCnt INHERITED;
};
#endif
diff --git a/include/views/SkView.h b/include/views/SkView.h
index 1241cabd86..de497dd768 100644
--- a/include/views/SkView.h
+++ b/include/views/SkView.h
@@ -254,11 +254,15 @@ public:
*/
class Artist : public SkRefCnt {
public:
+ SK_DECLARE_INST_COUNT(Artist)
+
void draw(SkView*, SkCanvas*);
void inflate(const SkDOM&, const SkDOM::Node*);
protected:
virtual void onDraw(SkView*, SkCanvas*) = 0;
virtual void onInflate(const SkDOM&, const SkDOM::Node*);
+ private:
+ typedef SkRefCnt INHERITED;
};
/** Return the artist attached to this view (or null). The artist's reference
count is not affected.
@@ -278,11 +282,15 @@ public:
*/
class Layout : public SkRefCnt {
public:
+ SK_DECLARE_INST_COUNT(Layout)
+
void layoutChildren(SkView* parent);
void inflate(const SkDOM&, const SkDOM::Node*);
protected:
virtual void onLayoutChildren(SkView* parent) = 0;
virtual void onInflate(const SkDOM&, const SkDOM::Node*);
+ private:
+ typedef SkRefCnt INHERITED;
};
/** Return the layout attached to this view (or null). The layout's reference
diff --git a/include/views/animated/SkWidgetViews.h b/include/views/animated/SkWidgetViews.h
index 295c101cf1..93adeef6b0 100644
--- a/include/views/animated/SkWidgetViews.h
+++ b/include/views/animated/SkWidgetViews.h
@@ -289,6 +289,8 @@ private:
class SkListSource : public SkRefCnt {
public:
+ SK_DECLARE_INST_COUNT(SkListSource)
+
virtual int countFields();
virtual void getFieldName(int index, SkString* field);
/** Return the index of the named field, or -1 if not found */
@@ -300,6 +302,8 @@ public:
virtual bool prepareWidgetEvent(SkEvent*, int rowIndex);
static SkListSource* Factory(const char name[]);
+private:
+ typedef SkRefCnt INHERITED;
};
#endif
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp
index e237ac598f..254d209db1 100644
--- a/samplecode/SampleApp.cpp
+++ b/samplecode/SampleApp.cpp
@@ -38,6 +38,8 @@ class GrContext;
#include "SkGPipe.h"
#include "SamplePipeControllers.h"
+SK_DEFINE_INST_COUNT(SampleWindow::DeviceManager)
+
extern SampleView* CreateSamplePictFileView(const char filename[]);
class PictFileFactory : public SkViewFactory {
diff --git a/samplecode/SampleApp.h b/samplecode/SampleApp.h
index 00353b208a..cb4446f18e 100644
--- a/samplecode/SampleApp.h
+++ b/samplecode/SampleApp.h
@@ -54,6 +54,8 @@ public:
*/
class DeviceManager : public SkRefCnt {
public:
+ SK_DECLARE_INST_COUNT(DeviceManager)
+
virtual void setUpBackend(SampleWindow* win, int msaaSampleCount) = 0;
virtual void tearDownBackend(SampleWindow* win) = 0;
@@ -79,6 +81,8 @@ public:
// return the GrRenderTarget backing gpu devices (NULL if not built with GPU support)
virtual GrRenderTarget* getGrRenderTarget() = 0;
+ private:
+ typedef SkRefCnt INHERITED;
};
SampleWindow(void* hwnd, int argc, char** argv, DeviceManager*);
diff --git a/src/core/SkBitmapHeap.cpp b/src/core/SkBitmapHeap.cpp
index 7caf1a5fd5..1867af21c4 100644
--- a/src/core/SkBitmapHeap.cpp
+++ b/src/core/SkBitmapHeap.cpp
@@ -12,6 +12,9 @@
#include "SkFlattenableBuffers.h"
#include "SkTSearch.h"
+SK_DEFINE_INST_COUNT(SkBitmapHeapReader)
+SK_DEFINE_INST_COUNT(SkBitmapHeap::ExternalStorage)
+
SkBitmapHeapEntry::SkBitmapHeapEntry()
: fSlot(-1)
, fRefCount(0)
diff --git a/src/core/SkBitmapHeap.h b/src/core/SkBitmapHeap.h
index a16727b640..61e1dd905d 100644
--- a/src/core/SkBitmapHeap.h
+++ b/src/core/SkBitmapHeap.h
@@ -52,6 +52,8 @@ private:
class SkBitmapHeapReader : public SkRefCnt {
public:
+ SK_DECLARE_INST_COUNT(SkBitmapHeapReader)
+
SkBitmapHeapReader() : INHERITED() {}
virtual SkBitmap* getBitmap(int32_t slot) const = 0;
virtual void releaseRef(int32_t slot) = 0;
@@ -67,7 +69,12 @@ class SkBitmapHeap : public SkBitmapHeapReader {
public:
class ExternalStorage : public SkRefCnt {
public:
+ SK_DECLARE_INST_COUNT(ExternalStorage)
+
virtual bool insert(const SkBitmap& bitmap, int32_t slot) = 0;
+
+ private:
+ typedef SkRefCnt INHERITED;
};
static const int32_t UNLIMITED_SIZE = -1;
diff --git a/src/core/SkMaskGamma.h b/src/core/SkMaskGamma.h
index 7498f64d87..f3fab033fc 100644
--- a/src/core/SkMaskGamma.h
+++ b/src/core/SkMaskGamma.h
@@ -105,6 +105,8 @@ void SkTMaskGamma_build_correcting_lut(uint8_t table[256], U8CPU srcI, SkScalar
*/
template <int R_LUM_BITS, int G_LUM_BITS, int B_LUM_BITS> class SkTMaskGamma : public SkRefCnt {
public:
+ SK_DECLARE_INST_COUNT_TEMPLATE(SkTMaskGamma)
+
/**
* Creates tables to convert linear alpha values to gamma correcting alpha
* values.
@@ -151,6 +153,8 @@ private:
: (R_LUM_BITS > G_LUM_BITS ? R_LUM_BITS : G_LUM_BITS)
};
uint8_t fGammaTables[1 << kLuminanceBits_Max][256];
+
+ typedef SkRefCnt INHERITED;
};
/**
diff --git a/src/core/SkPictureFlat.cpp b/src/core/SkPictureFlat.cpp
index 87664ca306..c66689fa79 100644
--- a/src/core/SkPictureFlat.cpp
+++ b/src/core/SkPictureFlat.cpp
@@ -16,6 +16,8 @@
#include "SkTypeface.h"
#include "SkXfermode.h"
+SK_DEFINE_INST_COUNT(SkFlatController)
+
///////////////////////////////////////////////////////////////////////////////
SkTypefacePlayback::SkTypefacePlayback() : fCount(0), fArray(NULL) {}
diff --git a/src/core/SkPictureFlat.h b/src/core/SkPictureFlat.h
index 53fd69ac6f..b4f0625631 100644
--- a/src/core/SkPictureFlat.h
+++ b/src/core/SkPictureFlat.h
@@ -158,6 +158,8 @@ class SkFlatData;
class SkFlatController : public SkRefCnt {
public:
+ SK_DECLARE_INST_COUNT(SkFlatController)
+
SkFlatController();
virtual ~SkFlatController();
/**
@@ -244,6 +246,8 @@ private:
SkTypefacePlayback* fTypefacePlayback;
SkNamedFactorySet* fFactorySet;
uint32_t fWriteBufferFlags;
+
+ typedef SkRefCnt INHERITED;
};
class SkFlatData {
diff --git a/src/core/SkPtrRecorder.cpp b/src/core/SkPtrRecorder.cpp
index 169944a98a..6ee58f886a 100644
--- a/src/core/SkPtrRecorder.cpp
+++ b/src/core/SkPtrRecorder.cpp
@@ -9,6 +9,7 @@
#include "SkTSearch.h"
SK_DEFINE_INST_COUNT(SkPtrSet)
+SK_DEFINE_INST_COUNT(SkNamedFactorySet)
void SkPtrSet::reset() {
Pair* p = fList.begin();
diff --git a/src/core/SkPtrRecorder.h b/src/core/SkPtrRecorder.h
index 8a48325298..c4c0bd8832 100644
--- a/src/core/SkPtrRecorder.h
+++ b/src/core/SkPtrRecorder.h
@@ -123,6 +123,8 @@ class SkFactorySet : public SkTPtrSet<SkFlattenable::Factory> {};
*/
class SkNamedFactorySet : public SkRefCnt {
public:
+ SK_DECLARE_INST_COUNT(SkNamedFactorySet)
+
SkNamedFactorySet();
/**
@@ -142,6 +144,8 @@ private:
int fNextAddedFactory;
SkFactorySet fFactorySet;
SkTDArray<const char*> fNames;
+
+ typedef SkRefCnt INHERITED;
};
#endif
diff --git a/src/core/SkScalerContext.cpp b/src/core/SkScalerContext.cpp
index 3fbcf3bf5b..e2725ffdfb 100644
--- a/src/core/SkScalerContext.cpp
+++ b/src/core/SkScalerContext.cpp
@@ -22,6 +22,8 @@
#include "SkStroke.h"
#include "SkThread.h"
+SK_DEFINE_INST_COUNT(SkMaskGamma)
+
#define ComputeBWRowBytes(width) (((unsigned)(width) + 7) >> 3)
void SkGlyph::toMask(SkMask* mask) const {
@@ -301,9 +303,9 @@ void SkScalerContext::getMetrics(SkGlyph* glyph) {
}
}
- if (SkMask::kARGB32_Format != glyph->fMaskFormat) {
- glyph->fMaskFormat = fRec.fMaskFormat;
- }
+ if (SkMask::kARGB32_Format != glyph->fMaskFormat) {
+ glyph->fMaskFormat = fRec.fMaskFormat;
+ }
if (fMaskFilter) {
SkMask src, dst;
@@ -764,10 +766,10 @@ protected:
extern SkScalerContext* SkCreateColorScalerContext(const SkDescriptor* desc);
SkScalerContext* SkScalerContext::Create(const SkDescriptor* desc) {
- SkScalerContext* c = NULL; //SkCreateColorScalerContext(desc);
- if (NULL == c) {
- c = SkFontHost::CreateScalerContext(desc);
- }
+ SkScalerContext* c = NULL; //SkCreateColorScalerContext(desc);
+ if (NULL == c) {
+ c = SkFontHost::CreateScalerContext(desc);
+ }
if (NULL == c) {
c = SkNEW_ARGS(SkScalerContext_Empty, (desc));
}
diff --git a/src/image/SkImage.cpp b/src/image/SkImage.cpp
index a8693e57d8..b6fc4899da 100644
--- a/src/image/SkImage.cpp
+++ b/src/image/SkImage.cpp
@@ -10,6 +10,8 @@
#include "SkBitmap.h"
#include "SkCanvas.h"
+SK_DEFINE_INST_COUNT(SkImage)
+
static SkImage_Base* asIB(SkImage* image) {
return static_cast<SkImage_Base*>(image);
}
diff --git a/src/image/SkSurface.cpp b/src/image/SkSurface.cpp
index e7695c9df8..299a8d22e0 100644
--- a/src/image/SkSurface.cpp
+++ b/src/image/SkSurface.cpp
@@ -9,6 +9,8 @@
#include "SkImagePriv.h"
#include "SkCanvas.h"
+SK_DEFINE_INST_COUNT(SkSurface)
+
///////////////////////////////////////////////////////////////////////////////
SkSurface_Base::SkSurface_Base(int width, int height) : INHERITED(width, height) {
diff --git a/src/utils/SkBoundaryPatch.cpp b/src/utils/SkBoundaryPatch.cpp
index 37f59b4596..c305c8b7f5 100644
--- a/src/utils/SkBoundaryPatch.cpp
+++ b/src/utils/SkBoundaryPatch.cpp
@@ -7,6 +7,8 @@
*/
#include "SkBoundaryPatch.h"
+SK_DEFINE_INST_COUNT(SkBoundary)
+
SkBoundaryPatch::SkBoundaryPatch() : fBoundary(NULL) {}
SkBoundaryPatch::~SkBoundaryPatch() {
diff --git a/src/utils/SkLayer.cpp b/src/utils/SkLayer.cpp
index a311cef3b5..54f1840f6f 100644
--- a/src/utils/SkLayer.cpp
+++ b/src/utils/SkLayer.cpp
@@ -15,6 +15,8 @@
static int gLayerAllocCount;
#endif
+SK_DEFINE_INST_COUNT(SkLayer)
+
///////////////////////////////////////////////////////////////////////////////
SkLayer::SkLayer() {
diff --git a/src/views/SkEventSink.cpp b/src/views/SkEventSink.cpp
index 20d8cdfc5b..8f39156c51 100644
--- a/src/views/SkEventSink.cpp
+++ b/src/views/SkEventSink.cpp
@@ -14,6 +14,8 @@
#include "SkThread.h"
#include "SkTime.h"
+SK_DEFINE_INST_COUNT(SkEventSink)
+
class SkEventSink_Globals {
public:
SkEventSink_Globals() {
diff --git a/src/views/SkView.cpp b/src/views/SkView.cpp
index 855d6a98e8..dae47d6f7c 100644
--- a/src/views/SkView.cpp
+++ b/src/views/SkView.cpp
@@ -8,52 +8,55 @@
#include "SkView.h"
#include "SkCanvas.h"
+SK_DEFINE_INST_COUNT(SkView::Artist)
+SK_DEFINE_INST_COUNT(SkView::Layout)
+
////////////////////////////////////////////////////////////////////////
SkView::SkView(uint32_t flags) : fFlags(SkToU8(flags))
{
- fWidth = fHeight = 0;
- fLoc.set(0, 0);
- fParent = fFirstChild = fNextSibling = fPrevSibling = NULL;
+ fWidth = fHeight = 0;
+ fLoc.set(0, 0);
+ fParent = fFirstChild = fNextSibling = fPrevSibling = NULL;
fMatrix.setIdentity();
- fContainsFocus = 0;
+ fContainsFocus = 0;
}
SkView::~SkView()
{
- this->detachAllChildren();
+ this->detachAllChildren();
}
void SkView::setFlags(uint32_t flags)
{
- SkASSERT((flags & ~kAllFlagMasks) == 0);
+ SkASSERT((flags & ~kAllFlagMasks) == 0);
- uint32_t diff = fFlags ^ flags;
+ uint32_t diff = fFlags ^ flags;
- if (diff & kVisible_Mask)
- this->inval(NULL);
+ if (diff & kVisible_Mask)
+ this->inval(NULL);
- fFlags = SkToU8(flags);
+ fFlags = SkToU8(flags);
- if (diff & kVisible_Mask)
- {
- this->inval(NULL);
- }
+ if (diff & kVisible_Mask)
+ {
+ this->inval(NULL);
+ }
}
void SkView::setVisibleP(bool pred)
{
- this->setFlags(SkSetClearShift(fFlags, pred, kVisible_Shift));
+ this->setFlags(SkSetClearShift(fFlags, pred, kVisible_Shift));
}
void SkView::setEnabledP(bool pred)
{
- this->setFlags(SkSetClearShift(fFlags, pred, kEnabled_Shift));
+ this->setFlags(SkSetClearShift(fFlags, pred, kEnabled_Shift));
}
void SkView::setFocusableP(bool pred)
{
- this->setFlags(SkSetClearShift(fFlags, pred, kFocusable_Shift));
+ this->setFlags(SkSetClearShift(fFlags, pred, kFocusable_Shift));
}
void SkView::setClipToBounds(bool pred) {
@@ -62,34 +65,34 @@ void SkView::setClipToBounds(bool pred) {
void SkView::setSize(SkScalar width, SkScalar height)
{
- width = SkMaxScalar(0, width);
- height = SkMaxScalar(0, height);
+ width = SkMaxScalar(0, width);
+ height = SkMaxScalar(0, height);
- if (fWidth != width || fHeight != height)
- {
- this->inval(NULL);
- fWidth = width;
- fHeight = height;
- this->inval(NULL);
- this->onSizeChange();
- this->invokeLayout();
- }
+ if (fWidth != width || fHeight != height)
+ {
+ this->inval(NULL);
+ fWidth = width;
+ fHeight = height;
+ this->inval(NULL);
+ this->onSizeChange();
+ this->invokeLayout();
+ }
}
void SkView::setLoc(SkScalar x, SkScalar y)
{
- if (fLoc.fX != x || fLoc.fY != y)
- {
- this->inval(NULL);
- fLoc.set(x, y);
+ if (fLoc.fX != x || fLoc.fY != y)
+ {
+ this->inval(NULL);
+ fLoc.set(x, y);
this->inval(NULL);
- }
+ }
}
void SkView::offset(SkScalar dx, SkScalar dy)
{
- if (dx || dy)
- this->setLoc(fLoc.fX + dx, fLoc.fY + dy);
+ if (dx || dy)
+ this->setLoc(fLoc.fX + dx, fLoc.fY + dy);
}
void SkView::setLocalMatrix(const SkMatrix& matrix)
@@ -101,16 +104,16 @@ void SkView::setLocalMatrix(const SkMatrix& matrix)
void SkView::draw(SkCanvas* canvas)
{
- if (fWidth && fHeight && this->isVisible())
- {
- SkRect r;
- r.set(fLoc.fX, fLoc.fY, fLoc.fX + fWidth, fLoc.fY + fHeight);
- if (this->isClipToBounds() &&
+ if (fWidth && fHeight && this->isVisible())
+ {
+ SkRect r;
+ r.set(fLoc.fX, fLoc.fY, fLoc.fX + fWidth, fLoc.fY + fHeight);
+ if (this->isClipToBounds() &&
canvas->quickReject(r, SkCanvas::kBW_EdgeType)) {
return;
}
- SkAutoCanvasRestore as(canvas, true);
+ SkAutoCanvasRestore as(canvas, true);
if (this->isClipToBounds()) {
canvas->clipRect(r);
@@ -124,30 +127,30 @@ void SkView::draw(SkCanvas* canvas)
}
int sc = canvas->save();
- this->onDraw(canvas);
+ this->onDraw(canvas);
canvas->restoreToCount(sc);
if (fParent) {
fParent->afterChild(this, canvas);
}
- B2FIter iter(this);
- SkView* child;
+ B2FIter iter(this);
+ SkView* child;
SkCanvas* childCanvas = this->beforeChildren(canvas);
- while ((child = iter.next()) != NULL)
- child->draw(childCanvas);
+ while ((child = iter.next()) != NULL)
+ child->draw(childCanvas);
this->afterChildren(canvas);
- }
+ }
}
void SkView::inval(SkRect* rect) {
- SkView* view = this;
+ SkView* view = this;
SkRect storage;
- for (;;) {
+ for (;;) {
if (!view->isVisible()) {
return;
}
@@ -164,7 +167,7 @@ void SkView::inval(SkRect* rect) {
return;
}
- SkView* parent = view->fParent;
+ SkView* parent = view->fParent;
if (parent == NULL) {
return;
}
@@ -173,139 +176,139 @@ void SkView::inval(SkRect* rect) {
rect->offset(view->fLoc.fX, view->fLoc.fY);
}
view = parent;
- }
+ }
}
////////////////////////////////////////////////////////////////////////////
bool SkView::setFocusView(SkView* fv)
{
- SkView* view = this;
-
- do {
- if (view->onSetFocusView(fv))
- return true;
- } while ((view = view->fParent) != NULL);
- return false;
+ SkView* view = this;
+
+ do {
+ if (view->onSetFocusView(fv))
+ return true;
+ } while ((view = view->fParent) != NULL);
+ return false;
}
SkView* SkView::getFocusView() const
{
- SkView* focus = NULL;
- const SkView* view = this;
- do {
- if (view->onGetFocusView(&focus))
- break;
- } while ((view = view->fParent) != NULL);
- return focus;
+ SkView* focus = NULL;
+ const SkView* view = this;
+ do {
+ if (view->onGetFocusView(&focus))
+ break;
+ } while ((view = view->fParent) != NULL);
+ return focus;
}
bool SkView::hasFocus() const
{
- return this == this->getFocusView();
+ return this == this->getFocusView();
}
bool SkView::acceptFocus()
{
- return this->isFocusable() && this->setFocusView(this);
+ return this->isFocusable() && this->setFocusView(this);
}
/*
- Try to give focus to this view, or its children
+ Try to give focus to this view, or its children
*/
SkView* SkView::acceptFocus(FocusDirection dir)
{
- if (dir == kNext_FocusDirection)
- {
- if (this->acceptFocus())
- return this;
+ if (dir == kNext_FocusDirection)
+ {
+ if (this->acceptFocus())
+ return this;
- B2FIter iter(this);
- SkView* child, *focus;
- while ((child = iter.next()) != NULL)
- if ((focus = child->acceptFocus(dir)) != NULL)
- return focus;
- }
- else // prev
- {
- F2BIter iter(this);
- SkView* child, *focus;
- while ((child = iter.next()) != NULL)
- if ((focus = child->acceptFocus(dir)) != NULL)
- return focus;
+ B2FIter iter(this);
+ SkView* child, *focus;
+ while ((child = iter.next()) != NULL)
+ if ((focus = child->acceptFocus(dir)) != NULL)
+ return focus;
+ }
+ else // prev
+ {
+ F2BIter iter(this);
+ SkView* child, *focus;
+ while ((child = iter.next()) != NULL)
+ if ((focus = child->acceptFocus(dir)) != NULL)
+ return focus;
- if (this->acceptFocus())
- return this;
- }
+ if (this->acceptFocus())
+ return this;
+ }
- return NULL;
+ return NULL;
}
SkView* SkView::moveFocus(FocusDirection dir)
{
- SkView* focus = this->getFocusView();
-
- if (focus == NULL)
- { // start with the root
- focus = this;
- while (focus->fParent)
- focus = focus->fParent;
- }
-
- SkView* child, *parent;
-
- if (dir == kNext_FocusDirection)
- {
- parent = focus;
- child = focus->fFirstChild;
- if (child)
- goto FIRST_CHILD;
- else
- goto NEXT_SIB;
-
- do {
- while (child != parent->fFirstChild)
- {
- FIRST_CHILD:
- if ((focus = child->acceptFocus(dir)) != NULL)
- return focus;
- child = child->fNextSibling;
- }
- NEXT_SIB:
- child = parent->fNextSibling;
- parent = parent->fParent;
- } while (parent != NULL);
- }
- else // prevfocus
- {
- parent = focus->fParent;
- if (parent == NULL) // we're the root
- return focus->acceptFocus(dir);
- else
- {
- child = focus;
- while (parent)
- {
- while (child != parent->fFirstChild)
- {
- child = child->fPrevSibling;
- if ((focus = child->acceptFocus(dir)) != NULL)
- return focus;
- }
- if (parent->acceptFocus())
- return parent;
-
- child = parent;
- parent = parent->fParent;
- }
- }
- }
- return NULL;
+ SkView* focus = this->getFocusView();
+
+ if (focus == NULL)
+ { // start with the root
+ focus = this;
+ while (focus->fParent)
+ focus = focus->fParent;
+ }
+
+ SkView* child, *parent;
+
+ if (dir == kNext_FocusDirection)
+ {
+ parent = focus;
+ child = focus->fFirstChild;
+ if (child)
+ goto FIRST_CHILD;
+ else
+ goto NEXT_SIB;
+
+ do {
+ while (child != parent->fFirstChild)
+ {
+ FIRST_CHILD:
+ if ((focus = child->acceptFocus(dir)) != NULL)
+ return focus;
+ child = child->fNextSibling;
+ }
+ NEXT_SIB:
+ child = parent->fNextSibling;
+ parent = parent->fParent;
+ } while (parent != NULL);
+ }
+ else // prevfocus
+ {
+ parent = focus->fParent;
+ if (parent == NULL) // we're the root
+ return focus->acceptFocus(dir);
+ else
+ {
+ child = focus;
+ while (parent)
+ {
+ while (child != parent->fFirstChild)
+ {
+ child = child->fPrevSibling;
+ if ((focus = child->acceptFocus(dir)) != NULL)
+ return focus;
+ }
+ if (parent->acceptFocus())
+ return parent;
+
+ child = parent;
+ parent = parent->fParent;
+ }
+ }
+ }
+ return NULL;
}
void SkView::onFocusChange(bool gainFocusP)
{
- this->inval(NULL);
+ this->inval(NULL);
}
////////////////////////////////////////////////////////////////////////////
@@ -321,52 +324,52 @@ SkView::Click::Click(SkView* target)
SkView::Click::~Click()
{
- this->resetType();
+ this->resetType();
}
void SkView::Click::resetType()
{
- if (fWeOwnTheType)
- {
- sk_free(fType);
- fWeOwnTheType = false;
- }
- fType = NULL;
+ if (fWeOwnTheType)
+ {
+ sk_free(fType);
+ fWeOwnTheType = false;
+ }
+ fType = NULL;
}
bool SkView::Click::isType(const char type[]) const
{
- const char* t = fType;
+ const char* t = fType;
- if (type == t)
- return true;
+ if (type == t)
+ return true;
- if (type == NULL)
- type = "";
- if (t == NULL)
- t = "";
- return !strcmp(t, type);
+ if (type == NULL)
+ type = "";
+ if (t == NULL)
+ t = "";
+ return !strcmp(t, type);
}
void SkView::Click::setType(const char type[])
{
- this->resetType();
- fType = (char*)type;
+ this->resetType();
+ fType = (char*)type;
}
void SkView::Click::copyType(const char type[])
{
- if (fType != type)
- {
- this->resetType();
- if (type)
- {
- size_t len = strlen(type) + 1;
- fType = (char*)sk_malloc_throw(len);
- memcpy(fType, type, len);
- fWeOwnTheType = true;
- }
- }
+ if (fType != type)
+ {
+ this->resetType();
+ if (type)
+ {
+ size_t len = strlen(type) + 1;
+ fType = (char*)sk_malloc_throw(len);
+ memcpy(fType, type, len);
+ fWeOwnTheType = true;
+ }
+ }
}
SkView::Click* SkView::findClickHandler(SkScalar x, SkScalar y)
@@ -469,18 +472,18 @@ void SkView::DoClickUp(Click* click, int x, int y)
//////////////////////////////////////////////////////////////////////
void SkView::invokeLayout() {
- SkView::Layout* layout = this->getLayout();
+ SkView::Layout* layout = this->getLayout();
- if (layout) {
- layout->layoutChildren(this);
+ if (layout) {
+ layout->layoutChildren(this);
}
}
void SkView::onDraw(SkCanvas* canvas) {
- Artist* artist = this->getArtist();
+ Artist* artist = this->getArtist();
- if (artist) {
- artist->draw(this, canvas);
+ if (artist) {
+ artist->draw(this, canvas);
}
}
@@ -491,23 +494,23 @@ bool SkView::onSendClickToChildren(SkScalar x, SkScalar y) {
}
SkView::Click* SkView::onFindClickHandler(SkScalar x, SkScalar y) {
- return NULL;
+ return NULL;
}
bool SkView::onClick(Click*) {
- return false;
+ return false;
}
bool SkView::handleInval(const SkRect*) {
- return false;
+ return false;
}
//////////////////////////////////////////////////////////////////////
void SkView::getLocalBounds(SkRect* bounds) const
{
- if (bounds)
- bounds->set(0, 0, fWidth, fHeight);
+ if (bounds)
+ bounds->set(0, 0, fWidth, fHeight);
}
//////////////////////////////////////////////////////////////////////
@@ -515,110 +518,110 @@ void SkView::getLocalBounds(SkRect* bounds) const
void SkView::detachFromParent_NoLayout()
{
- if (fParent == NULL)
- return;
+ if (fParent == NULL)
+ return;
- if (fContainsFocus)
- (void)this->setFocusView(NULL);
+ if (fContainsFocus)
+ (void)this->setFocusView(NULL);
- this->inval(NULL);
+ this->inval(NULL);
- SkView* next = NULL;
+ SkView* next = NULL;
- if (fNextSibling != this) // do we have any siblings
- {
- fNextSibling->fPrevSibling = fPrevSibling;
- fPrevSibling->fNextSibling = fNextSibling;
- next = fNextSibling;
- }
+ if (fNextSibling != this) // do we have any siblings
+ {
+ fNextSibling->fPrevSibling = fPrevSibling;
+ fPrevSibling->fNextSibling = fNextSibling;
+ next = fNextSibling;
+ }
- if (fParent->fFirstChild == this)
- fParent->fFirstChild = next;
+ if (fParent->fFirstChild == this)
+ fParent->fFirstChild = next;
- fParent = fNextSibling = fPrevSibling = NULL;
+ fParent = fNextSibling = fPrevSibling = NULL;
- this->unref();
+ this->unref();
}
void SkView::detachFromParent()
{
- SkView* parent = fParent;
+ SkView* parent = fParent;
- if (parent)
- {
- this->detachFromParent_NoLayout();
- parent->invokeLayout();
- }
+ if (parent)
+ {
+ this->detachFromParent_NoLayout();
+ parent->invokeLayout();
+ }
}
SkView* SkView::attachChildToBack(SkView* child)
{
- SkASSERT(child != this);
+ SkASSERT(child != this);
- if (child == NULL || fFirstChild == child)
- goto DONE;
+ if (child == NULL || fFirstChild == child)
+ goto DONE;
- child->ref();
- child->detachFromParent_NoLayout();
+ child->ref();
+ child->detachFromParent_NoLayout();
- if (fFirstChild == NULL)
- {
- child->fNextSibling = child;
- child->fPrevSibling = child;
- }
- else
- {
- child->fNextSibling = fFirstChild;
- child->fPrevSibling = fFirstChild->fPrevSibling;
- fFirstChild->fPrevSibling->fNextSibling = child;
- fFirstChild->fPrevSibling = child;
- }
+ if (fFirstChild == NULL)
+ {
+ child->fNextSibling = child;
+ child->fPrevSibling = child;
+ }
+ else
+ {
+ child->fNextSibling = fFirstChild;
+ child->fPrevSibling = fFirstChild->fPrevSibling;
+ fFirstChild->fPrevSibling->fNextSibling = child;
+ fFirstChild->fPrevSibling = child;
+ }
- fFirstChild = child;
- child->fParent = this;
- child->inval(NULL);
+ fFirstChild = child;
+ child->fParent = this;
+ child->inval(NULL);
- this->invokeLayout();
+ this->invokeLayout();
DONE:
- return child;
+ return child;
}
SkView* SkView::attachChildToFront(SkView* child)
{
- SkASSERT(child != this);
+ SkASSERT(child != this);
- if (child == NULL || (fFirstChild && fFirstChild->fPrevSibling == child))
- goto DONE;
+ if (child == NULL || (fFirstChild && fFirstChild->fPrevSibling == child))
+ goto DONE;
- child->ref();
- child->detachFromParent_NoLayout();
+ child->ref();
+ child->detachFromParent_NoLayout();
- if (fFirstChild == NULL)
- {
- fFirstChild = child;
- child->fNextSibling = child;
- child->fPrevSibling = child;
- }
- else
- {
- child->fNextSibling = fFirstChild;
- child->fPrevSibling = fFirstChild->fPrevSibling;
- fFirstChild->fPrevSibling->fNextSibling = child;
- fFirstChild->fPrevSibling = child;
- }
+ if (fFirstChild == NULL)
+ {
+ fFirstChild = child;
+ child->fNextSibling = child;
+ child->fPrevSibling = child;
+ }
+ else
+ {
+ child->fNextSibling = fFirstChild;
+ child->fPrevSibling = fFirstChild->fPrevSibling;
+ fFirstChild->fPrevSibling->fNextSibling = child;
+ fFirstChild->fPrevSibling = child;
+ }
- child->fParent = this;
- child->inval(NULL);
+ child->fParent = this;
+ child->inval(NULL);
- this->invokeLayout();
+ this->invokeLayout();
DONE:
- return child;
+ return child;
}
void SkView::detachAllChildren()
{
- while (fFirstChild)
- fFirstChild->detachFromParent_NoLayout();
+ while (fFirstChild)
+ fFirstChild->detachFromParent_NoLayout();
}
void SkView::localToGlobal(SkMatrix* matrix) const
@@ -655,84 +658,84 @@ bool SkView::globalToLocal(SkScalar x, SkScalar y, SkPoint* local) const
//////////////////////////////////////////////////////////////////
/* Even if the subclass overrides onInflate, they should always be
- sure to call the inherited method, so that we get called.
+ sure to call the inherited method, so that we get called.
*/
void SkView::onInflate(const SkDOM& dom, const SkDOM::Node* node)
{
- SkScalar x, y;
+ SkScalar x, y;
- x = this->locX();
- y = this->locY();
- (void)dom.findScalar(node, "x", &x);
- (void)dom.findScalar(node, "y", &y);
- this->setLoc(x, y);
+ x = this->locX();
+ y = this->locY();
+ (void)dom.findScalar(node, "x", &x);
+ (void)dom.findScalar(node, "y", &y);
+ this->setLoc(x, y);
- x = this->width();
- y = this->height();
- (void)dom.findScalar(node, "width", &x);
- (void)dom.findScalar(node, "height", &y);
- this->setSize(x, y);
+ x = this->width();
+ y = this->height();
+ (void)dom.findScalar(node, "width", &x);
+ (void)dom.findScalar(node, "height", &y);
+ this->setSize(x, y);
- // inflate the flags
+ // inflate the flags
- static const char* gFlagNames[] = {
- "visible", "enabled", "focusable", "flexH", "flexV"
- };
- SkASSERT(SK_ARRAY_COUNT(gFlagNames) == kFlagShiftCount);
+ static const char* gFlagNames[] = {
+ "visible", "enabled", "focusable", "flexH", "flexV"
+ };
+ SkASSERT(SK_ARRAY_COUNT(gFlagNames) == kFlagShiftCount);
- bool b;
- uint32_t flags = this->getFlags();
- for (unsigned i = 0; i < SK_ARRAY_COUNT(gFlagNames); i++)
- if (dom.findBool(node, gFlagNames[i], &b))
- flags = SkSetClearShift(flags, b, i);
- this->setFlags(flags);
+ bool b;
+ uint32_t flags = this->getFlags();
+ for (unsigned i = 0; i < SK_ARRAY_COUNT(gFlagNames); i++)
+ if (dom.findBool(node, gFlagNames[i], &b))
+ flags = SkSetClearShift(flags, b, i);
+ this->setFlags(flags);
}
void SkView::inflate(const SkDOM& dom, const SkDOM::Node* node)
{
- this->onInflate(dom, node);
+ this->onInflate(dom, node);
}
void SkView::onPostInflate(const SkTDict<SkView*>&)
{
- // override in subclass as needed
+ // override in subclass as needed
}
void SkView::postInflate(const SkTDict<SkView*>& dict)
{
- this->onPostInflate(dict);
+ this->onPostInflate(dict);
- B2FIter iter(this);
- SkView* child;
- while ((child = iter.next()) != NULL)
- child->postInflate(dict);
+ B2FIter iter(this);
+ SkView* child;
+ while ((child = iter.next()) != NULL)
+ child->postInflate(dict);
}
//////////////////////////////////////////////////////////////////
SkView* SkView::sendEventToParents(const SkEvent& evt)
{
- SkView* parent = fParent;
+ SkView* parent = fParent;
- while (parent)
- {
- if (parent->doEvent(evt))
- return parent;
- parent = parent->fParent;
- }
- return NULL;
+ while (parent)
+ {
+ if (parent->doEvent(evt))
+ return parent;
+ parent = parent->fParent;
+ }
+ return NULL;
}
SkView* SkView::sendQueryToParents(SkEvent* evt) {
- SkView* parent = fParent;
+ SkView* parent = fParent;
- while (parent) {
- if (parent->doQuery(evt)) {
- return parent;
+ while (parent) {
+ if (parent->doQuery(evt)) {
+ return parent;
}
- parent = parent->fParent;
- }
- return NULL;
+ parent = parent->fParent;
+ }
+ return NULL;
}
//////////////////////////////////////////////////////////////////
@@ -740,42 +743,42 @@ SkView* SkView::sendQueryToParents(SkEvent* evt) {
SkView::F2BIter::F2BIter(const SkView* parent)
{
- fFirstChild = parent ? parent->fFirstChild : NULL;
- fChild = fFirstChild ? fFirstChild->fPrevSibling : NULL;
+ fFirstChild = parent ? parent->fFirstChild : NULL;
+ fChild = fFirstChild ? fFirstChild->fPrevSibling : NULL;
}
SkView* SkView::F2BIter::next()
{
- SkView* curr = fChild;
+ SkView* curr = fChild;
- if (fChild)
- {
- if (fChild == fFirstChild)
- fChild = NULL;
- else
- fChild = fChild->fPrevSibling;
- }
- return curr;
+ if (fChild)
+ {
+ if (fChild == fFirstChild)
+ fChild = NULL;
+ else
+ fChild = fChild->fPrevSibling;
+ }
+ return curr;
}
SkView::B2FIter::B2FIter(const SkView* parent)
{
- fFirstChild = parent ? parent->fFirstChild : NULL;
- fChild = fFirstChild;
+ fFirstChild = parent ? parent->fFirstChild : NULL;
+ fChild = fFirstChild;
}
SkView* SkView::B2FIter::next()
{
- SkView* curr = fChild;
+ SkView* curr = fChild;
- if (fChild)
- {
- SkView* next = fChild->fNextSibling;
- if (next == fFirstChild)
- next = NULL;
- fChild = next;
- }
- return curr;
+ if (fChild)
+ {
+ SkView* next = fChild->fNextSibling;
+ if (next == fFirstChild)
+ next = NULL;
+ fChild = next;
+ }
+ return curr;
}
//////////////////////////////////////////////////////////////////
@@ -785,58 +788,58 @@ SkView* SkView::B2FIter::next()
static inline void show_if_nonzero(const char name[], SkScalar value)
{
- if (value)
- SkDebugf("%s=\"%g\"", name, value/65536.);
+ if (value)
+ SkDebugf("%s=\"%g\"", name, value/65536.);
}
static void tab(int level)
{
- for (int i = 0; i < level; i++)
- SkDebugf(" ");
+ for (int i = 0; i < level; i++)
+ SkDebugf(" ");
}
static void dumpview(const SkView* view, int level, bool recurse)
{
- tab(level);
-
- SkDebugf("<view");
- show_if_nonzero(" x", view->locX());
- show_if_nonzero(" y", view->locY());
- show_if_nonzero(" width", view->width());
- show_if_nonzero(" height", view->height());
-
- if (recurse)
- {
- SkView::B2FIter iter(view);
- SkView* child;
- bool noChildren = true;
-
- while ((child = iter.next()) != NULL)
- {
- if (noChildren)
- SkDebugf(">\n");
- noChildren = false;
- dumpview(child, level + 1, true);
- }
-
- if (!noChildren)
- {
- tab(level);
- SkDebugf("</view>\n");
- }
- else
- goto ONELINER;
- }
- else
- {
- ONELINER:
- SkDebugf(" />\n");
- }
+ tab(level);
+
+ SkDebugf("<view");
+ show_if_nonzero(" x", view->locX());
+ show_if_nonzero(" y", view->locY());
+ show_if_nonzero(" width", view->width());
+ show_if_nonzero(" height", view->height());
+
+ if (recurse)
+ {
+ SkView::B2FIter iter(view);
+ SkView* child;
+ bool noChildren = true;
+
+ while ((child = iter.next()) != NULL)
+ {
+ if (noChildren)
+ SkDebugf(">\n");
+ noChildren = false;
+ dumpview(child, level + 1, true);
+ }
+
+ if (!noChildren)
+ {
+ tab(level);
+ SkDebugf("</view>\n");
+ }
+ else
+ goto ONELINER;
+ }
+ else
+ {
+ ONELINER:
+ SkDebugf(" />\n");
+ }
}
void SkView::dump(bool recurse) const
{
- dumpview(this, 0, recurse);
+ dumpview(this, 0, recurse);
}
#endif
diff --git a/src/views/animated/SkWidgetViews.cpp b/src/views/animated/SkWidgetViews.cpp
index 007a36f986..ee03b7b1a7 100644
--- a/src/views/animated/SkWidgetViews.cpp
+++ b/src/views/animated/SkWidgetViews.cpp
@@ -15,79 +15,81 @@
/*
I have moved this to SkWidgetViews.h
enum SkinEnum {
- kButton_SkinEnum,
- kProgress_SkinEnum,
- kScroll_SkinEnum,
- kStaticText_SkinEnum,
-
- kSkinEnumCount
+ kButton_SkinEnum,
+ kProgress_SkinEnum,
+ kScroll_SkinEnum,
+ kStaticText_SkinEnum,
+
+ kSkinEnumCount
};
*/
+SK_DEFINE_INST_COUNT(SkListSource)
+
const char* get_skin_enum_path(SkinEnum se)
{
- SkASSERT((unsigned)se < kSkinEnumCount);
+ SkASSERT((unsigned)se < kSkinEnumCount);
- static const char* gSkinPaths[] = {
+ static const char* gSkinPaths[] = {
"common/default/default/skins/border3.xml",
"common/default/default/skins/button.xml",
"common/default/default/skins/progressBar.xml",
"common/default/default/skins/scrollBar.xml",
"common/default/default/skins/statictextpaint.xml"
- };
+ };
- return gSkinPaths[se];
+ return gSkinPaths[se];
}
void init_skin_anim(const char path[], SkAnimator* anim)
{
- SkASSERT(path && anim);
+ SkASSERT(path && anim);
- SkFILEStream stream(path);
+ SkFILEStream stream(path);
- if (!stream.isValid())
- {
- SkDEBUGF(("init_skin_anim: loading skin failed <%s>\n", path));
- sk_throw();
- }
+ if (!stream.isValid())
+ {
+ SkDEBUGF(("init_skin_anim: loading skin failed <%s>\n", path));
+ sk_throw();
+ }
- if (!anim->decodeStream(&stream))
- {
- SkDEBUGF(("init_skin_anim: decoding skin failed <%s>\n", path));
- sk_throw();
- }
+ if (!anim->decodeStream(&stream))
+ {
+ SkDEBUGF(("init_skin_anim: decoding skin failed <%s>\n", path));
+ sk_throw();
+ }
}
void init_skin_anim(SkinEnum se, SkAnimator* anim)
{
- init_skin_anim(get_skin_enum_path(se), anim);
+ init_skin_anim(get_skin_enum_path(se), anim);
}
void init_skin_paint(SkinEnum se, SkPaint* paint)
{
- SkASSERT(paint);
+ SkASSERT(paint);
- SkAnimator anim;
- SkCanvas canvas;
-
- init_skin_anim(se, &anim);
- anim.draw(&canvas, paint, 0);
+ SkAnimator anim;
+ SkCanvas canvas;
+
+ init_skin_anim(se, &anim);
+ anim.draw(&canvas, paint, 0);
}
void inflate_paint(const SkDOM& dom, const SkDOM::Node* node, SkPaint* paint)
{
- SkASSERT(paint);
-
- SkAnimator anim;
- SkCanvas canvas;
-
- if (!anim.decodeDOM(dom, node))
- {
- SkDEBUGF(("inflate_paint: decoding dom failed\n"));
- SkDEBUGCODE(dom.dump(node);)
- sk_throw();
- }
- anim.draw(&canvas, paint, 0);
+ SkASSERT(paint);
+
+ SkAnimator anim;
+ SkCanvas canvas;
+
+ if (!anim.decodeDOM(dom, node))
+ {
+ SkDEBUGF(("inflate_paint: decoding dom failed\n"));
+ SkDEBUGCODE(dom.dump(node);)
+ sk_throw();
+ }
+ anim.draw(&canvas, paint, 0);
}
////////////////////////////////////////////////////////////////////////////////////////
@@ -98,99 +100,99 @@ SkWidgetView::SkWidgetView() : SkView(SkView::kFocusable_Mask | SkView::kEnabled
const char* SkWidgetView::getLabel() const
{
- return fLabel.c_str();
+ return fLabel.c_str();
}
-
+
void SkWidgetView::getLabel(SkString* label) const
{
- if (label)
- *label = fLabel;
+ if (label)
+ *label = fLabel;
}
void SkWidgetView::setLabel(const char label[])
{
- this->setLabel(label, label ? strlen(label) : 0);
+ this->setLabel(label, label ? strlen(label) : 0);
}
void SkWidgetView::setLabel(const char label[], size_t len)
{
- if ((label == NULL && fLabel.size() != 0) || !fLabel.equals(label, len))
- {
- SkString tmp(label, len);
+ if ((label == NULL && fLabel.size() != 0) || !fLabel.equals(label, len))
+ {
+ SkString tmp(label, len);
- this->onLabelChange(fLabel.c_str(), tmp.c_str());
- fLabel.swap(tmp);
- }
+ this->onLabelChange(fLabel.c_str(), tmp.c_str());
+ fLabel.swap(tmp);
+ }
}
void SkWidgetView::setLabel(const SkString& label)
{
- if (fLabel != label)
- {
- this->onLabelChange(fLabel.c_str(), label.c_str());
- fLabel = label;
- }
+ if (fLabel != label)
+ {
+ this->onLabelChange(fLabel.c_str(), label.c_str());
+ fLabel = label;
+ }
}
bool SkWidgetView::postWidgetEvent()
{
- if (!fEvent.isType(""))
- {
- SkEvent evt(fEvent); // make a copy since onPrepareWidgetEvent may edit the event
-
- if (this->onPrepareWidgetEvent(&evt))
- {
- SkDEBUGCODE(evt.dump("SkWidgetView::postWidgetEvent");)
-
- this->postToListeners(evt); // wonder if this should return true if there are > 0 listeners...
- return true;
- }
- }
- return false;
+ if (!fEvent.isType(""))
+ {
+ SkEvent evt(fEvent); // make a copy since onPrepareWidgetEvent may edit the event
+
+ if (this->onPrepareWidgetEvent(&evt))
+ {
+ SkDEBUGCODE(evt.dump("SkWidgetView::postWidgetEvent");)
+
+ this->postToListeners(evt); // wonder if this should return true if there are > 0 listeners...
+ return true;
+ }
+ }
+ return false;
}
/*virtual*/ void SkWidgetView::onInflate(const SkDOM& dom, const SkDOM::Node* node)
{
- this->INHERITED::onInflate(dom, node);
-
- const char* label = dom.findAttr(node, "label");
- if (label)
- this->setLabel(label);
-
- if ((node = dom.getFirstChild(node, "event")) != NULL)
- fEvent.inflate(dom, node);
+ this->INHERITED::onInflate(dom, node);
+
+ const char* label = dom.findAttr(node, "label");
+ if (label)
+ this->setLabel(label);
+
+ if ((node = dom.getFirstChild(node, "event")) != NULL)
+ fEvent.inflate(dom, node);
}
/*virtual*/ void SkWidgetView::onLabelChange(const char oldLabel[], const char newLabel[])
{
- this->inval(NULL);
+ this->inval(NULL);
}
static const char gWidgetEventSinkIDSlotName[] = "sk-widget-sinkid-slot";
/*virtual*/ bool SkWidgetView::onPrepareWidgetEvent(SkEvent* evt)
{
- evt->setS32(gWidgetEventSinkIDSlotName, this->getSinkID());
- return true;
+ evt->setS32(gWidgetEventSinkIDSlotName, this->getSinkID());
+ return true;
}
SkEventSinkID SkWidgetView::GetWidgetEventSinkID(const SkEvent& evt)
{
- int32_t sinkID;
-
- return evt.findS32(gWidgetEventSinkIDSlotName, &sinkID) ? (SkEventSinkID)sinkID : 0;
+ int32_t sinkID;
+
+ return evt.findS32(gWidgetEventSinkIDSlotName, &sinkID) ? (SkEventSinkID)sinkID : 0;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
/*virtual*/ bool SkButtonView::onEvent(const SkEvent& evt)
{
- if (evt.isType(SK_EventType_Key) && evt.getFast32() == kOK_SkKey)
- {
- this->postWidgetEvent();
- return true;
- }
- return this->INHERITED::onEvent(evt);
+ if (evt.isType(SK_EventType_Key) && evt.getFast32() == kOK_SkKey)
+ {
+ this->postWidgetEvent();
+ return true;
+ }
+ return this->INHERITED::onEvent(evt);
}
///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -201,50 +203,50 @@ SkCheckButtonView::SkCheckButtonView() : fCheckState(kOff_CheckState)
void SkCheckButtonView::setCheckState(CheckState state)
{
- SkASSERT((unsigned)state <= kUnknown_CheckState);
-
- if (fCheckState != state)
- {
- this->onCheckStateChange(this->getCheckState(), state);
- fCheckState = SkToU8(state);
- }
+ SkASSERT((unsigned)state <= kUnknown_CheckState);
+
+ if (fCheckState != state)
+ {
+ this->onCheckStateChange(this->getCheckState(), state);
+ fCheckState = SkToU8(state);
+ }
}
-
+
/*virtual*/ void SkCheckButtonView::onCheckStateChange(CheckState oldState, CheckState newState)
{
- this->inval(NULL);
+ this->inval(NULL);
}
/*virtual*/ void SkCheckButtonView::onInflate(const SkDOM& dom, const SkDOM::Node* node)
{
- this->INHERITED::onInflate(dom, node);
-
- int index = dom.findList(node, "check-state", "off,on,unknown");
- if (index >= 0)
- this->setCheckState((CheckState)index);
+ this->INHERITED::onInflate(dom, node);
+
+ int index = dom.findList(node, "check-state", "off,on,unknown");
+ if (index >= 0)
+ this->setCheckState((CheckState)index);
}
static const char gCheckStateSlotName[] = "sk-checkbutton-check-slot";
/*virtual*/ bool SkCheckButtonView::onPrepareWidgetEvent(SkEvent* evt)
{
- // could check if we're "disabled", and return false...
+ // could check if we're "disabled", and return false...
- evt->setS32(gCheckStateSlotName, this->getCheckState());
- return true;
+ evt->setS32(gCheckStateSlotName, this->getCheckState());
+ return true;
}
bool SkCheckButtonView::GetWidgetEventCheckState(const SkEvent& evt, CheckState* state)
{
- int32_t state32;
-
- if (evt.findS32(gCheckStateSlotName, &state32))
- {
- if (state)
- *state = (CheckState)state32;
- return true;
- }
- return false;
+ int32_t state32;
+
+ if (evt.findS32(gCheckStateSlotName, &state32))
+ {
+ if (state)
+ *state = (CheckState)state32;
+ return true;
+ }
+ return false;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -256,93 +258,93 @@ bool SkCheckButtonView::GetWidgetEventCheckState(const SkEvent& evt, CheckState*
class SkAnimButtonView : public SkButtonView {
public:
- SkAnimButtonView()
- {
- fAnim.setHostEventSink(this);
- init_skin_anim(kButton_SkinEnum, &fAnim);
- }
+ SkAnimButtonView()
+ {
+ fAnim.setHostEventSink(this);
+ init_skin_anim(kButton_SkinEnum, &fAnim);
+ }
protected:
- virtual void onLabelChange(const char oldLabel[], const char newLabel[])
- {
- this->INHERITED::onLabelChange(oldLabel, newLabel);
-
- SkEvent evt("user");
- evt.setString("id", "setLabel");
- evt.setString("LABEL", newLabel);
- fAnim.doUserEvent(evt);
- }
-
- virtual void onFocusChange(bool gainFocus)
- {
- this->INHERITED::onFocusChange(gainFocus);
-
- SkEvent evt("user");
- evt.setString("id", "setFocus");
- evt.setS32("FOCUS", gainFocus);
- fAnim.doUserEvent(evt);
- }
-
- virtual void onSizeChange()
- {
- this->INHERITED::onSizeChange();
-
- SkEvent evt("user");
- evt.setString("id", "setDim");
- evt.setScalar("dimX", this->width());
- evt.setScalar("dimY", this->height());
- fAnim.doUserEvent(evt);
- }
-
- virtual void onDraw(SkCanvas* canvas)
- {
- SkPaint paint;
- SkAnimator::DifferenceType diff = fAnim.draw(canvas, &paint, SkTime::GetMSecs());
-
- if (diff == SkAnimator::kDifferent)
- this->inval(NULL);
- else if (diff == SkAnimator::kPartiallyDifferent)
- {
- SkRect bounds;
- fAnim.getInvalBounds(&bounds);
- this->inval(&bounds);
- }
- }
-
- virtual bool onEvent(const SkEvent& evt)
- {
- if (evt.isType(SK_EventType_Inval))
- {
- this->inval(NULL);
- return true;
- }
- if (evt.isType("recommendDim"))
- {
- SkScalar height;
-
- if (evt.findScalar("y", &height))
- this->setHeight(height);
- return true;
- }
- return this->INHERITED::onEvent(evt);
- }
-
- virtual bool onPrepareWidgetEvent(SkEvent* evt)
- {
- if (this->INHERITED::onPrepareWidgetEvent(evt))
- {
- SkEvent e("user");
- e.setString("id", "handlePress");
- (void)fAnim.doUserEvent(e);
- return true;
- }
- return false;
- }
+ virtual void onLabelChange(const char oldLabel[], const char newLabel[])
+ {
+ this->INHERITED::onLabelChange(oldLabel, newLabel);
+
+ SkEvent evt("user");
+ evt.setString("id", "setLabel");
+ evt.setString("LABEL", newLabel);
+ fAnim.doUserEvent(evt);
+ }
+
+ virtual void onFocusChange(bool gainFocus)
+ {
+ this->INHERITED::onFocusChange(gainFocus);
+
+ SkEvent evt("user");
+ evt.setString("id", "setFocus");
+ evt.setS32("FOCUS", gainFocus);
+ fAnim.doUserEvent(evt);
+ }
+
+ virtual void onSizeChange()
+ {
+ this->INHERITED::onSizeChange();
+
+ SkEvent evt("user");
+ evt.setString("id", "setDim");
+ evt.setScalar("dimX", this->width());
+ evt.setScalar("dimY", this->height());
+ fAnim.doUserEvent(evt);
+ }
+
+ virtual void onDraw(SkCanvas* canvas)
+ {
+ SkPaint paint;
+ SkAnimator::DifferenceType diff = fAnim.draw(canvas, &paint, SkTime::GetMSecs());
+
+ if (diff == SkAnimator::kDifferent)
+ this->inval(NULL);
+ else if (diff == SkAnimator::kPartiallyDifferent)
+ {
+ SkRect bounds;
+ fAnim.getInvalBounds(&bounds);
+ this->inval(&bounds);
+ }
+ }
+
+ virtual bool onEvent(const SkEvent& evt)
+ {
+ if (evt.isType(SK_EventType_Inval))
+ {
+ this->inval(NULL);
+ return true;
+ }
+ if (evt.isType("recommendDim"))
+ {
+ SkScalar height;
+
+ if (evt.findScalar("y", &height))
+ this->setHeight(height);
+ return true;
+ }
+ return this->INHERITED::onEvent(evt);
+ }
+
+ virtual bool onPrepareWidgetEvent(SkEvent* evt)
+ {
+ if (this->INHERITED::onPrepareWidgetEvent(evt))
+ {
+ SkEvent e("user");
+ e.setString("id", "handlePress");
+ (void)fAnim.doUserEvent(e);
+ return true;
+ }
+ return false;
+ }
private:
- SkAnimator fAnim;
-
- typedef SkButtonView INHERITED;
+ SkAnimator fAnim;
+
+ typedef SkButtonView INHERITED;
};
////////////////////////////////////////////////////////////////////////////////////////////
@@ -350,26 +352,26 @@ private:
SkView* SkWidgetFactory(const char name[])
{
- if (name == NULL)
- return NULL;
-
- // must be in the same order as the SkSkinWidgetEnum is declared
- static const char* gNames[] = {
- "sk-border",
- "sk-button",
- "sk-image",
- "sk-list",
- "sk-progress",
- "sk-scroll",
- "sk-text"
-
- };
-
- for (size_t i = 0; i < SK_ARRAY_COUNT(gNames); i++)
- if (!strcmp(gNames[i], name))
- return SkWidgetFactory((SkWidgetEnum)i);
-
- return NULL;
+ if (name == NULL)
+ return NULL;
+
+ // must be in the same order as the SkSkinWidgetEnum is declared
+ static const char* gNames[] = {
+ "sk-border",
+ "sk-button",
+ "sk-image",
+ "sk-list",
+ "sk-progress",
+ "sk-scroll",
+ "sk-text"
+
+ };
+
+ for (size_t i = 0; i < SK_ARRAY_COUNT(gNames); i++)
+ if (!strcmp(gNames[i], name))
+ return SkWidgetFactory((SkWidgetEnum)i);
+
+ return NULL;
}
#include "SkImageView.h"
@@ -379,24 +381,24 @@ SkView* SkWidgetFactory(const char name[])
SkView* SkWidgetFactory(SkWidgetEnum sw)
{
- switch (sw) {
- case kBorder_WidgetEnum:
- return new SkBorderView;
- case kButton_WidgetEnum:
- return new SkAnimButtonView;
- case kImage_WidgetEnum:
- return new SkImageView;
- case kList_WidgetEnum:
- return new SkListView;
- case kProgress_WidgetEnum:
- return new SkProgressBarView;
- case kScroll_WidgetEnum:
- return new SkScrollBarView;
- case kText_WidgetEnum:
- return new SkStaticTextView;
- default:
- SkDEBUGFAIL("unknown enum passed to SkWidgetFactory");
- break;
- }
- return NULL;
+ switch (sw) {
+ case kBorder_WidgetEnum:
+ return new SkBorderView;
+ case kButton_WidgetEnum:
+ return new SkAnimButtonView;
+ case kImage_WidgetEnum:
+ return new SkImageView;
+ case kList_WidgetEnum:
+ return new SkListView;
+ case kProgress_WidgetEnum:
+ return new SkProgressBarView;
+ case kScroll_WidgetEnum:
+ return new SkScrollBarView;
+ case kText_WidgetEnum:
+ return new SkStaticTextView;
+ default:
+ SkDEBUGFAIL("unknown enum passed to SkWidgetFactory");
+ break;
+ }
+ return NULL;
}
diff --git a/tests/AAClipTest.cpp b/tests/AAClipTest.cpp
index bf52b01acd..c5e82ba647 100644
--- a/tests/AAClipTest.cpp
+++ b/tests/AAClipTest.cpp
@@ -337,6 +337,9 @@ static bool operator==(const SkRasterClip& a, const SkRasterClip& b) {
SkMask ma, mb;
copyToMask(a, &ma);
copyToMask(b, &mb);
+ SkAutoMaskFreeImage aCleanUp(ma.fImage);
+ SkAutoMaskFreeImage bCleanUp(mb.fImage);
+
return ma == mb;
}
diff --git a/tests/RefDictTest.cpp b/tests/RefDictTest.cpp
index 83d1aefae1..38a990a439 100644
--- a/tests/RefDictTest.cpp
+++ b/tests/RefDictTest.cpp
@@ -9,8 +9,14 @@
#include "SkRefDict.h"
class TestRC : public SkRefCnt {
+public:
+ SK_DECLARE_INST_COUNT(TestRC)
+private:
+ typedef SkRefCnt INHERITED;
};
+SK_DEFINE_INST_COUNT(TestRC)
+
static void TestRefDict(skiatest::Reporter* reporter) {
TestRC data0, data1;
SkRefDict dict;
diff --git a/tests/Test.cpp b/tests/Test.cpp
index 0441ab0fa7..deb83483c2 100644
--- a/tests/Test.cpp
+++ b/tests/Test.cpp
@@ -16,6 +16,8 @@
class GrContext;
#endif
+SK_DEFINE_INST_COUNT(skiatest::Reporter)
+
using namespace skiatest;
Reporter::Reporter() {
diff --git a/tests/Test.h b/tests/Test.h
index 4ca1971782..2396d6f964 100644
--- a/tests/Test.h
+++ b/tests/Test.h
@@ -21,6 +21,7 @@ namespace skiatest {
class Reporter : public SkRefCnt {
public:
+ SK_DECLARE_INST_COUNT(Reporter)
Reporter();
enum Result {
diff --git a/tests/UtilsTest.cpp b/tests/UtilsTest.cpp
index f1b1ea9139..1c2f870d1f 100644
--- a/tests/UtilsTest.cpp
+++ b/tests/UtilsTest.cpp
@@ -14,13 +14,19 @@
class RefClass : public SkRefCnt {
public:
+ SK_DECLARE_INST_COUNT(RefClass)
+
RefClass(int n) : fN(n) {}
int get() const { return fN; }
private:
int fN;
+
+ typedef SkRefCnt INHERITED;
};
+SK_DEFINE_INST_COUNT(RefClass)
+
static void test_refptr(skiatest::Reporter* reporter) {
RefClass* r0 = new RefClass(0);