OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 fontHeight = 14; | 58 fontHeight = 14; |
59 | 59 |
60 OwnPtr<SkCanvas> canvas = adoptPtr(skia::CreateBitmapCanvas(ATLAS_SIZE, ATLA
S_SIZE, false /* opaque */)); | 60 OwnPtr<SkCanvas> canvas = adoptPtr(skia::CreateBitmapCanvas(ATLAS_SIZE, ATLA
S_SIZE, false /* opaque */)); |
61 | 61 |
62 PlatformContextSkia platformContext(canvas.get()); | 62 PlatformContextSkia platformContext(canvas.get()); |
63 platformContext.setDrawingToImageBuffer(true); | 63 platformContext.setDrawingToImageBuffer(true); |
64 GraphicsContext atlasContext(&platformContext); | 64 GraphicsContext atlasContext(&platformContext); |
65 | 65 |
66 // Clear the entire texture atlas to transparent before drawing fonts. | 66 // Clear the entire texture atlas to transparent before drawing fonts. |
67 atlasContext.setFillColor(Color(0, 0, 0, 0), ColorSpaceDeviceRGB); | 67 atlasContext.setFillColor(Color(0, 0, 0, 0), ColorSpaceDeviceRGB); |
68 atlasContext.fillRect(FloatRect(0, 0, ATLAS_SIZE, ATLAS_SIZE)); | 68 atlasContext.clearRect(FloatRect(0, 0, ATLAS_SIZE, ATLAS_SIZE)); |
69 | 69 |
70 // FIXME: monospace font does not work as expected. | 70 // FIXME: monospace font does not work as expected. |
71 FontDescription fontDescription; | 71 FontDescription fontDescription; |
72 fontDescription.setGenericFamily(FontDescription::MonospaceFamily); | 72 fontDescription.setGenericFamily(FontDescription::MonospaceFamily); |
73 fontDescription.setComputedSize(fontHeight); | 73 fontDescription.setComputedSize(fontHeight); |
74 | 74 |
75 FontCachePurgePreventer fontCachePurgePreventer; | 75 FontCachePurgePreventer fontCachePurgePreventer; |
76 | 76 |
77 int textHeight = fontDescription.computedPixelSize(); | 77 int textHeight = fontDescription.computedPixelSize(); |
78 IntPoint position(0, textHeight); | 78 IntPoint position(0, textHeight); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 position.setX(position.x() + textWidth); | 122 position.setX(position.x() + textWidth); |
123 } | 123 } |
124 | 124 |
125 SkBitmap copy; | 125 SkBitmap copy; |
126 const SkBitmap& source = canvas->getDevice()->accessBitmap(false); | 126 const SkBitmap& source = canvas->getDevice()->accessBitmap(false); |
127 source.copyTo(©, source.config()); | 127 source.copyTo(©, source.config()); |
128 return copy; | 128 return copy; |
129 } | 129 } |
130 | 130 |
131 } // namespace WebCore | 131 } // namespace WebCore |
OLD | NEW |