fadefilter.cpp 990 B

1234567891011121314151617181920212223242526272829
  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. #include "gm/gm.h"
  8. #include "include/core/SkCanvas.h"
  9. #include "include/core/SkColorFilter.h"
  10. #include "include/core/SkImageFilter.h"
  11. #include "include/core/SkPaint.h"
  12. #include "include/core/SkRect.h"
  13. #include "include/core/SkRefCnt.h"
  14. #include "include/effects/SkColorFilterImageFilter.h"
  15. #include <utility>
  16. // This GM renders correctly in 8888, but fails in PDF
  17. DEF_SIMPLE_GM(fadefilter, canvas, 256, 256) {
  18. float matrix[20] = { 1, 0, 0, 0, 0.5f,
  19. 0, 1, 0, 0, 0.5f,
  20. 0, 0, 1, 0, 0.5f,
  21. 0, 0, 0, 1, 0 };
  22. sk_sp<SkColorFilter> colorFilter(SkColorFilters::Matrix(matrix));
  23. SkPaint layerPaint;
  24. layerPaint.setImageFilter(SkColorFilterImageFilter::Make(std::move(colorFilter), nullptr));
  25. canvas->drawRect(SkRect::MakeLTRB(64, 64, 192, 192), layerPaint);
  26. }