tinybitmap.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * Copyright 2011 Google Inc.
  3. *
  4. * Use of this source code is governed by a BSD-style license that can be
  5. * found in the LICENSE file.
  6. */
  7. #include "gm/gm.h"
  8. #include "include/core/SkBitmap.h"
  9. #include "include/core/SkCanvas.h"
  10. #include "include/core/SkColorPriv.h"
  11. #include "include/core/SkPaint.h"
  12. #include "include/core/SkShader.h"
  13. #include "include/core/SkSize.h"
  14. #include "include/core/SkString.h"
  15. #include "include/core/SkTileMode.h"
  16. namespace {
  17. class TinyBitmapGM : public skiagm::GM {
  18. void onOnceBeforeDraw() override { this->setBGColor(0xFFDDDDDD); }
  19. SkString onShortName() override { return SkString("tinybitmap"); }
  20. virtual SkISize onISize() override { return SkISize::Make(100, 100); }
  21. void onDraw(SkCanvas* canvas) override {
  22. SkBitmap bm;
  23. bm.allocN32Pixels(1, 1);
  24. *bm.getAddr32(0, 0) = SkPackARGB32(0x80, 0x80, 0, 0);
  25. SkPaint paint;
  26. paint.setAlphaf(0.5f);
  27. paint.setShader(bm.makeShader(SkTileMode::kRepeat, SkTileMode::kMirror));
  28. canvas->drawPaint(paint);
  29. }
  30. };
  31. }
  32. DEF_GM( return new TinyBitmapGM; )