Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: webkit/plugins/ppapi/ppb_flash_impl_linux.cc

Issue 6282007: First pass at making the proxy handle multiple renderers. This associates the... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/plugins/ppapi/ppb_flash_impl.cc ('k') | webkit/plugins/ppapi/ppb_font_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "skia/ext/platform_canvas.h" 7 #include "skia/ext/platform_canvas.h"
8 #include "ppapi/c/pp_point.h" 8 #include "ppapi/c/pp_point.h"
9 #include "ppapi/c/pp_rect.h" 9 #include "ppapi/c/pp_rect.h"
10 #include "ppapi/c/dev/ppb_font_dev.h" 10 #include "ppapi/c/dev/ppb_font_dev.h"
11 #include "third_party/skia/include/core/SkCanvas.h" 11 #include "third_party/skia/include/core/SkCanvas.h"
12 #include "third_party/skia/include/core/SkMatrix.h" 12 #include "third_party/skia/include/core/SkMatrix.h"
13 #include "third_party/skia/include/core/SkPaint.h" 13 #include "third_party/skia/include/core/SkPaint.h"
14 #include "third_party/skia/include/core/SkPoint.h" 14 #include "third_party/skia/include/core/SkPoint.h"
15 #include "third_party/skia/include/core/SkTemplates.h" 15 #include "third_party/skia/include/core/SkTemplates.h"
16 #include "third_party/skia/include/core/SkTypeface.h" 16 #include "third_party/skia/include/core/SkTypeface.h"
17 #include "webkit/plugins/ppapi/ppb_image_data_impl.h" 17 #include "webkit/plugins/ppapi/ppb_image_data_impl.h"
18 #include "webkit/plugins/ppapi/var.h" 18 #include "webkit/plugins/ppapi/var.h"
19 19
20 namespace webkit { 20 namespace webkit {
21 namespace ppapi { 21 namespace ppapi {
22 22
23 bool PPB_Flash_Impl::DrawGlyphs(PP_Instance, 23 PP_Bool PPB_Flash_Impl::DrawGlyphs(PP_Instance,
24 PP_Resource pp_image_data, 24 PP_Resource pp_image_data,
25 const PP_FontDescription_Dev* font_desc, 25 const PP_FontDescription_Dev* font_desc,
26 uint32_t color, 26 uint32_t color,
27 PP_Point position, 27 PP_Point position,
28 PP_Rect clip, 28 PP_Rect clip,
29 const float transformation[3][3], 29 const float transformation[3][3],
30 uint32_t glyph_count, 30 uint32_t glyph_count,
31 const uint16_t glyph_indices[], 31 const uint16_t glyph_indices[],
32 const PP_Point glyph_advances[]) { 32 const PP_Point glyph_advances[]) {
33 scoped_refptr<PPB_ImageData_Impl> image_resource( 33 scoped_refptr<PPB_ImageData_Impl> image_resource(
34 Resource::GetAs<PPB_ImageData_Impl>(pp_image_data)); 34 Resource::GetAs<PPB_ImageData_Impl>(pp_image_data));
35 if (!image_resource.get()) 35 if (!image_resource.get())
36 return false; 36 return PP_FALSE;
37 ImageDataAutoMapper mapper(image_resource); 37 ImageDataAutoMapper mapper(image_resource);
38 if (!mapper.is_valid()) 38 if (!mapper.is_valid())
39 return false; 39 return PP_FALSE;
40 40
41 // Set up the typeface. 41 // Set up the typeface.
42 scoped_refptr<StringVar> face_name(StringVar::FromPPVar(font_desc->face)); 42 scoped_refptr<StringVar> face_name(StringVar::FromPPVar(font_desc->face));
43 if (!face_name) 43 if (!face_name)
44 return false; 44 return PP_FALSE;
45 int style = SkTypeface::kNormal; 45 int style = SkTypeface::kNormal;
46 if (font_desc->weight >= PP_FONTWEIGHT_BOLD) 46 if (font_desc->weight >= PP_FONTWEIGHT_BOLD)
47 style |= SkTypeface::kBold; 47 style |= SkTypeface::kBold;
48 if (font_desc->italic) 48 if (font_desc->italic)
49 style |= SkTypeface::kItalic; 49 style |= SkTypeface::kItalic;
50 SkTypeface* typeface = 50 SkTypeface* typeface =
51 SkTypeface::CreateFromName(face_name->value().c_str(), 51 SkTypeface::CreateFromName(face_name->value().c_str(),
52 static_cast<SkTypeface::Style>(style)); 52 static_cast<SkTypeface::Style>(style));
53 if (!typeface) 53 if (!typeface)
54 return false; 54 return PP_FALSE;
55 55
56 // Set up the canvas. 56 // Set up the canvas.
57 SkCanvas* canvas = image_resource->mapped_canvas(); 57 SkCanvas* canvas = image_resource->mapped_canvas();
58 canvas->save(); 58 canvas->save();
59 59
60 // Clip is applied in pixels before the transform. 60 // Clip is applied in pixels before the transform.
61 SkRect clip_rect = { clip.point.x, clip.point.y, 61 SkRect clip_rect = { clip.point.x, clip.point.y,
62 clip.point.x + clip.size.width, 62 clip.point.x + clip.size.width,
63 clip.point.y + clip.size.height }; 63 clip.point.y + clip.size.height };
64 canvas->clipRect(clip_rect); 64 canvas->clipRect(clip_rect);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 SkPoint* sk_positions = storage.get(); 98 SkPoint* sk_positions = storage.get();
99 for (uint32_t i = 0; i < glyph_count; i++) { 99 for (uint32_t i = 0; i < glyph_count; i++) {
100 sk_positions[i].set(x, y); 100 sk_positions[i].set(x, y);
101 x += SkFloatToScalar(glyph_advances[i].x); 101 x += SkFloatToScalar(glyph_advances[i].x);
102 y += SkFloatToScalar(glyph_advances[i].y); 102 y += SkFloatToScalar(glyph_advances[i].y);
103 } 103 }
104 104
105 canvas->drawPosText(glyph_indices, glyph_count * 2, sk_positions, paint); 105 canvas->drawPosText(glyph_indices, glyph_count * 2, sk_positions, paint);
106 106
107 canvas->restore(); 107 canvas->restore();
108 return true; 108 return PP_TRUE;
109 } 109 }
110 110
111 } // namespace ppapi 111 } // namespace ppapi
112 } // namespace webkit 112 } // namespace webkit
113 113
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/ppb_flash_impl.cc ('k') | webkit/plugins/ppapi/ppb_font_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698