OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "webkit/plugins/ppapi/ppb_flash_impl.h" | 5 #include "webkit/plugins/ppapi/ppb_flash_impl.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/time.h" | 10 #include "base/time.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 | 87 |
88 // Set up the typeface. | 88 // Set up the typeface. |
89 StringVar* face_name = StringVar::FromPPVar(font_desc->face); | 89 StringVar* face_name = StringVar::FromPPVar(font_desc->face); |
90 if (!face_name) | 90 if (!face_name) |
91 return PP_FALSE; | 91 return PP_FALSE; |
92 int style = SkTypeface::kNormal; | 92 int style = SkTypeface::kNormal; |
93 if (font_desc->weight >= PP_FONTWEIGHT_BOLD) | 93 if (font_desc->weight >= PP_FONTWEIGHT_BOLD) |
94 style |= SkTypeface::kBold; | 94 style |= SkTypeface::kBold; |
95 if (font_desc->italic) | 95 if (font_desc->italic) |
96 style |= SkTypeface::kItalic; | 96 style |= SkTypeface::kItalic; |
97 SkTypeface* typeface = | 97 skia::RefPtr<SkTypeface> typeface = skia::AdoptRef( |
98 SkTypeface::CreateFromName(face_name->value().c_str(), | 98 SkTypeface::CreateFromName(face_name->value().c_str(), |
99 static_cast<SkTypeface::Style>(style)); | 99 static_cast<SkTypeface::Style>(style))); |
100 if (!typeface) | 100 if (!typeface) |
101 return PP_FALSE; | 101 return PP_FALSE; |
102 SkAutoUnref aur(typeface); | |
103 | 102 |
104 // Set up the canvas. | 103 // Set up the canvas. |
105 SkCanvas* canvas = image_resource->GetPlatformCanvas(); | 104 SkCanvas* canvas = image_resource->GetPlatformCanvas(); |
106 SkAutoCanvasRestore acr(canvas, true); | 105 SkAutoCanvasRestore acr(canvas, true); |
107 | 106 |
108 // Clip is applied in pixels before the transform. | 107 // Clip is applied in pixels before the transform. |
109 SkRect clip_rect = { SkIntToScalar(clip->point.x), | 108 SkRect clip_rect = { SkIntToScalar(clip->point.x), |
110 SkIntToScalar(clip->point.y), | 109 SkIntToScalar(clip->point.y), |
111 SkIntToScalar(clip->point.x + clip->size.width), | 110 SkIntToScalar(clip->point.x + clip->size.width), |
112 SkIntToScalar(clip->point.y + clip->size.height) }; | 111 SkIntToScalar(clip->point.y + clip->size.height) }; |
(...skipping 11 matching lines...) Expand all Loading... |
124 matrix.set(SkMatrix::kMPersp1, SkFloatToScalar(transformation[2][1])); | 123 matrix.set(SkMatrix::kMPersp1, SkFloatToScalar(transformation[2][1])); |
125 matrix.set(SkMatrix::kMPersp2, SkFloatToScalar(transformation[2][2])); | 124 matrix.set(SkMatrix::kMPersp2, SkFloatToScalar(transformation[2][2])); |
126 canvas->concat(matrix); | 125 canvas->concat(matrix); |
127 | 126 |
128 SkPaint paint; | 127 SkPaint paint; |
129 paint.setColor(color); | 128 paint.setColor(color); |
130 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); | 129 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); |
131 paint.setAntiAlias(true); | 130 paint.setAntiAlias(true); |
132 paint.setHinting(SkPaint::kFull_Hinting); | 131 paint.setHinting(SkPaint::kFull_Hinting); |
133 paint.setTextSize(SkIntToScalar(font_desc->size)); | 132 paint.setTextSize(SkIntToScalar(font_desc->size)); |
134 paint.setTypeface(typeface); // Takes a ref and manages lifetime. | 133 paint.setTypeface(typeface.get()); // Takes a ref and manages lifetime. |
135 if (allow_subpixel_aa) { | 134 if (allow_subpixel_aa) { |
136 paint.setSubpixelText(true); | 135 paint.setSubpixelText(true); |
137 paint.setLCDRenderText(true); | 136 paint.setLCDRenderText(true); |
138 } | 137 } |
139 | 138 |
140 SkScalar x = SkIntToScalar(position->x); | 139 SkScalar x = SkIntToScalar(position->x); |
141 SkScalar y = SkIntToScalar(position->y); | 140 SkScalar y = SkIntToScalar(position->y); |
142 | 141 |
143 // Build up the skia advances. | 142 // Build up the skia advances. |
144 if (glyph_count == 0) | 143 if (glyph_count == 0) |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 return PP_TRUE; | 466 return PP_TRUE; |
468 } | 467 } |
469 | 468 |
470 PP_Bool PPB_Flash_Impl::FlashGetScreenSize(PP_Instance instance, | 469 PP_Bool PPB_Flash_Impl::FlashGetScreenSize(PP_Instance instance, |
471 PP_Size* size) { | 470 PP_Size* size) { |
472 return instance_->GetScreenSize(instance, size); | 471 return instance_->GetScreenSize(instance, size); |
473 } | 472 } |
474 | 473 |
475 } // namespace ppapi | 474 } // namespace ppapi |
476 } // namespace webkit | 475 } // namespace webkit |
OLD | NEW |