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

Side by Side Diff: tests/PDFPrimitivesTest.cpp

Issue 941023005: PDF : New factory function for SkPDFDevice (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase on 07d5947 Created 5 years, 10 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
« no previous file with comments | « tests/CanvasTest.cpp ('k') | no next file » | 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 2010 The Android Open Source Project 2 * Copyright 2010 The Android Open Source Project
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 "SkData.h" 10 #include "SkData.h"
11 #include "SkFlate.h" 11 #include "SkFlate.h"
12 #include "SkImageEncoder.h" 12 #include "SkImageEncoder.h"
13 #include "SkMatrix.h" 13 #include "SkMatrix.h"
14 #include "SkPDFCanon.h"
14 #include "SkPDFCatalog.h" 15 #include "SkPDFCatalog.h"
15 #include "SkPDFDevice.h" 16 #include "SkPDFDevice.h"
16 #include "SkPDFStream.h" 17 #include "SkPDFStream.h"
17 #include "SkPDFTypes.h" 18 #include "SkPDFTypes.h"
18 #include "SkReadBuffer.h" 19 #include "SkReadBuffer.h"
19 #include "SkScalar.h" 20 #include "SkScalar.h"
20 #include "SkStream.h" 21 #include "SkStream.h"
21 #include "SkTypes.h" 22 #include "SkTypes.h"
22 #include "Test.h" 23 #include "Test.h"
23 24
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 REPORTER_ASSERT(reporter, stub.get() == catalog.getSubstituteObject(proxy)); 209 REPORTER_ASSERT(reporter, stub.get() == catalog.getSubstituteObject(proxy));
209 REPORTER_ASSERT(reporter, proxy.get() != catalog.getSubstituteObject(stub)); 210 REPORTER_ASSERT(reporter, proxy.get() != catalog.getSubstituteObject(stub));
210 } 211 }
211 212
212 // This test used to assert without the fix submitted for 213 // This test used to assert without the fix submitted for
213 // http://code.google.com/p/skia/issues/detail?id=1083. 214 // http://code.google.com/p/skia/issues/detail?id=1083.
214 // SKP files might have invalid glyph ids. This test ensures they are ignored, 215 // SKP files might have invalid glyph ids. This test ensures they are ignored,
215 // and there is no assert on input data in Debug mode. 216 // and there is no assert on input data in Debug mode.
216 static void test_issue1083() { 217 static void test_issue1083() {
217 SkISize pageSize = SkISize::Make(100, 100); 218 SkISize pageSize = SkISize::Make(100, 100);
218 SkAutoTUnref<SkPDFDevice> dev(new SkPDFDevice(pageSize, pageSize, SkMatrix:: I())); 219 SkPDFCanon canon;
219 220 SkAutoTUnref<SkPDFDevice> dev(SkPDFDevice::Create(pageSize, 72.0f, &canon));
220 SkCanvas c(dev); 221 SkCanvas c(dev);
221 SkPaint paint; 222 SkPaint paint;
222 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); 223 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
223 224
224 uint16_t glyphID = 65000; 225 uint16_t glyphID = 65000;
225 c.drawText(&glyphID, 2, 0, 0, paint); 226 c.drawText(&glyphID, 2, 0, 0, paint);
226 227
227 SkPDFDocument doc; 228 SkPDFDocument doc;
228 doc.appendPage(dev); 229 doc.appendPage(dev);
229 230
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 str->append(")"); 348 str->append(")");
348 } 349 }
349 #endif 350 #endif
350 351
351 }; 352 };
352 353
353 // Check that PDF rendering of image filters successfully falls back to 354 // Check that PDF rendering of image filters successfully falls back to
354 // CPU rasterization. 355 // CPU rasterization.
355 DEF_TEST(PDFImageFilter, reporter) { 356 DEF_TEST(PDFImageFilter, reporter) {
356 SkISize pageSize = SkISize::Make(100, 100); 357 SkISize pageSize = SkISize::Make(100, 100);
357 SkAutoTUnref<SkPDFDevice> device(new SkPDFDevice(pageSize, pageSize, SkMatri x::I())); 358 SkPDFCanon canon;
358 SkCanvas canvas(device.get()); 359 SkAutoTUnref<SkPDFDevice> pdfDevice(
360 SkPDFDevice::Create(pageSize, 72.0f, &canon));
361 SkCanvas canvas(pdfDevice.get());
359 SkAutoTUnref<DummyImageFilter> filter(new DummyImageFilter()); 362 SkAutoTUnref<DummyImageFilter> filter(new DummyImageFilter());
360 363
361 // Filter just created; should be unvisited. 364 // Filter just created; should be unvisited.
362 REPORTER_ASSERT(reporter, !filter->visited()); 365 REPORTER_ASSERT(reporter, !filter->visited());
363 SkPaint paint; 366 SkPaint paint;
364 paint.setImageFilter(filter.get()); 367 paint.setImageFilter(filter.get());
365 canvas.drawRect(SkRect::MakeWH(100, 100), paint); 368 canvas.drawRect(SkRect::MakeWH(100, 100), paint);
366 369
367 // Filter was used in rendering; should be visited. 370 // Filter was used in rendering; should be visited.
368 REPORTER_ASSERT(reporter, filter->visited()); 371 REPORTER_ASSERT(reporter, filter->visited());
369 } 372 }
OLDNEW
« no previous file with comments | « tests/CanvasTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698