GrRectanizer.h 1016 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * Copyright 2010 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 GrRectanizer_DEFINED
  8. #define GrRectanizer_DEFINED
  9. #include "include/gpu/GrTypes.h"
  10. struct SkIPoint16;
  11. class GrRectanizer {
  12. public:
  13. GrRectanizer(int width, int height) : fWidth(width), fHeight(height) {
  14. SkASSERT(width >= 0);
  15. SkASSERT(height >= 0);
  16. }
  17. virtual ~GrRectanizer() {}
  18. virtual void reset() = 0;
  19. int width() const { return fWidth; }
  20. int height() const { return fHeight; }
  21. // Attempt to add a rect. Return true on success; false on failure. If
  22. // successful the position in the atlas is returned in 'loc'.
  23. virtual bool addRect(int width, int height, SkIPoint16* loc) = 0;
  24. virtual float percentFull() const = 0;
  25. /**
  26. * Our factory, which returns the subclass du jour
  27. */
  28. static GrRectanizer* Factory(int width, int height);
  29. private:
  30. int fWidth;
  31. int fHeight;
  32. };
  33. #endif