| 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 "chrome/renderer/pepper/pepper_flash_renderer_host.h" | 5 #include "chrome/renderer/pepper/pepper_flash_renderer_host.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "net/http/http_util.h" | 21 #include "net/http/http_util.h" |
| 22 #include "ppapi/c/pp_errors.h" | 22 #include "ppapi/c/pp_errors.h" |
| 23 #include "ppapi/c/trusted/ppb_browser_font_trusted.h" | 23 #include "ppapi/c/trusted/ppb_browser_font_trusted.h" |
| 24 #include "ppapi/host/dispatch_host_message.h" | 24 #include "ppapi/host/dispatch_host_message.h" |
| 25 #include "ppapi/proxy/host_dispatcher.h" | 25 #include "ppapi/proxy/host_dispatcher.h" |
| 26 #include "ppapi/proxy/ppapi_messages.h" | 26 #include "ppapi/proxy/ppapi_messages.h" |
| 27 #include "ppapi/proxy/resource_message_params.h" | 27 #include "ppapi/proxy/resource_message_params.h" |
| 28 #include "ppapi/proxy/serialized_structs.h" | 28 #include "ppapi/proxy/serialized_structs.h" |
| 29 #include "ppapi/thunk/enter.h" | 29 #include "ppapi/thunk/enter.h" |
| 30 #include "ppapi/thunk/ppb_image_data_api.h" | 30 #include "ppapi/thunk/ppb_image_data_api.h" |
| 31 #include "skia/ext/cdl_paint.h" |
| 31 #include "skia/ext/platform_canvas.h" | 32 #include "skia/ext/platform_canvas.h" |
| 32 #include "third_party/skia/include/core/SkCanvas.h" | 33 #include "third_party/skia/include/core/SkCanvas.h" |
| 33 #include "third_party/skia/include/core/SkMatrix.h" | 34 #include "third_party/skia/include/core/SkMatrix.h" |
| 34 #include "third_party/skia/include/core/SkPaint.h" | 35 #include "third_party/skia/include/core/SkPaint.h" |
| 35 #include "third_party/skia/include/core/SkPoint.h" | 36 #include "third_party/skia/include/core/SkPoint.h" |
| 36 #include "third_party/skia/include/core/SkTypeface.h" | 37 #include "third_party/skia/include/core/SkTypeface.h" |
| 37 #include "ui/gfx/geometry/rect.h" | 38 #include "ui/gfx/geometry/rect.h" |
| 38 #include "url/gurl.h" | 39 #include "url/gurl.h" |
| 39 | 40 |
| 40 using ppapi::thunk::EnterResourceNoLock; | 41 using ppapi::thunk::EnterResourceNoLock; |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 params.font_desc.face.c_str(), SkFontStyle::FromOldStyle(style))); | 215 params.font_desc.face.c_str(), SkFontStyle::FromOldStyle(style))); |
| 215 if (!typeface) | 216 if (!typeface) |
| 216 return PP_ERROR_FAILED; | 217 return PP_ERROR_FAILED; |
| 217 | 218 |
| 218 EnterResourceNoLock<PPB_ImageData_API> enter( | 219 EnterResourceNoLock<PPB_ImageData_API> enter( |
| 219 params.image_data.host_resource(), true); | 220 params.image_data.host_resource(), true); |
| 220 if (enter.failed()) | 221 if (enter.failed()) |
| 221 return PP_ERROR_FAILED; | 222 return PP_ERROR_FAILED; |
| 222 | 223 |
| 223 PPB_ImageData_API* image = static_cast<PPB_ImageData_API*>(enter.object()); | 224 PPB_ImageData_API* image = static_cast<PPB_ImageData_API*>(enter.object()); |
| 224 SkCanvas* canvas = image->GetCanvas(); | 225 CdlCanvas* canvas = image->GetCanvas(); |
| 225 bool needs_unmapping = false; | 226 bool needs_unmapping = false; |
| 226 if (!canvas) { | 227 if (!canvas) { |
| 227 needs_unmapping = true; | 228 needs_unmapping = true; |
| 228 image->Map(); | 229 image->Map(); |
| 229 canvas = image->GetCanvas(); | 230 canvas = image->GetCanvas(); |
| 230 if (!canvas) | 231 if (!canvas) |
| 231 return PP_ERROR_FAILED; // Failure mapping. | 232 return PP_ERROR_FAILED; // Failure mapping. |
| 232 } | 233 } |
| 233 | 234 |
| 234 SkAutoCanvasRestore acr(canvas, true); | 235 CdlAutoCanvasRestore acr(canvas, true); |
| 235 | 236 |
| 236 // Clip is applied in pixels before the transform. | 237 // Clip is applied in pixels before the transform. |
| 237 SkRect clip_rect = { | 238 SkRect clip_rect = { |
| 238 SkIntToScalar(params.clip.point.x), SkIntToScalar(params.clip.point.y), | 239 SkIntToScalar(params.clip.point.x), SkIntToScalar(params.clip.point.y), |
| 239 SkIntToScalar(params.clip.point.x + params.clip.size.width), | 240 SkIntToScalar(params.clip.point.x + params.clip.size.width), |
| 240 SkIntToScalar(params.clip.point.y + params.clip.size.height)}; | 241 SkIntToScalar(params.clip.point.y + params.clip.size.height)}; |
| 241 canvas->clipRect(clip_rect); | 242 canvas->clipRect(clip_rect); |
| 242 | 243 |
| 243 SkMatrix matrix; | 244 SkMatrix matrix; |
| 244 matrix.set(SkMatrix::kMScaleX, SkFloatToScalar(params.transformation[0][0])); | 245 matrix.set(SkMatrix::kMScaleX, SkFloatToScalar(params.transformation[0][0])); |
| 245 matrix.set(SkMatrix::kMSkewX, SkFloatToScalar(params.transformation[0][1])); | 246 matrix.set(SkMatrix::kMSkewX, SkFloatToScalar(params.transformation[0][1])); |
| 246 matrix.set(SkMatrix::kMTransX, SkFloatToScalar(params.transformation[0][2])); | 247 matrix.set(SkMatrix::kMTransX, SkFloatToScalar(params.transformation[0][2])); |
| 247 matrix.set(SkMatrix::kMSkewY, SkFloatToScalar(params.transformation[1][0])); | 248 matrix.set(SkMatrix::kMSkewY, SkFloatToScalar(params.transformation[1][0])); |
| 248 matrix.set(SkMatrix::kMScaleY, SkFloatToScalar(params.transformation[1][1])); | 249 matrix.set(SkMatrix::kMScaleY, SkFloatToScalar(params.transformation[1][1])); |
| 249 matrix.set(SkMatrix::kMTransY, SkFloatToScalar(params.transformation[1][2])); | 250 matrix.set(SkMatrix::kMTransY, SkFloatToScalar(params.transformation[1][2])); |
| 250 matrix.set(SkMatrix::kMPersp0, SkFloatToScalar(params.transformation[2][0])); | 251 matrix.set(SkMatrix::kMPersp0, SkFloatToScalar(params.transformation[2][0])); |
| 251 matrix.set(SkMatrix::kMPersp1, SkFloatToScalar(params.transformation[2][1])); | 252 matrix.set(SkMatrix::kMPersp1, SkFloatToScalar(params.transformation[2][1])); |
| 252 matrix.set(SkMatrix::kMPersp2, SkFloatToScalar(params.transformation[2][2])); | 253 matrix.set(SkMatrix::kMPersp2, SkFloatToScalar(params.transformation[2][2])); |
| 253 canvas->concat(matrix); | 254 canvas->concat(matrix); |
| 254 | 255 |
| 255 SkPaint paint; | 256 CdlPaint paint; |
| 256 paint.setColor(params.color); | 257 paint.setColor(params.color); |
| 257 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); | 258 paint.setTextEncoding(CdlPaint::kGlyphID_TextEncoding); |
| 258 paint.setAntiAlias(true); | 259 paint.setAntiAlias(true); |
| 259 paint.setHinting(SkPaint::kFull_Hinting); | 260 paint.setHinting(CdlPaint::kFull_Hinting); |
| 260 paint.setTextSize(SkIntToScalar(params.font_desc.size)); | 261 paint.setTextSize(SkIntToScalar(params.font_desc.size)); |
| 261 paint.setTypeface(std::move(typeface)); | 262 paint.setTypeface(std::move(typeface)); |
| 262 if (params.allow_subpixel_aa) { | 263 if (params.allow_subpixel_aa) { |
| 263 paint.setSubpixelText(true); | 264 paint.setSubpixelText(true); |
| 264 paint.setLCDRenderText(true); | 265 paint.setLCDRenderText(true); |
| 265 } | 266 } |
| 266 | 267 |
| 267 SkScalar x = SkIntToScalar(params.position.x); | 268 SkScalar x = SkIntToScalar(params.position.x); |
| 268 SkScalar y = SkIntToScalar(params.position.y); | 269 SkScalar y = SkIntToScalar(params.position.y); |
| 269 | 270 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 rect.point.x, rect.point.y, rect.size.width, rect.size.height))) | 371 rect.point.x, rect.point.y, rect.size.width, rect.size.height))) |
| 371 return PP_OK; | 372 return PP_OK; |
| 372 return PP_ERROR_FAILED; | 373 return PP_ERROR_FAILED; |
| 373 } | 374 } |
| 374 | 375 |
| 375 int32_t PepperFlashRendererHost::OnInvokePrinting( | 376 int32_t PepperFlashRendererHost::OnInvokePrinting( |
| 376 ppapi::host::HostMessageContext* host_context) { | 377 ppapi::host::HostMessageContext* host_context) { |
| 377 pdf::PepperPDFHost::InvokePrintingForInstance(pp_instance()); | 378 pdf::PepperPDFHost::InvokePrintingForInstance(pp_instance()); |
| 378 return PP_OK; | 379 return PP_OK; |
| 379 } | 380 } |
| OLD | NEW |