add BlitRow procs for 32->32, to allow for neon and other optimizations.
call these new procs in (nearly) all the places we had inlined loops before.
In once instance (blitter_argb32::blitAntiH) we get different results by a
tiny bit. The new code is more accurate, and exactly inline with all of the
other like-minded blits, so I think the change is good going forward.
git-svn-id: http://skia.googlecode.com/svn/trunk@366 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/samplecode/SampleGM.cpp b/samplecode/SampleGM.cpp
new file mode 100644
index 0000000..095dfe6
--- /dev/null
+++ b/samplecode/SampleGM.cpp
@@ -0,0 +1,84 @@
+#include "SampleCode.h"
+#include "SkView.h"
+#include "SkCanvas.h"
+
+#include "gm.h"
+
+using namespace skiagm;
+
+GM::GM() {}
+GM::~GM() {}
+
+void GM::draw(SkCanvas* canvas) {
+ this->onDraw(canvas);
+}
+
+// need to explicitly declare this, or we get some weird infinite loop llist
+template GMRegistry* GMRegistry::gHead;
+
+class Iter {
+public:
+ Iter() {
+ fReg = GMRegistry::Head();
+ }
+
+ GM* next() {
+ if (fReg) {
+ GMRegistry::Factory fact = fReg->factory();
+ fReg = fReg->next();
+ return fact(0);
+ }
+ return NULL;
+ }
+
+ static int Count() {
+ const GMRegistry* reg = GMRegistry::Head();
+ int count = 0;
+ while (reg) {
+ count += 1;
+ reg = reg->next();
+ }
+ return count;
+ }
+
+private:
+ const GMRegistry* fReg;
+};
+
+///////////////////////////////////////////////////////////////////////////////
+
+class GMView : public SkView {
+ Iter fIter;
+ GM* fGM;
+public:
+ GMView() {
+ fGM = fIter.next();
+ }
+
+protected:
+ // overrides from SkEventSink
+ virtual bool onQuery(SkEvent* evt) {
+ if (SampleCode::TitleQ(*evt)) {
+ SampleCode::TitleR(evt, "GM");
+ return true;
+ }
+ return this->INHERITED::onQuery(evt);
+ }
+
+ void drawBG(SkCanvas* canvas) {
+ canvas->drawColor(0xFFDDDDDD);
+ }
+
+ virtual void onDraw(SkCanvas* canvas) {
+ fGM->draw(canvas);
+ }
+
+private:
+ typedef SkView INHERITED;
+};
+
+///////////////////////////////////////////////////////////////////////////////
+
+static SkView* MyFactory() { return new GMView; }
+static SkViewRegister reg(MyFactory);
+
diff --git a/samplecode/SampleNinePatch.cpp b/samplecode/SampleNinePatch.cpp
index efb108f..941b3ff 100644
--- a/samplecode/SampleNinePatch.cpp
+++ b/samplecode/SampleNinePatch.cpp
@@ -19,6 +19,9 @@
r.set(1, 1, fBM.width() - 1, fBM.height() - 1);
fBM.extractSubset(&tmp, r);
fBM.swap(tmp);
+
+ fX = SkIntToScalar(fBM.width());
+ fY = 0;
}
protected:
@@ -33,7 +36,11 @@
void drawBG(SkCanvas* canvas) {
canvas->drawColor(SK_ColorWHITE);
-
+ }
+
+ virtual void onDraw(SkCanvas* canvas) {
+ this->drawBG(canvas);
+
canvas->scale(1.5f, 1.5f);
canvas->drawBitmap(fBM, 0, 0);
@@ -44,17 +51,19 @@
margins.set(d, d, d, d);
dst.set(0, 0, SkIntToScalar(200), SkIntToScalar(200));
- dst.offset(SkIntToScalar(fBM.width()), 0);
- dst.offset(SkIntToScalar(2), SkIntToScalar(2));
+ dst.offset(fX, fY);
SkNinePatch::DrawNine(canvas, dst, fBM, margins);
}
- virtual void onDraw(SkCanvas* canvas) {
- this->drawBG(canvas);
+ virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y) {
+ fX = x / 1.5f;
+ fY = y / 1.5f;
+ this->inval(NULL);
+ return this->INHERITED::onFindClickHandler(x, y);
}
-
private:
+ SkScalar fX, fY;
typedef SkView INHERITED;
};