Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Unified Diff: include/core/SkTypeface.h

Issue 676523002: Add SkTypeface::getBounds() (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/core/SkThreadPriv.h ('k') | src/core/SkLazyPtr.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkTypeface.h
diff --git a/include/core/SkTypeface.h b/include/core/SkTypeface.h
index f67623674a3c05823df0a584a2d363ecbf080b6e..c3ff3641b71b4a49561dee69861361ed54d1eca4 100644
--- a/include/core/SkTypeface.h
+++ b/include/core/SkTypeface.h
@@ -12,6 +12,7 @@
#include "SkAdvancedTypefaceMetrics.h"
#include "SkFontStyle.h"
+#include "SkLazyPtr.h"
#include "SkWeakRefCnt.h"
class SkDescriptor;
@@ -282,6 +283,13 @@ public:
SkScalerContext* createScalerContext(const SkDescriptor*,
bool allowFailure = false) const;
+ /**
+ * Return a rectangle (scaled to 1-pt) that represents the union of the bounds of all
+ * of the glyphs, but each one positioned at (0,). This may be conservatively large, and
+ * will not take into account any hinting or other size-specific adjustments.
+ */
+ SkRect getBounds() const;
+
// PRIVATE / EXPERIMENTAL -- do not call
void filterRec(SkScalerContextRec* rec) const {
this->onFilterRec(rec);
@@ -333,6 +341,8 @@ protected:
virtual size_t onGetTableData(SkFontTableTag, size_t offset,
size_t length, void* data) const = 0;
+ virtual bool onComputeBounds(SkRect*) const;
+
private:
friend class SkGTypeface;
friend class SkPDFFont;
@@ -359,9 +369,13 @@ private:
static SkTypeface* CreateDefault(int style); // SkLazyPtr requires an int, not a Style.
static void DeleteDefault(SkTypeface*);
- SkFontID fUniqueID;
- SkFontStyle fStyle;
- bool fIsFixedPitch;
+ struct BoundsComputer;
+// friend struct BoundsComputer;
+
+ SkLazyPtr<SkRect> fLazyBounds;
+ SkFontID fUniqueID;
+ SkFontStyle fStyle;
+ bool fIsFixedPitch;
friend class SkPaint;
friend class SkGlyphCache; // GetDefaultTypeface
« no previous file with comments | « include/core/SkThreadPriv.h ('k') | src/core/SkLazyPtr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698