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

Unified Diff: src/image/SkSurface_Raster.cpp

Issue 128933004: use SkImageInfo directly, instead of converting to SkBitmap::Config (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 11 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/image/SkSurface_Base.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/image/SkSurface_Raster.cpp
diff --git a/src/image/SkSurface_Raster.cpp b/src/image/SkSurface_Raster.cpp
index 48afe4fc206a27d4e194460929985e6a12a34c2b..1b218eb446222a1e64802c357b8a7ab3c28e362e 100644
--- a/src/image/SkSurface_Raster.cpp
+++ b/src/image/SkSurface_Raster.cpp
@@ -18,7 +18,7 @@ public:
static bool Valid(const SkImageInfo&, size_t rb = kIgnoreRowBytesValue);
SkSurface_Raster(const SkImageInfo&, void*, size_t rb);
- SkSurface_Raster(const SkImageInfo&, SkPixelRef*, size_t rb);
+ SkSurface_Raster(SkPixelRef*);
virtual SkCanvas* onNewCanvas() SK_OVERRIDE;
virtual SkSurface* onNewSurface(const SkImageInfo&) SK_OVERRIDE;
@@ -39,25 +39,21 @@ private:
bool SkSurface_Raster::Valid(const SkImageInfo& info, size_t rowBytes) {
static const size_t kMaxTotalSize = SK_MaxS32;
- SkBitmap::Config config = SkImageInfoToBitmapConfig(info);
-
int shift = 0;
- switch (config) {
- case SkBitmap::kA8_Config:
+ switch (info.fColorType) {
+ case kAlpha_8_SkColorType:
shift = 0;
break;
- case SkBitmap::kRGB_565_Config:
+ case kRGB_565_SkColorType:
shift = 1;
break;
- case SkBitmap::kARGB_8888_Config:
+ case kPMColor_SkColorType:
shift = 2;
break;
default:
return false;
}
- // TODO: examine colorspace
-
if (kIgnoreRowBytesValue == rowBytes) {
return true;
}
@@ -72,7 +68,7 @@ bool SkSurface_Raster::Valid(const SkImageInfo& info, size_t rowBytes) {
return false;
}
- uint64_t size = (uint64_t)info.fHeight * rowBytes;
+ uint64_t size = sk_64_mul(info.fHeight, rowBytes);
if (size > kMaxTotalSize) {
return false;
}
@@ -81,21 +77,23 @@ bool SkSurface_Raster::Valid(const SkImageInfo& info, size_t rowBytes) {
}
SkSurface_Raster::SkSurface_Raster(const SkImageInfo& info, void* pixels, size_t rb)
- : INHERITED(info.fWidth, info.fHeight) {
- SkBitmap::Config config = SkImageInfoToBitmapConfig(info);
- fBitmap.setConfig(config, info.fWidth, info.fHeight, rb, info.fAlphaType);
+ : INHERITED(info)
+{
+ fBitmap.setConfig(info, rb);
fBitmap.setPixels(pixels);
fWeOwnThePixels = false; // We are "Direct"
}
-SkSurface_Raster::SkSurface_Raster(const SkImageInfo& info, SkPixelRef* pr, size_t rb)
- : INHERITED(info.fWidth, info.fHeight) {
- SkBitmap::Config config = SkImageInfoToBitmapConfig(info);
- fBitmap.setConfig(config, info.fWidth, info.fHeight, rb, info.fAlphaType);
+SkSurface_Raster::SkSurface_Raster(SkPixelRef* pr)
+ : INHERITED(pr->info().fWidth, pr->info().fHeight)
+{
+ const SkImageInfo& info = pr->info();
+
+ fBitmap.setConfig(info, info.minRowBytes());
fBitmap.setPixelRef(pr);
fWeOwnThePixels = true;
- if (!SkAlphaTypeIsOpaque(info.fAlphaType)) {
+ if (!info.isOpaque()) {
fBitmap.eraseColor(SK_ColorTRANSPARENT);
}
}
@@ -159,5 +157,5 @@ SkSurface* SkSurface::NewRaster(const SkImageInfo& info) {
if (NULL == pr.get()) {
return NULL;
}
- return SkNEW_ARGS(SkSurface_Raster, (info, pr, info.minRowBytes()));
+ return SkNEW_ARGS(SkSurface_Raster, (pr));
}
« no previous file with comments | « src/image/SkSurface_Base.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698