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

Unified Diff: experimental/PdfViewer/src/SkPdfRenderer.cpp

Issue 322963002: hide SkBitmap::setConfig (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 6 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 | « experimental/PdfViewer/pdf_viewer_main.cpp ('k') | gm/stroketext.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: experimental/PdfViewer/src/SkPdfRenderer.cpp
diff --git a/experimental/PdfViewer/src/SkPdfRenderer.cpp b/experimental/PdfViewer/src/SkPdfRenderer.cpp
index eea7c6e4775e2f77543093d06bbd7eca8aa67767..09953440932d71603e5b95aa62eb2c4754afa6dd 100644
--- a/experimental/PdfViewer/src/SkPdfRenderer.cpp
+++ b/experimental/PdfViewer/src/SkPdfRenderer.cpp
@@ -232,9 +232,7 @@ private:
// Utilities
static void setup_bitmap(SkBitmap* bitmap, int width, int height, SkColor color = SK_ColorWHITE) {
- bitmap->setConfig(SkBitmap::kARGB_8888_Config, width, height);
-
- bitmap->allocPixels();
+ bitmap->allocN32Pixels(width, height);
bitmap->eraseColor(color);
}
@@ -398,8 +396,8 @@ static SkBitmap* transferImageStreamToBitmap(const unsigned char* uncompressedSt
uncompressedStream += bytesPerLine;
}
- bitmap->setConfig(SkBitmap::kARGB_8888_Config, width, height);
- bitmap->setPixels(uncompressedStreamArgb);
+ const SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
+ bitmap->installPixels(info, uncompressedStreamArgb, info.minRowBytes());
}
else if ((colorSpace.equals("DeviceGray") || colorSpace.equals("Gray")) && bpc == 8) {
unsigned char* uncompressedStreamA8 = (unsigned char*)malloc(width * height);
@@ -414,9 +412,10 @@ static SkBitmap* transferImageStreamToBitmap(const unsigned char* uncompressedSt
uncompressedStream += bytesPerLine;
}
- bitmap->setConfig(transparencyMask ? SkBitmap::kA8_Config : SkBitmap::kIndex8_Config,
- width, height);
- bitmap->setPixels(uncompressedStreamA8, transparencyMask ? NULL : getGrayColortable());
+ const SkColorType ct = transparencyMask ? kAlpha_8_SkColorType : kIndex_8_SkColorType;
+ const SkImageInfo info = SkImageInfo::Make(width, height, ct, kPremul_SkAlphaType);
+ bitmap->installPixels(info, uncompressedStreamA8, info.minRowBytes(),
+ transparencyMask ? NULL : getGrayColortable(), NULL, NULL);
}
// TODO(edisonn): pass color space and context here?
@@ -519,9 +518,11 @@ static SkBitmap* getImageFromObjectCore(SkPdfContext* pdfContext,
// TODO(edisonn): assumes RGB for now, since it is the only one implemented
if (indexed) {
SkBitmap* bitmap = new SkBitmap();
- bitmap->setConfig(SkBitmap::kIndex8_Config, width, height);
- SkColorTable* colorTable = new SkColorTable(colors, cnt);
- bitmap->setPixels((void*)uncompressedStream, colorTable);
+ const SkImageInfo info = SkImageInfo::Make(width, height, kIndex_8_SkColorType,
+ kPremul_SkAlphaType);
+ SkAutoTUnref<SkColorTable> colorTable(new SkColorTable(colors, cnt));
+ bitmap->installPixels(info, (void*)uncompressedStream, info.minRowBytes(), colorTable,
+ NULL, NULL);
return bitmap;
}
« no previous file with comments | « experimental/PdfViewer/pdf_viewer_main.cpp ('k') | gm/stroketext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698