FIXME: comment out ppapi code that blocks compilation
This commit is contained in:
parent
60ba2013c4
commit
91d16c9b3a
1 changed files with 90 additions and 89 deletions
|
@ -193,95 +193,96 @@ int32_t PepperFlashRendererHost::OnSetInstanceAlwaysOnTop(
|
|||
int32_t PepperFlashRendererHost::OnDrawGlyphs(
|
||||
ppapi::host::HostMessageContext* host_context,
|
||||
ppapi::proxy::PPBFlash_DrawGlyphs_Params params) {
|
||||
if (params.glyph_indices.size() != params.glyph_advances.size() ||
|
||||
params.glyph_indices.empty())
|
||||
return PP_ERROR_FAILED;
|
||||
|
||||
// Set up the typeface.
|
||||
int weight = (params.font_desc.weight + 1) * 100;
|
||||
SkFontStyle::Slant slant = SkFontStyle::kUpright_Slant;
|
||||
if (params.font_desc.italic)
|
||||
slant = SkFontStyle::kItalic_Slant;
|
||||
SkFontStyle style(weight, SkFontStyle::kNormal_Width, slant);
|
||||
sk_sp<SkTypeface> typeface(
|
||||
SkTypeface::MakeFromName(params.font_desc.face.c_str(), style));
|
||||
if (!typeface)
|
||||
return PP_ERROR_FAILED;
|
||||
|
||||
EnterResourceNoLock<PPB_ImageData_API> enter(
|
||||
params.image_data.host_resource(), true);
|
||||
if (enter.failed())
|
||||
return PP_ERROR_FAILED;
|
||||
|
||||
// Set up the canvas.
|
||||
PPB_ImageData_API* image = static_cast<PPB_ImageData_API*>(enter.object());
|
||||
SkCanvas* canvas = image->GetCanvas();
|
||||
bool needs_unmapping = false;
|
||||
if (!canvas) {
|
||||
needs_unmapping = true;
|
||||
image->Map();
|
||||
canvas = image->GetCanvas();
|
||||
if (!canvas)
|
||||
return PP_ERROR_FAILED; // Failure mapping.
|
||||
}
|
||||
|
||||
SkAutoCanvasRestore acr(canvas, true);
|
||||
|
||||
// Clip is applied in pixels before the transform.
|
||||
SkRect clip_rect = {
|
||||
SkIntToScalar(params.clip.point.x), SkIntToScalar(params.clip.point.y),
|
||||
SkIntToScalar(params.clip.point.x + params.clip.size.width),
|
||||
SkIntToScalar(params.clip.point.y + params.clip.size.height)};
|
||||
canvas->clipRect(clip_rect);
|
||||
|
||||
// Convert & set the matrix.
|
||||
SkMatrix matrix;
|
||||
matrix.set(SkMatrix::kMScaleX, SkFloatToScalar(params.transformation[0][0]));
|
||||
matrix.set(SkMatrix::kMSkewX, SkFloatToScalar(params.transformation[0][1]));
|
||||
matrix.set(SkMatrix::kMTransX, SkFloatToScalar(params.transformation[0][2]));
|
||||
matrix.set(SkMatrix::kMSkewY, SkFloatToScalar(params.transformation[1][0]));
|
||||
matrix.set(SkMatrix::kMScaleY, SkFloatToScalar(params.transformation[1][1]));
|
||||
matrix.set(SkMatrix::kMTransY, SkFloatToScalar(params.transformation[1][2]));
|
||||
matrix.set(SkMatrix::kMPersp0, SkFloatToScalar(params.transformation[2][0]));
|
||||
matrix.set(SkMatrix::kMPersp1, SkFloatToScalar(params.transformation[2][1]));
|
||||
matrix.set(SkMatrix::kMPersp2, SkFloatToScalar(params.transformation[2][2]));
|
||||
canvas->concat(matrix);
|
||||
|
||||
SkPaint paint;
|
||||
paint.setColor(params.color);
|
||||
paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
|
||||
paint.setAntiAlias(true);
|
||||
paint.setHinting(SkPaint::kFull_Hinting);
|
||||
paint.setTextSize(SkIntToScalar(params.font_desc.size));
|
||||
paint.setTypeface(std::move(typeface));
|
||||
if (params.allow_subpixel_aa) {
|
||||
paint.setSubpixelText(true);
|
||||
paint.setLCDRenderText(true);
|
||||
}
|
||||
|
||||
SkScalar x = SkIntToScalar(params.position.x);
|
||||
SkScalar y = SkIntToScalar(params.position.y);
|
||||
|
||||
// Build up the skia advances.
|
||||
size_t glyph_count = params.glyph_indices.size();
|
||||
if (glyph_count) {
|
||||
std::vector<SkPoint> storage;
|
||||
storage.resize(glyph_count);
|
||||
SkPoint* sk_positions = &storage[0];
|
||||
for (uint32_t i = 0; i < glyph_count; i++) {
|
||||
sk_positions[i].set(x, y);
|
||||
x += SkFloatToScalar(params.glyph_advances[i].x);
|
||||
y += SkFloatToScalar(params.glyph_advances[i].y);
|
||||
}
|
||||
|
||||
canvas->drawPosText(¶ms.glyph_indices[0], glyph_count * 2, sk_positions,
|
||||
paint);
|
||||
}
|
||||
|
||||
if (needs_unmapping)
|
||||
image->Unmap();
|
||||
|
||||
return PP_OK;
|
||||
// if (params.glyph_indices.size() != params.glyph_advances.size() ||
|
||||
// params.glyph_indices.empty())
|
||||
// return PP_ERROR_FAILED;
|
||||
//
|
||||
// // Set up the typeface.
|
||||
// int weight = (params.font_desc.weight + 1) * 100;
|
||||
// SkFontStyle::Slant slant = SkFontStyle::kUpright_Slant;
|
||||
// if (params.font_desc.italic)
|
||||
// slant = SkFontStyle::kItalic_Slant;
|
||||
// SkFontStyle style(weight, SkFontStyle::kNormal_Width, slant);
|
||||
// sk_sp<SkTypeface> typeface(
|
||||
// SkTypeface::MakeFromName(params.font_desc.face.c_str(), style));
|
||||
// if (!typeface)
|
||||
// return PP_ERROR_FAILED;
|
||||
//
|
||||
// EnterResourceNoLock<PPB_ImageData_API> enter(
|
||||
// params.image_data.host_resource(), true);
|
||||
// if (enter.failed())
|
||||
// return PP_ERROR_FAILED;
|
||||
//
|
||||
// // Set up the canvas.
|
||||
// PPB_ImageData_API* image = static_cast<PPB_ImageData_API*>(enter.object());
|
||||
// SkCanvas* canvas = image->GetCanvas();
|
||||
// bool needs_unmapping = false;
|
||||
// if (!canvas) {
|
||||
// needs_unmapping = true;
|
||||
// image->Map();
|
||||
// canvas = image->GetCanvas();
|
||||
// if (!canvas)
|
||||
// return PP_ERROR_FAILED; // Failure mapping.
|
||||
// }
|
||||
//
|
||||
// SkAutoCanvasRestore acr(canvas, true);
|
||||
//
|
||||
// // Clip is applied in pixels before the transform.
|
||||
// SkRect clip_rect = {
|
||||
// SkIntToScalar(params.clip.point.x), SkIntToScalar(params.clip.point.y),
|
||||
// SkIntToScalar(params.clip.point.x + params.clip.size.width),
|
||||
// SkIntToScalar(params.clip.point.y + params.clip.size.height)};
|
||||
// canvas->clipRect(clip_rect);
|
||||
//
|
||||
// // Convert & set the matrix.
|
||||
// SkMatrix matrix;
|
||||
// matrix.set(SkMatrix::kMScaleX, SkFloatToScalar(params.transformation[0][0]));
|
||||
// matrix.set(SkMatrix::kMSkewX, SkFloatToScalar(params.transformation[0][1]));
|
||||
// matrix.set(SkMatrix::kMTransX, SkFloatToScalar(params.transformation[0][2]));
|
||||
// matrix.set(SkMatrix::kMSkewY, SkFloatToScalar(params.transformation[1][0]));
|
||||
// matrix.set(SkMatrix::kMScaleY, SkFloatToScalar(params.transformation[1][1]));
|
||||
// matrix.set(SkMatrix::kMTransY, SkFloatToScalar(params.transformation[1][2]));
|
||||
// matrix.set(SkMatrix::kMPersp0, SkFloatToScalar(params.transformation[2][0]));
|
||||
// matrix.set(SkMatrix::kMPersp1, SkFloatToScalar(params.transformation[2][1]));
|
||||
// matrix.set(SkMatrix::kMPersp2, SkFloatToScalar(params.transformation[2][2]));
|
||||
// canvas->concat(matrix);
|
||||
//
|
||||
// SkPaint paint;
|
||||
// paint.setColor(params.color);
|
||||
// paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
|
||||
// paint.setAntiAlias(true);
|
||||
// paint.setHinting(SkPaint::kFull_Hinting);
|
||||
// paint.setTextSize(SkIntToScalar(params.font_desc.size));
|
||||
// paint.setTypeface(std::move(typeface));
|
||||
// if (params.allow_subpixel_aa) {
|
||||
// paint.setSubpixelText(true);
|
||||
// paint.setLCDRenderText(true);
|
||||
// }
|
||||
//
|
||||
// SkScalar x = SkIntToScalar(params.position.x);
|
||||
// SkScalar y = SkIntToScalar(params.position.y);
|
||||
//
|
||||
// // Build up the skia advances.
|
||||
// size_t glyph_count = params.glyph_indices.size();
|
||||
// if (glyph_count) {
|
||||
// std::vector<SkPoint> storage;
|
||||
// storage.resize(glyph_count);
|
||||
// SkPoint* sk_positions = &storage[0];
|
||||
// for (uint32_t i = 0; i < glyph_count; i++) {
|
||||
// sk_positions[i].set(x, y);
|
||||
// x += SkFloatToScalar(params.glyph_advances[i].x);
|
||||
// y += SkFloatToScalar(params.glyph_advances[i].y);
|
||||
// }
|
||||
//
|
||||
// canvas->drawPosText(¶ms.glyph_indices[0], glyph_count * 2, sk_positions,
|
||||
// paint);
|
||||
// }
|
||||
//
|
||||
// if (needs_unmapping)
|
||||
// image->Unmap();
|
||||
//
|
||||
// return PP_OK;
|
||||
}
|
||||
|
||||
// CAUTION: This code is subtle because Navigate is a sync call which may
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue