thumbnail.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Copyright 2020 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef PDF_UI_THUMBNAIL_H_
  5. #define PDF_UI_THUMBNAIL_H_
  6. #include "base/values.h"
  7. #include "ui/gfx/geometry/size.h"
  8. namespace chrome_pdf {
  9. class Thumbnail final {
  10. public:
  11. Thumbnail(const gfx::Size& page_size, float device_pixel_ratio);
  12. Thumbnail(Thumbnail&& other);
  13. Thumbnail& operator=(Thumbnail&& other);
  14. ~Thumbnail();
  15. float device_pixel_ratio() const { return device_pixel_ratio_; }
  16. int stride() const { return stride_; }
  17. const gfx::Size& image_size() const { return image_size_; }
  18. // Note that <canvas> can only hold data in RGBA format. It is the
  19. // responsibility of the thumbnail's renderer to fill the data with RGBA data.
  20. base::Value::BlobStorage& GetImageData();
  21. // Transfers the internal image data to the caller. After calling TakeData(),
  22. // this Thumbnail instance should not be used.
  23. base::Value::BlobStorage TakeData();
  24. private:
  25. // Intended resolution of the thumbnail image. The dimensions of `bitmap_`
  26. // are the dimensions of the thumbnail in CSS pixels multiplied by
  27. // `device_pixel_ratio_`.
  28. // Only values between 0.25 and 2 are supported.
  29. float device_pixel_ratio_;
  30. gfx::Size image_size_; // In pixels.
  31. int stride_;
  32. base::Value::BlobStorage image_data_;
  33. };
  34. } // namespace chrome_pdf
  35. #endif // PDF_UI_THUMBNAIL_H_