diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-03-18 17:39:44 -0700 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-03-18 17:39:44 -0700 |
commit | af527e02dce280c269d751322e9f60aac8cb97da (patch) | |
tree | 19faf6d47cdd3d589a6dfcff0f8f75fcbb03aa20 /samplecode/SampleBitmapRect.cpp | |
parent | 5956d1c224aadf1d2712b46b32d3fc69a19915bd (diff) | |
download | external_skia-af527e02dce280c269d751322e9f60aac8cb97da.zip external_skia-af527e02dce280c269d751322e9f60aac8cb97da.tar.gz external_skia-af527e02dce280c269d751322e9f60aac8cb97da.tar.bz2 |
auto import from //branches/cupcake_rel/...@140373
Diffstat (limited to 'samplecode/SampleBitmapRect.cpp')
-rw-r--r-- | samplecode/SampleBitmapRect.cpp | 110 |
1 files changed, 0 insertions, 110 deletions
diff --git a/samplecode/SampleBitmapRect.cpp b/samplecode/SampleBitmapRect.cpp deleted file mode 100644 index f164e06..0000000 --- a/samplecode/SampleBitmapRect.cpp +++ /dev/null @@ -1,110 +0,0 @@ -#include "SampleCode.h" -#include "SkView.h" -#include "SkCanvas.h" -#include "SkGradientShader.h" -#include "SkGraphics.h" -#include "SkImageDecoder.h" -#include "SkPath.h" -#include "SkPorterDuff.h" -#include "SkRegion.h" -#include "SkShader.h" -#include "SkUtils.h" -#include "SkXfermode.h" -#include "SkColorPriv.h" -#include "SkColorFilter.h" -#include "SkTime.h" -#include "SkTypeface.h" - -#include "SkImageRef.h" -#include "SkOSFile.h" -#include "SkStream.h" - -#define SPECIFIC_IMAGE "/skimages/main.gif" - -class BitmapRectView : public SkView { -public: - SkBitmap fBitmap; - int fCurrX, fCurrY; - - BitmapRectView() { - SkImageDecoder::DecodeFile(SPECIFIC_IMAGE, &fBitmap); - fCurrX = fCurrY = 0; - } - -protected: - // overrides from SkEventSink - virtual bool onQuery(SkEvent* evt) - { - if (SampleCode::TitleQ(*evt)) - { - SkString str("BitmapRect: "); - str.append(SPECIFIC_IMAGE); - SampleCode::TitleR(evt, str.c_str()); - return true; - } - return this->INHERITED::onQuery(evt); - } - - void drawBG(SkCanvas* canvas) - { - canvas->drawColor(SK_ColorGRAY); - } - - virtual void onDraw(SkCanvas* canvas) - { - this->drawBG(canvas); - - canvas->drawBitmap(fBitmap, 0, 0, NULL); - - SkIRect subset; - const int SRC_WIDTH = 16; - const int SRC_HEIGHT = 16; - - subset.set(0, 0, SRC_WIDTH, SRC_HEIGHT); - subset.offset(fCurrX, fCurrY); - - SkDebugf("---- src x=%d y=%d\n", subset.fLeft, subset.fTop); - - SkRect dst0, dst1; - SkScalar y = SkIntToScalar(fBitmap.height() + 16); - - dst0.set(SkIntToScalar(50), y, - SkIntToScalar(50+SRC_WIDTH), - y + SkIntToScalar(SRC_HEIGHT)); - dst1 = dst0; - dst1.offset(SkIntToScalar(200), 0); - dst1.fRight = dst1.fLeft + 8 * dst0.width(); - dst1.fBottom = dst1.fTop + 8 * dst0.height(); - - canvas->drawBitmapRect(fBitmap, &subset, dst0, NULL); - canvas->drawBitmapRect(fBitmap, &subset, dst1, NULL); - - SkPaint paint; - paint.setColor(0x88FF0000); - canvas->drawRect(dst0, paint); - paint.setColor(0x880000FF); - canvas->drawRect(dst1, paint); - } - - virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y) - { - return new Click(this); - } - - virtual bool onClick(Click* click) - { - fCurrX = click->fICurr.fX; - fCurrY = click->fICurr.fY; - this->inval(NULL); - return true; - } - -private: - typedef SkView INHERITED; -}; - -////////////////////////////////////////////////////////////////////////////// - -static SkView* MyFactory() { return new BitmapRectView; } -static SkViewRegister reg(MyFactory); - |