FIXME: comment out ppapi code that blocks compilation

This commit is contained in:
Heilig Benedek 2018-05-15 03:58:25 +02:00 committed by Samuel Attard
parent 60ba2013c4
commit 91d16c9b3a

View file

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