summaryrefslogtreecommitdiffstats
path: root/o3d
diff options
context:
space:
mode:
authorpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-10 20:51:35 +0000
committerpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-10 20:51:35 +0000
commit7bdb25d77ceae0c9db9c6d11e22fe5deccf888d3 (patch)
treef4fb72c1cba93b60735c8798efbca3017c07650a /o3d
parent31a80f2ad70f9c29ca604bbda2a934b3fe6fc7f4 (diff)
downloadchromium_src-7bdb25d77ceae0c9db9c6d11e22fe5deccf888d3.zip
chromium_src-7bdb25d77ceae0c9db9c6d11e22fe5deccf888d3.tar.gz
chromium_src-7bdb25d77ceae0c9db9c6d11e22fe5deccf888d3.tar.bz2
linux: enabling fonts
'Cause, guess what, they work now. Review URL: http://codereview.chromium.org/492001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34274 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d')
-rw-r--r--o3d/core/cross/canvas.cc8
-rw-r--r--o3d/core/cross/canvas_paint.cc26
2 files changed, 4 insertions, 30 deletions
diff --git a/o3d/core/cross/canvas.cc b/o3d/core/cross/canvas.cc
index 07bb4a5..c955a14 100644
--- a/o3d/core/cross/canvas.cc
+++ b/o3d/core/cross/canvas.cc
@@ -103,15 +103,11 @@ void Canvas::DrawText(const String& text,
float x,
float y,
CanvasPaint* paint) {
-#ifndef OS_LINUX
sk_canvas_.drawText(text.c_str(),
text.length(),
SkFloatToScalar(x),
SkFloatToScalar(y),
paint->GetNativePaint());
-#else
- O3D_ERROR(service_locator()) << "Text is not yet supported on Linux";
-#endif
}
void Canvas::DrawTextOnPath(const String& text,
@@ -119,7 +115,6 @@ void Canvas::DrawTextOnPath(const String& text,
float horizontal_offset,
float vertical_offset,
CanvasPaint* paint) {
-#ifndef OS_LINUX
unsigned int size = positions.size();
if (size < 2) {
O3D_ERROR(service_locator()) << "Must provide at least two positions"
@@ -143,9 +138,6 @@ void Canvas::DrawTextOnPath(const String& text,
SkFloatToScalar(horizontal_offset),
SkFloatToScalar(vertical_offset),
nativePaint);
-#else
- O3D_ERROR(service_locator()) << "Text is not yet supported on Linux";
-#endif
}
void Canvas::DrawBitmap(Texture2D* texture2d,
diff --git a/o3d/core/cross/canvas_paint.cc b/o3d/core/cross/canvas_paint.cc
index 08c5c2e..d4545b7 100644
--- a/o3d/core/cross/canvas_paint.cc
+++ b/o3d/core/cross/canvas_paint.cc
@@ -157,7 +157,6 @@ StrokeDrawLooper::StrokeDrawLooper(SkFlattenableReadBuffer& buffer) {
O3D_DEFN_CLASS(CanvasPaint, ParamObject);
-#ifndef OS_LINUX
static SkPaint::Align ToSKAlign(CanvasPaint::TextAlign align) {
switch (align) {
case CanvasPaint::LEFT:
@@ -170,7 +169,6 @@ static SkPaint::Align ToSKAlign(CanvasPaint::TextAlign align) {
return SkPaint::kLeft_Align;
}
}
-#endif // OS_LINUX
CanvasPaint::CanvasPaint(ServiceLocator* service_locator)
: ParamObject(service_locator),
@@ -216,7 +214,6 @@ void CanvasPaint::UpdateNativePaint() {
sk_paint_.setLooper(NULL);
}
-#ifndef OS_LINUX
sk_paint_.setTextSize(SkFloatToScalar(text_size_));
// TODO: Verify that there's visual parity between fonts on all
@@ -227,9 +224,10 @@ void CanvasPaint::UpdateNativePaint() {
SkTypeface* tf = SkTypeface::CreateFromName(
text_typeface_.c_str(),
static_cast<SkTypeface::Style>(text_style_));
- sk_paint_.setTypeface(tf);
- tf->unref();
-#endif
+ if (tf) {
+ sk_paint_.setTypeface(tf);
+ tf->unref();
+ }
if (shader_) {
sk_paint_.setShader(shader_->GetNativeShader());
@@ -237,9 +235,7 @@ void CanvasPaint::UpdateNativePaint() {
sk_paint_.setShader(NULL);
}
-#ifndef OS_LINUX
sk_paint_.setTextAlign(ToSKAlign(text_align_));
-#endif
needs_update_ = false;
}
@@ -248,7 +244,6 @@ void CanvasPaint::UpdateNativePaint() {
CanvasFontMetrics CanvasPaint::GetFontMetrics() {
CanvasFontMetrics ret;
-#ifndef OS_LINUX
SkPaint::FontMetrics metrics;
GetNativePaint().getFontMetrics(&metrics);
@@ -257,28 +252,15 @@ CanvasFontMetrics CanvasPaint::GetFontMetrics() {
ret.set_descent(metrics.fDescent);
ret.set_leading(metrics.fLeading);
ret.set_top(metrics.fTop);
-#else
- O3D_ERROR(service_locator()) << "Text is not yet supported on Linux";
- ret.set_top(0.f);
- ret.set_ascent(0.f);
- ret.set_descent(0.f);
- ret.set_bottom(0.f);
- ret.set_leading(0.f);
-#endif
return ret;
}
Float4 CanvasPaint::MeasureText(const String& text) {
-#ifndef OS_LINUX
SkRect bounds;
GetNativePaint().measureText(text.c_str(), text.size(), &bounds);
return Float4(bounds.fLeft, bounds.fTop, bounds.fRight, bounds.fBottom);
-#else
- O3D_ERROR(service_locator()) << "Text is not yet supported on Linux";
- return Float4(0.f, 0.f, 0.f, 0.f);
-#endif
}
ObjectBase::Ref CanvasPaint::Create(ServiceLocator* service_locator) {