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

Side by Side Diff: src/xps/SkXPSDevice.cpp

Issue 2000853003: SkXPS: clean up SkConstexprMath (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2016-05-23 (Monday) 12:51:27 EDT Created 4 years, 7 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 | « src/xps/SkConstexprMath.h ('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 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 "SkTypes.h" 8 #include "SkTypes.h"
9 #if defined(SK_BUILD_FOR_WIN32) 9 #if defined(SK_BUILD_FOR_WIN32)
10 10
11 #ifndef UNICODE 11 #ifndef UNICODE
12 #define UNICODE 12 #define UNICODE
13 #endif 13 #endif
14 #ifndef _UNICODE 14 #ifndef _UNICODE
15 #define _UNICODE 15 #define _UNICODE
16 #endif 16 #endif
17 #include <ObjBase.h> 17 #include <ObjBase.h>
18 #include <XpsObjectModel.h> 18 #include <XpsObjectModel.h>
19 #include <T2EmbApi.h> 19 #include <T2EmbApi.h>
20 #include <FontSub.h> 20 #include <FontSub.h>
21 #include <limits>
21 22
22 #include "SkColor.h" 23 #include "SkColor.h"
23 #include "SkConstexprMath.h"
24 #include "SkData.h" 24 #include "SkData.h"
25 #include "SkDraw.h" 25 #include "SkDraw.h"
26 #include "SkEndian.h" 26 #include "SkEndian.h"
27 #include "SkFindAndPlaceGlyph.h" 27 #include "SkFindAndPlaceGlyph.h"
28 #include "SkGeometry.h" 28 #include "SkGeometry.h"
29 #include "SkGlyphCache.h" 29 #include "SkGlyphCache.h"
30 #include "SkHRESULT.h" 30 #include "SkHRESULT.h"
31 #include "SkImageEncoder.h" 31 #include "SkImageEncoder.h"
32 #include "SkIStream.h" 32 #include "SkIStream.h"
33 #include "SkMaskFilter.h" 33 #include "SkMaskFilter.h"
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 IXpsOMImageResource** image) { 195 IXpsOMImageResource** image) {
196 SkTScopedComPtr<IXpsOMThumbnailGenerator> thumbnailGenerator; 196 SkTScopedComPtr<IXpsOMThumbnailGenerator> thumbnailGenerator;
197 HRM(CoCreateInstance( 197 HRM(CoCreateInstance(
198 CLSID_XpsOMThumbnailGenerator, 198 CLSID_XpsOMThumbnailGenerator,
199 nullptr, 199 nullptr,
200 CLSCTX_INPROC_SERVER, 200 CLSCTX_INPROC_SERVER,
201 IID_PPV_ARGS(&thumbnailGenerator)), 201 IID_PPV_ARGS(&thumbnailGenerator)),
202 "Could not create thumbnail generator."); 202 "Could not create thumbnail generator.");
203 203
204 SkTScopedComPtr<IOpcPartUri> partUri; 204 SkTScopedComPtr<IOpcPartUri> partUri;
205 static const size_t size = SkTUMax< 205 constexpr size_t size = SkTMax<size_t>(
bungeman-skia 2016/05/23 18:12:38 Both parameters are size_t now, so it shouldn't ne
hal.canary 2016/05/28 17:05:54 Done.
206 SK_ARRAY_COUNT(L"/Documents/1/Metadata/.png") + SK_DIGITS_IN(pageNum), 206 SK_ARRAY_COUNT(L"/Documents/1/Metadata/.png")
207 SK_ARRAY_COUNT(L"/Metadata/" L_GUID_ID L".png") 207 + static_cast<size_t>(std::numeric_limits<unsigned>::digits10 + 1),
bungeman-skia 2016/05/23 18:12:38 It's rather annoying that this indentation kinda h
hal.canary 2016/05/28 17:05:54 Done.
208 >::value; 208 SK_ARRAY_COUNT(L"/Metadata/" L_GUID_ID L".png"));
209 wchar_t buffer[size]; 209 wchar_t buffer[size];
210 if (pageNum > 0) { 210 if (pageNum > 0) {
211 swprintf_s(buffer, size, L"/Documents/1/Metadata/%u.png", pageNum); 211 swprintf_s(buffer, size, L"/Documents/1/Metadata/%u.png", pageNum);
212 } else { 212 } else {
213 wchar_t id[GUID_ID_LEN]; 213 wchar_t id[GUID_ID_LEN];
214 HR(this->createId(id, GUID_ID_LEN)); 214 HR(this->createId(id, GUID_ID_LEN));
215 swprintf_s(buffer, size, L"/Metadata/%s.png", id); 215 swprintf_s(buffer, size, L"/Metadata/%s.png", id);
216 } 216 }
217 HRM(this->fXpsFactory->CreatePartUri(buffer, &partUri), 217 HRM(this->fXpsFactory->CreatePartUri(buffer, &partUri),
218 "Could not create thumbnail part uri."); 218 "Could not create thumbnail part uri.");
219 219
220 HRM(thumbnailGenerator->GenerateThumbnail(page, 220 HRM(thumbnailGenerator->GenerateThumbnail(page,
221 XPS_IMAGE_TYPE_PNG, 221 XPS_IMAGE_TYPE_PNG,
222 XPS_THUMBNAIL_SIZE_LARGE, 222 XPS_THUMBNAIL_SIZE_LARGE,
223 partUri.get(), 223 partUri.get(),
224 image), 224 image),
225 "Could not generate thumbnail."); 225 "Could not generate thumbnail.");
226 226
227 return S_OK; 227 return S_OK;
228 } 228 }
229 229
230 HRESULT SkXPSDevice::createXpsPage(const XPS_SIZE& pageSize, 230 HRESULT SkXPSDevice::createXpsPage(const XPS_SIZE& pageSize,
231 IXpsOMPage** page) { 231 IXpsOMPage** page) {
232 static const size_t size = SK_ARRAY_COUNT(L"/Documents/1/Pages/.fpage") 232 constexpr size_t size =
233 + SK_DIGITS_IN(fCurrentPage); 233 SK_ARRAY_COUNT(L"/Documents/1/Pages/.fpage")
234 + static_cast<size_t>(std::numeric_limits<unsigned>::digits10 + 1);
234 wchar_t buffer[size]; 235 wchar_t buffer[size];
235 swprintf_s(buffer, size, L"/Documents/1/Pages/%u.fpage", 236 swprintf_s(buffer, size, L"/Documents/1/Pages/%u.fpage",
236 this->fCurrentPage); 237 this->fCurrentPage);
237 SkTScopedComPtr<IOpcPartUri> partUri; 238 SkTScopedComPtr<IOpcPartUri> partUri;
238 HRM(this->fXpsFactory->CreatePartUri(buffer, &partUri), 239 HRM(this->fXpsFactory->CreatePartUri(buffer, &partUri),
239 "Could not create page part uri."); 240 "Could not create page part uri.");
240 241
241 //If the language is unknown, use "und" (XPS Spec 2.3.5.1). 242 //If the language is unknown, use "und" (XPS Spec 2.3.5.1).
242 HRM(this->fXpsFactory->CreatePage(&pageSize, 243 HRM(this->fXpsFactory->CreatePage(&pageSize,
243 L"und", 244 L"und",
(...skipping 2027 matching lines...) Expand 10 before | Expand all | Expand 10 after
2271 //SkXPSDevice* dev = new SkXPSDevice(this); 2272 //SkXPSDevice* dev = new SkXPSDevice(this);
2272 //SkSize s = SkSize::Make(width, height); 2273 //SkSize s = SkSize::Make(width, height);
2273 //dev->BeginCanvas(s, s, SkMatrix::I()); 2274 //dev->BeginCanvas(s, s, SkMatrix::I());
2274 //return dev; 2275 //return dev;
2275 } 2276 }
2276 #endif 2277 #endif
2277 return new SkXPSDevice(this->fXpsFactory.get()); 2278 return new SkXPSDevice(this->fXpsFactory.get());
2278 } 2279 }
2279 2280
2280 #endif//defined(SK_BUILD_FOR_WIN32) 2281 #endif//defined(SK_BUILD_FOR_WIN32)
OLDNEW
« no previous file with comments | « src/xps/SkConstexprMath.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698