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

Side by Side Diff: tests/FontHostStreamTest.cpp

Issue 184233003: remove deprecated use of bitmap config from tests (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 9 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 | « tests/DrawTextTest.cpp ('k') | tests/PixelRefTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkColor.h" 10 #include "SkColor.h"
11 #include "SkFontHost.h" 11 #include "SkFontHost.h"
12 #include "SkGraphics.h" 12 #include "SkGraphics.h"
13 #include "SkPaint.h" 13 #include "SkPaint.h"
14 #include "SkPoint.h" 14 #include "SkPoint.h"
15 #include "SkRect.h" 15 #include "SkRect.h"
16 #include "SkStream.h" 16 #include "SkStream.h"
17 #include "SkTypeface.h" 17 #include "SkTypeface.h"
18 #include "SkTypes.h" 18 #include "SkTypes.h"
19 #include "Test.h" 19 #include "Test.h"
20 20
21 static const SkColor bgColor = SK_ColorWHITE; 21 static const SkColor bgColor = SK_ColorWHITE;
22 22
23 static void create(SkBitmap* bm, SkIRect bound, SkBitmap::Config config) { 23 static void create(SkBitmap* bm, SkIRect bound) {
24 bm->setConfig(config, bound.width(), bound.height()); 24 bm->allocN32Pixels(bound.width(), bound.height());
25 bm->allocPixels();
26 } 25 }
27 26
28 static void drawBG(SkCanvas* canvas) { 27 static void drawBG(SkCanvas* canvas) {
29 canvas->drawColor(bgColor); 28 canvas->drawColor(bgColor);
30 } 29 }
31 30
32 /** Assumes that the ref draw was completely inside ref canvas -- 31 /** Assumes that the ref draw was completely inside ref canvas --
33 implies that everything outside is "bgColor". 32 implies that everything outside is "bgColor".
34 Checks that all overlap is the same and that all non-overlap on the 33 Checks that all overlap is the same and that all non-overlap on the
35 ref is "bgColor". 34 ref is "bgColor".
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 SkPaint paint; 68 SkPaint paint;
70 paint.setColor(SK_ColorGRAY); 69 paint.setColor(SK_ColorGRAY);
71 paint.setTextSize(SkIntToScalar(30)); 70 paint.setTextSize(SkIntToScalar(30));
72 71
73 SkTypeface* fTypeface = SkTypeface::CreateFromName("Georgia", 72 SkTypeface* fTypeface = SkTypeface::CreateFromName("Georgia",
74 SkTypeface::kNormal); 73 SkTypeface::kNormal);
75 SkSafeUnref(paint.setTypeface(fTypeface)); 74 SkSafeUnref(paint.setTypeface(fTypeface));
76 75
77 SkIRect origRect = SkIRect::MakeWH(64, 64); 76 SkIRect origRect = SkIRect::MakeWH(64, 64);
78 SkBitmap origBitmap; 77 SkBitmap origBitmap;
79 create(&origBitmap, origRect, SkBitmap::kARGB_8888_Config); 78 create(&origBitmap, origRect);
80 SkCanvas origCanvas(origBitmap); 79 SkCanvas origCanvas(origBitmap);
81 80
82 SkIRect streamRect = SkIRect::MakeWH(64, 64); 81 SkIRect streamRect = SkIRect::MakeWH(64, 64);
83 SkBitmap streamBitmap; 82 SkBitmap streamBitmap;
84 create(&streamBitmap, streamRect, SkBitmap::kARGB_8888_Config); 83 create(&streamBitmap, streamRect);
85 SkCanvas streamCanvas(streamBitmap); 84 SkCanvas streamCanvas(streamBitmap);
86 85
87 SkPoint point = SkPoint::Make(24, 32); 86 SkPoint point = SkPoint::Make(24, 32);
88 87
89 // Test: origTypeface and streamTypeface from orig data draw the same 88 // Test: origTypeface and streamTypeface from orig data draw the same
90 drawBG(&origCanvas); 89 drawBG(&origCanvas);
91 origCanvas.drawText("A", 1, point.fX, point.fY, paint); 90 origCanvas.drawText("A", 1, point.fX, point.fY, paint);
92 91
93 SkTypeface* origTypeface = paint.getTypeface(); 92 SkTypeface* origTypeface = paint.getTypeface();
94 SkAutoTUnref<SkTypeface> aur; 93 SkAutoTUnref<SkTypeface> aur;
95 if (NULL == origTypeface) { 94 if (NULL == origTypeface) {
96 origTypeface = aur.reset(SkTypeface::RefDefault()); 95 origTypeface = aur.reset(SkTypeface::RefDefault());
97 } 96 }
98 97
99 int ttcIndex; 98 int ttcIndex;
100 SkAutoTUnref<SkStream> fontData(origTypeface->openStream(&ttcIndex)); 99 SkAutoTUnref<SkStream> fontData(origTypeface->openStream(&ttcIndex));
101 SkTypeface* streamTypeface = SkTypeface::CreateFromStream(fontData); 100 SkTypeface* streamTypeface = SkTypeface::CreateFromStream(fontData);
102 SkSafeUnref(paint.setTypeface(streamTypeface)); 101 SkSafeUnref(paint.setTypeface(streamTypeface));
103 drawBG(&streamCanvas); 102 drawBG(&streamCanvas);
104 streamCanvas.drawPosText("A", 1, &point, paint); 103 streamCanvas.drawPosText("A", 1, &point, paint);
105 104
106 REPORTER_ASSERT(reporter, 105 REPORTER_ASSERT(reporter,
107 compare(origBitmap, origRect, streamBitmap, streamRect)) ; 106 compare(origBitmap, origRect, streamBitmap, streamRect)) ;
108 } 107 }
109 //Make sure the typeface is deleted and removed. 108 //Make sure the typeface is deleted and removed.
110 SkGraphics::PurgeFontCache(); 109 SkGraphics::PurgeFontCache();
111 } 110 }
OLDNEW
« no previous file with comments | « tests/DrawTextTest.cpp ('k') | tests/PixelRefTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698