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

Unified 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-30 (Monday) 10:22:51 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/xps/SkConstexprMath.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/xps/SkXPSDevice.cpp
diff --git a/src/xps/SkXPSDevice.cpp b/src/xps/SkXPSDevice.cpp
index aef9dc8baf8659b751c966becb167a9ccd3adcda..eb983fc0d73bea670487a35f8a877fa2ddcd20b7 100644
--- a/src/xps/SkXPSDevice.cpp
+++ b/src/xps/SkXPSDevice.cpp
@@ -18,9 +18,9 @@
#include <XpsObjectModel.h>
#include <T2EmbApi.h>
#include <FontSub.h>
+#include <limits>
#include "SkColor.h"
-#include "SkConstexprMath.h"
#include "SkData.h"
#include "SkDraw.h"
#include "SkEndian.h"
@@ -190,6 +190,10 @@ bool SkXPSDevice::beginSheet(
return true;
}
+template <typename T> static constexpr size_t sk_digits_in() {
+ return static_cast<size_t>(std::numeric_limits<T>::digits10 + 1);
+}
+
HRESULT SkXPSDevice::createXpsThumbnail(IXpsOMPage* page,
const unsigned int pageNum,
IXpsOMImageResource** image) {
@@ -202,10 +206,9 @@ HRESULT SkXPSDevice::createXpsThumbnail(IXpsOMPage* page,
"Could not create thumbnail generator.");
SkTScopedComPtr<IOpcPartUri> partUri;
- static const size_t size = SkTUMax<
- SK_ARRAY_COUNT(L"/Documents/1/Metadata/.png") + SK_DIGITS_IN(pageNum),
- SK_ARRAY_COUNT(L"/Metadata/" L_GUID_ID L".png")
- >::value;
+ constexpr size_t size = SkTMax(
bungeman-skia 2016/05/31 18:07:17 I've gone back and forth now trying to figure out
+ SK_ARRAY_COUNT(L"/Documents/1/Metadata/.png") + sk_digits_in<decltype(pageNum)>(),
+ SK_ARRAY_COUNT(L"/Metadata/" L_GUID_ID L".png"));
wchar_t buffer[size];
if (pageNum > 0) {
swprintf_s(buffer, size, L"/Documents/1/Metadata/%u.png", pageNum);
@@ -229,8 +232,9 @@ HRESULT SkXPSDevice::createXpsThumbnail(IXpsOMPage* page,
HRESULT SkXPSDevice::createXpsPage(const XPS_SIZE& pageSize,
IXpsOMPage** page) {
- static const size_t size = SK_ARRAY_COUNT(L"/Documents/1/Pages/.fpage")
- + SK_DIGITS_IN(fCurrentPage);
+ constexpr size_t size =
+ SK_ARRAY_COUNT(L"/Documents/1/Pages/.fpage")
+ + sk_digits_in<decltype(fCurrentPage)>();
wchar_t buffer[size];
swprintf_s(buffer, size, L"/Documents/1/Pages/%u.fpage",
this->fCurrentPage);
« 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