BitmapRegionDecoderBench.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * Copyright 2015 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. #ifndef BitmapRegionDecoderBench_DEFINED
  8. #define BitmapRegionDecoderBench_DEFINED
  9. #include "bench/Benchmark.h"
  10. #include "include/android/SkBitmapRegionDecoder.h"
  11. #include "include/core/SkData.h"
  12. #include "include/core/SkImageInfo.h"
  13. #include "include/core/SkRefCnt.h"
  14. #include "include/core/SkString.h"
  15. /**
  16. * Benchmark Android's BitmapRegionDecoder for a particular colorType, sampleSize, and subset.
  17. *
  18. * nanobench.cpp handles creating benchmarks for interesting scaled subsets. We strive to test
  19. * on real use cases.
  20. */
  21. class BitmapRegionDecoderBench : public Benchmark {
  22. public:
  23. // Calls encoded->ref()
  24. BitmapRegionDecoderBench(const char* basename, SkData* encoded, SkColorType colorType,
  25. uint32_t sampleSize, const SkIRect& subset);
  26. protected:
  27. const char* onGetName() override;
  28. bool isSuitableFor(Backend backend) override;
  29. void onDraw(int n, SkCanvas* canvas) override;
  30. void onDelayedSetup() override;
  31. private:
  32. SkString fName;
  33. std::unique_ptr<SkBitmapRegionDecoder> fBRD;
  34. sk_sp<SkData> fData;
  35. const SkColorType fColorType;
  36. const uint32_t fSampleSize;
  37. const SkIRect fSubset;
  38. typedef Benchmark INHERITED;
  39. };
  40. #endif // BitmapRegionDecoderBench_DEFINED