зеркало из https://github.com/mozilla/moz-skia.git
use SkColorType instead of SkBitmap::Config in views/effects
R=scroggo@google.com, reed@google.com TBR=scroggo Author: reed@chromium.org Review URL: https://codereview.chromium.org/168843002 git-svn-id: http://skia.googlecode.com/svn/trunk@13469 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
Родитель
6e58cf36f0
Коммит
e24ad23ae6
|
@ -32,8 +32,8 @@ public:
|
||||||
|
|
||||||
const SkBitmap& getBitmap() const { return fBitmap; }
|
const SkBitmap& getBitmap() const { return fBitmap; }
|
||||||
|
|
||||||
void setConfig(SkBitmap::Config);
|
void setColorType(SkColorType);
|
||||||
void resize(int width, int height, SkBitmap::Config config = SkBitmap::kNo_Config);
|
void resize(int width, int height, SkColorType = kUnknown_SkColorType);
|
||||||
|
|
||||||
bool isDirty() const { return !fDirtyRgn.isEmpty(); }
|
bool isDirty() const { return !fDirtyRgn.isEmpty(); }
|
||||||
bool update(SkIRect* updateArea);
|
bool update(SkIRect* updateArea);
|
||||||
|
@ -81,7 +81,7 @@ protected:
|
||||||
virtual bool onSetFocusView(SkView* focus);
|
virtual bool onSetFocusView(SkView* focus);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SkBitmap::Config fConfig;
|
SkColorType fColorType;
|
||||||
SkBitmap fBitmap;
|
SkBitmap fBitmap;
|
||||||
SkRegion fDirtyRgn;
|
SkRegion fDirtyRgn;
|
||||||
|
|
||||||
|
|
|
@ -442,39 +442,6 @@ static void SkGMRegistyToSampleRegistry() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
#include <CoreFoundation/CoreFoundation.h>
|
|
||||||
#include <CoreFoundation/CFURLAccess.h>
|
|
||||||
|
|
||||||
static void testpdf() {
|
|
||||||
CFStringRef path = CFStringCreateWithCString(NULL, "/test.pdf",
|
|
||||||
kCFStringEncodingUTF8);
|
|
||||||
CFURLRef url = CFURLCreateWithFileSystemPath(NULL, path,
|
|
||||||
kCFURLPOSIXPathStyle,
|
|
||||||
false);
|
|
||||||
CFRelease(path);
|
|
||||||
CGRect box = CGRectMake(0, 0, 8*72, 10*72);
|
|
||||||
CGContextRef cg = CGPDFContextCreateWithURL(url, &box, NULL);
|
|
||||||
CFRelease(url);
|
|
||||||
|
|
||||||
CGContextBeginPage(cg, &box);
|
|
||||||
CGRect r = CGRectMake(10, 10, 40 + 0.5, 50 + 0.5);
|
|
||||||
CGContextFillEllipseInRect(cg, r);
|
|
||||||
CGContextEndPage(cg);
|
|
||||||
CGContextRelease(cg);
|
|
||||||
|
|
||||||
if (false) {
|
|
||||||
SkBitmap bm;
|
|
||||||
bm.setConfig(SkBitmap::kA8_Config, 64, 64);
|
|
||||||
bm.allocPixels();
|
|
||||||
bm.eraseColor(SK_ColorTRANSPARENT);
|
|
||||||
|
|
||||||
SkCanvas canvas(bm);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
enum FlipAxisEnum {
|
enum FlipAxisEnum {
|
||||||
|
@ -991,8 +958,7 @@ SampleWindow::SampleWindow(void* hwnd, int argc, char** argv, DeviceManager* dev
|
||||||
fSlideMenu = new SkOSMenu;
|
fSlideMenu = new SkOSMenu;
|
||||||
this->addMenu(fSlideMenu);
|
this->addMenu(fSlideMenu);
|
||||||
|
|
||||||
// this->setConfig(SkBitmap::kRGB_565_Config);
|
this->setColorType(kPMColor_SkColorType);
|
||||||
this->setConfig(SkBitmap::kARGB_8888_Config);
|
|
||||||
this->setVisibleP(true);
|
this->setVisibleP(true);
|
||||||
this->setClipToBounds(false);
|
this->setClipToBounds(false);
|
||||||
|
|
||||||
|
@ -1600,17 +1566,18 @@ void SampleWindow::afterChild(SkView* child, SkCanvas* canvas) {
|
||||||
canvas->setDrawFilter(NULL);
|
canvas->setDrawFilter(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SkBitmap::Config gConfigCycle[] = {
|
static SkColorType gColorTypeCycle[] = {
|
||||||
SkBitmap::kNo_Config, // none -> none
|
kUnknown_SkColorType, // none -> none
|
||||||
SkBitmap::kNo_Config, // a8 -> none
|
kUnknown_SkColorType, // a8 -> none
|
||||||
SkBitmap::kNo_Config, // index8 -> none
|
kARGB_4444_SkColorType, // 565 -> 4444
|
||||||
SkBitmap::kARGB_4444_Config, // 565 -> 4444
|
kPMColor_SkColorType, // 4444 -> 8888
|
||||||
SkBitmap::kARGB_8888_Config, // 4444 -> 8888
|
kRGB_565_SkColorType, // 8888 -> 565
|
||||||
SkBitmap::kRGB_565_Config // 8888 -> 565
|
kRGB_565_SkColorType, // 8888 -> 565
|
||||||
|
kUnknown_SkColorType, // index8 -> none
|
||||||
};
|
};
|
||||||
|
|
||||||
static SkBitmap::Config cycle_configs(SkBitmap::Config c) {
|
static SkColorType cycle_configs(SkColorType c) {
|
||||||
return gConfigCycle[c];
|
return gColorTypeCycle[c];
|
||||||
}
|
}
|
||||||
|
|
||||||
void SampleWindow::changeZoomLevel(float delta) {
|
void SampleWindow::changeZoomLevel(float delta) {
|
||||||
|
@ -2007,7 +1974,7 @@ bool SampleWindow::onHandleKey(SkKey key) {
|
||||||
if (USE_ARROWS_FOR_ZOOM) {
|
if (USE_ARROWS_FOR_ZOOM) {
|
||||||
this->changeZoomLevel(-1.f / 32.f);
|
this->changeZoomLevel(-1.f / 32.f);
|
||||||
} else {
|
} else {
|
||||||
this->setConfig(cycle_configs(this->getBitmap().config()));
|
this->setColorType(cycle_configs(this->getBitmap().colorType()));
|
||||||
this->updateTitle();
|
this->updateTitle();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -306,9 +306,9 @@ void SkAlphaThresholdFilterImpl::flatten(SkWriteBuffer& buffer) const {
|
||||||
bool SkAlphaThresholdFilterImpl::onFilterImage(Proxy*, const SkBitmap& src,
|
bool SkAlphaThresholdFilterImpl::onFilterImage(Proxy*, const SkBitmap& src,
|
||||||
const SkMatrix& matrix, SkBitmap* dst,
|
const SkMatrix& matrix, SkBitmap* dst,
|
||||||
SkIPoint* offset) const {
|
SkIPoint* offset) const {
|
||||||
SkASSERT(src.config() == SkBitmap::kARGB_8888_Config);
|
SkASSERT(src.colorType() == kPMColor_SkColorType);
|
||||||
|
|
||||||
if (src.config() != SkBitmap::kARGB_8888_Config) {
|
if (src.colorType() != kPMColor_SkColorType) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,7 @@ bool SkBicubicImageFilter::onFilterImage(Proxy* proxy,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (src.config() != SkBitmap::kARGB_8888_Config) {
|
if (src.colorType() != kPMColor_SkColorType) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -143,7 +143,7 @@ bool SkBlurImageFilter::onFilterImage(Proxy* proxy,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (src.config() != SkBitmap::kARGB_8888_Config) {
|
if (src.colorType() != kPMColor_SkColorType) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -195,10 +195,9 @@ static bool draw_rrect_into_mask(const SkRRect rrect, SkMask* mask) {
|
||||||
// FIXME: This code duplicates code in draw_rects_into_mask, below. Is there a
|
// FIXME: This code duplicates code in draw_rects_into_mask, below. Is there a
|
||||||
// clean way to share more code?
|
// clean way to share more code?
|
||||||
SkBitmap bitmap;
|
SkBitmap bitmap;
|
||||||
bitmap.setConfig(SkBitmap::kA8_Config,
|
bitmap.installPixels(SkImageInfo::MakeA8(mask->fBounds.width(),
|
||||||
mask->fBounds.width(), mask->fBounds.height(),
|
mask->fBounds.height()),
|
||||||
mask->fRowBytes);
|
mask->fImage, mask->fRowBytes, NULL, NULL);
|
||||||
bitmap.setPixels(mask->fImage);
|
|
||||||
|
|
||||||
SkCanvas canvas(bitmap);
|
SkCanvas canvas(bitmap);
|
||||||
canvas.translate(-SkIntToScalar(mask->fBounds.left()),
|
canvas.translate(-SkIntToScalar(mask->fBounds.left()),
|
||||||
|
@ -216,10 +215,11 @@ static bool draw_rects_into_mask(const SkRect rects[], int count, SkMask* mask)
|
||||||
}
|
}
|
||||||
|
|
||||||
SkBitmap bitmap;
|
SkBitmap bitmap;
|
||||||
bitmap.setConfig(SkBitmap::kA8_Config,
|
bitmap.installPixels(SkImageInfo::Make(mask->fBounds.width(),
|
||||||
mask->fBounds.width(), mask->fBounds.height(),
|
mask->fBounds.height(),
|
||||||
mask->fRowBytes);
|
kAlpha_8_SkColorType,
|
||||||
bitmap.setPixels(mask->fImage);
|
kPremul_SkAlphaType),
|
||||||
|
mask->fImage, mask->fRowBytes, NULL, NULL);
|
||||||
|
|
||||||
SkCanvas canvas(bitmap);
|
SkCanvas canvas(bitmap);
|
||||||
canvas.translate(-SkIntToScalar(mask->fBounds.left()),
|
canvas.translate(-SkIntToScalar(mask->fBounds.left()),
|
||||||
|
|
|
@ -204,8 +204,8 @@ bool SkDisplacementMapEffect::onFilterImage(Proxy* proxy,
|
||||||
(displInput && !displInput->filterImage(proxy, src, ctm, &displ, &displOffset))) {
|
(displInput && !displInput->filterImage(proxy, src, ctm, &displ, &displOffset))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ((displ.config() != SkBitmap::kARGB_8888_Config) ||
|
if ((displ.colorType() != kPMColor_SkColorType) ||
|
||||||
(color.config() != SkBitmap::kARGB_8888_Config)) {
|
(color.colorType() != kPMColor_SkColorType)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -122,8 +122,9 @@ bool SkLayerRasterizer::onRasterize(const SkPath& path, const SkMatrix& matrix,
|
||||||
translatedMatrix.postTranslate(-SkIntToScalar(mask->fBounds.fLeft),
|
translatedMatrix.postTranslate(-SkIntToScalar(mask->fBounds.fLeft),
|
||||||
-SkIntToScalar(mask->fBounds.fTop));
|
-SkIntToScalar(mask->fBounds.fTop));
|
||||||
|
|
||||||
device.setConfig(SkBitmap::kA8_Config, mask->fBounds.width(), mask->fBounds.height(), mask->fRowBytes);
|
device.installPixels(SkImageInfo::MakeA8(mask->fBounds.width(),
|
||||||
device.setPixels(mask->fImage);
|
mask->fBounds.height()),
|
||||||
|
mask->fImage, mask->fRowBytes, NULL, NULL);
|
||||||
|
|
||||||
draw.fBitmap = &device;
|
draw.fBitmap = &device;
|
||||||
draw.fMatrix = &drawMatrix;
|
draw.fMatrix = &drawMatrix;
|
||||||
|
|
|
@ -933,7 +933,7 @@ bool SkDiffuseLightingImageFilter::onFilterImage(Proxy* proxy,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (src.config() != SkBitmap::kARGB_8888_Config) {
|
if (src.colorType() != kPMColor_SkColorType) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
SkAutoLockPixels alp(src);
|
SkAutoLockPixels alp(src);
|
||||||
|
@ -1026,7 +1026,7 @@ bool SkSpecularLightingImageFilter::onFilterImage(Proxy* proxy,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (src.config() != SkBitmap::kARGB_8888_Config) {
|
if (src.colorType() != kPMColor_SkColorType) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
SkAutoLockPixels alp(src);
|
SkAutoLockPixels alp(src);
|
||||||
|
|
|
@ -282,11 +282,11 @@ void SkMagnifierImageFilter::flatten(SkWriteBuffer& buffer) const {
|
||||||
bool SkMagnifierImageFilter::onFilterImage(Proxy*, const SkBitmap& src,
|
bool SkMagnifierImageFilter::onFilterImage(Proxy*, const SkBitmap& src,
|
||||||
const SkMatrix&, SkBitmap* dst,
|
const SkMatrix&, SkBitmap* dst,
|
||||||
SkIPoint* offset) const {
|
SkIPoint* offset) const {
|
||||||
SkASSERT(src.config() == SkBitmap::kARGB_8888_Config);
|
SkASSERT(src.colorType() == kPMColor_SkColorType);
|
||||||
SkASSERT(fSrcRect.width() < src.width());
|
SkASSERT(fSrcRect.width() < src.width());
|
||||||
SkASSERT(fSrcRect.height() < src.height());
|
SkASSERT(fSrcRect.height() < src.height());
|
||||||
|
|
||||||
if ((src.config() != SkBitmap::kARGB_8888_Config) ||
|
if ((src.colorType() != kPMColor_SkColorType) ||
|
||||||
(fSrcRect.width() >= src.width()) ||
|
(fSrcRect.width() >= src.width()) ||
|
||||||
(fSrcRect.height() >= src.height())) {
|
(fSrcRect.height() >= src.height())) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -260,7 +260,7 @@ bool SkMatrixConvolutionImageFilter::onFilterImage(Proxy* proxy,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (src.config() != SkBitmap::kARGB_8888_Config) {
|
if (src.colorType() != kPMColor_SkColorType) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -150,7 +150,7 @@ bool SkMorphologyImageFilter::filterImageGeneric(SkMorphologyImageFilter::Proc p
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (src.config() != SkBitmap::kARGB_8888_Config) {
|
if (src.colorType() != kPMColor_SkColorType) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,13 +23,13 @@ bool SkTransparentShader::setContext(const SkBitmap& device,
|
||||||
uint32_t SkTransparentShader::getFlags() {
|
uint32_t SkTransparentShader::getFlags() {
|
||||||
uint32_t flags = this->INHERITED::getFlags();
|
uint32_t flags = this->INHERITED::getFlags();
|
||||||
|
|
||||||
switch (fDevice->config()) {
|
switch (fDevice->colorType()) {
|
||||||
case SkBitmap::kRGB_565_Config:
|
case kRGB_565_SkColorType:
|
||||||
flags |= kHasSpan16_Flag;
|
flags |= kHasSpan16_Flag;
|
||||||
if (fAlpha == 255)
|
if (fAlpha == 255)
|
||||||
flags |= kOpaqueAlpha_Flag;
|
flags |= kOpaqueAlpha_Flag;
|
||||||
break;
|
break;
|
||||||
case SkBitmap::kARGB_8888_Config:
|
case kPMColor_SkColorType:
|
||||||
if (fAlpha == 255 && fDevice->isOpaque())
|
if (fAlpha == 255 && fDevice->isOpaque())
|
||||||
flags |= kOpaqueAlpha_Flag;
|
flags |= kOpaqueAlpha_Flag;
|
||||||
break;
|
break;
|
||||||
|
@ -42,8 +42,8 @@ uint32_t SkTransparentShader::getFlags() {
|
||||||
void SkTransparentShader::shadeSpan(int x, int y, SkPMColor span[], int count) {
|
void SkTransparentShader::shadeSpan(int x, int y, SkPMColor span[], int count) {
|
||||||
unsigned scale = SkAlpha255To256(fAlpha);
|
unsigned scale = SkAlpha255To256(fAlpha);
|
||||||
|
|
||||||
switch (fDevice->config()) {
|
switch (fDevice->colorType()) {
|
||||||
case SkBitmap::kARGB_8888_Config:
|
case kPMColor_SkColorType:
|
||||||
if (scale == 256) {
|
if (scale == 256) {
|
||||||
SkPMColor* src = fDevice->getAddr32(x, y);
|
SkPMColor* src = fDevice->getAddr32(x, y);
|
||||||
if (src != span) {
|
if (src != span) {
|
||||||
|
@ -56,7 +56,7 @@ void SkTransparentShader::shadeSpan(int x, int y, SkPMColor span[], int count) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SkBitmap::kRGB_565_Config: {
|
case kRGB_565_SkColorType: {
|
||||||
const uint16_t* src = fDevice->getAddr16(x, y);
|
const uint16_t* src = fDevice->getAddr16(x, y);
|
||||||
if (scale == 256) {
|
if (scale == 256) {
|
||||||
for (int i = count - 1; i >= 0; --i) {
|
for (int i = count - 1; i >= 0; --i) {
|
||||||
|
@ -78,10 +78,7 @@ void SkTransparentShader::shadeSpan(int x, int y, SkPMColor span[], int count) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SkBitmap::kIndex8_Config:
|
case kAlpha_8_SkColorType: {
|
||||||
SkDEBUGFAIL("index8 not supported as a destination device");
|
|
||||||
break;
|
|
||||||
case SkBitmap::kA8_Config: {
|
|
||||||
const uint8_t* src = fDevice->getAddr8(x, y);
|
const uint8_t* src = fDevice->getAddr8(x, y);
|
||||||
if (scale == 256) {
|
if (scale == 256) {
|
||||||
for (int i = count - 1; i >= 0; --i) {
|
for (int i = count - 1; i >= 0; --i) {
|
||||||
|
@ -94,13 +91,14 @@ void SkTransparentShader::shadeSpan(int x, int y, SkPMColor span[], int count) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: // to avoid warnings
|
default:
|
||||||
|
SkDEBUGFAIL("colorType not supported as a destination device");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkTransparentShader::shadeSpan16(int x, int y, uint16_t span[], int count) {
|
void SkTransparentShader::shadeSpan16(int x, int y, uint16_t span[], int count) {
|
||||||
SkASSERT(fDevice->config() == SkBitmap::kRGB_565_Config);
|
SkASSERT(fDevice->colorType() == kRGB_565_SkColorType);
|
||||||
|
|
||||||
uint16_t* src = fDevice->getAddr16(x, y);
|
uint16_t* src = fDevice->getAddr16(x, y);
|
||||||
if (src != span) {
|
if (src != span) {
|
||||||
|
|
|
@ -583,7 +583,7 @@ void SkGradientShaderBase::getGradientTableBitmap(SkBitmap* bitmap) const {
|
||||||
if (fMapper) {
|
if (fMapper) {
|
||||||
// force our cahce32pixelref to be built
|
// force our cahce32pixelref to be built
|
||||||
(void)this->getCache32();
|
(void)this->getCache32();
|
||||||
bitmap->setConfig(SkBitmap::kARGB_8888_Config, kCache32Count, 1);
|
bitmap->setConfig(SkImageInfo::MakeN32Premul(kCache32Count, 1));
|
||||||
bitmap->setPixelRef(fCache32PixelRef);
|
bitmap->setPixelRef(fCache32PixelRef);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -624,7 +624,7 @@ void SkGradientShaderBase::getGradientTableBitmap(SkBitmap* bitmap) const {
|
||||||
if (!gCache->find(storage.get(), size, bitmap)) {
|
if (!gCache->find(storage.get(), size, bitmap)) {
|
||||||
// force our cahce32pixelref to be built
|
// force our cahce32pixelref to be built
|
||||||
(void)this->getCache32();
|
(void)this->getCache32();
|
||||||
bitmap->setConfig(SkBitmap::kARGB_8888_Config, kCache32Count, 1);
|
bitmap->setConfig(SkImageInfo::MakeN32Premul(kCache32Count, 1));
|
||||||
bitmap->setPixelRef(fCache32PixelRef);
|
bitmap->setPixelRef(fCache32PixelRef);
|
||||||
|
|
||||||
gCache->add(storage.get(), size, *bitmap);
|
gCache->add(storage.get(), size, *bitmap);
|
||||||
|
@ -1043,7 +1043,7 @@ GrGradientEffect::GrGradientEffect(GrContext* ctx,
|
||||||
desc.fHeight = 32;
|
desc.fHeight = 32;
|
||||||
desc.fRowHeight = bitmap.height();
|
desc.fRowHeight = bitmap.height();
|
||||||
desc.fContext = ctx;
|
desc.fContext = ctx;
|
||||||
desc.fConfig = SkBitmapConfig2GrPixelConfig(bitmap.config());
|
desc.fConfig = SkImageInfo2GrPixelConfig(bitmap.colorType(), bitmap.alphaType());
|
||||||
fAtlas = GrTextureStripAtlas::GetAtlas(desc);
|
fAtlas = GrTextureStripAtlas::GetAtlas(desc);
|
||||||
SkASSERT(NULL != fAtlas);
|
SkASSERT(NULL != fAtlas);
|
||||||
|
|
||||||
|
|
|
@ -221,11 +221,11 @@ SkCanvasState* SkCanvasStateUtils::CaptureCanvasState(SkCanvas* canvas) {
|
||||||
layerState->width = bitmap.width();
|
layerState->width = bitmap.width();
|
||||||
layerState->height = bitmap.height();
|
layerState->height = bitmap.height();
|
||||||
|
|
||||||
switch (bitmap.config()) {
|
switch (bitmap.colorType()) {
|
||||||
case SkBitmap::kARGB_8888_Config:
|
case kPMColor_SkColorType:
|
||||||
layerState->raster.config = kARGB_8888_RasterConfig;
|
layerState->raster.config = kARGB_8888_RasterConfig;
|
||||||
break;
|
break;
|
||||||
case SkBitmap::kRGB_565_Config:
|
case kRGB_565_SkColorType:
|
||||||
layerState->raster.config = kRGB_565_RasterConfig;
|
layerState->raster.config = kRGB_565_RasterConfig;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -279,25 +279,24 @@ static SkCanvas* create_canvas_from_canvas_layer(const SkCanvasLayerState& layer
|
||||||
SkASSERT(kRaster_CanvasBackend == layerState.type);
|
SkASSERT(kRaster_CanvasBackend == layerState.type);
|
||||||
|
|
||||||
SkBitmap bitmap;
|
SkBitmap bitmap;
|
||||||
SkBitmap::Config config =
|
SkColorType colorType =
|
||||||
layerState.raster.config == kARGB_8888_RasterConfig ? SkBitmap::kARGB_8888_Config :
|
layerState.raster.config == kARGB_8888_RasterConfig ? kPMColor_SkColorType :
|
||||||
layerState.raster.config == kRGB_565_RasterConfig ? SkBitmap::kRGB_565_Config :
|
layerState.raster.config == kRGB_565_RasterConfig ? kRGB_565_SkColorType :
|
||||||
SkBitmap::kNo_Config;
|
kUnknown_SkColorType;
|
||||||
|
|
||||||
if (config == SkBitmap::kNo_Config) {
|
if (colorType == kUnknown_SkColorType) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bitmap.setConfig(config, layerState.width, layerState.height,
|
bitmap.installPixels(SkImageInfo::Make(layerState.width, layerState.height,
|
||||||
layerState.raster.rowBytes);
|
colorType, kPremul_SkAlphaType),
|
||||||
bitmap.setPixels(layerState.raster.pixels);
|
layerState.raster.pixels, layerState.raster.rowBytes,
|
||||||
|
NULL, NULL);
|
||||||
|
|
||||||
SkASSERT(!bitmap.empty());
|
SkASSERT(!bitmap.empty());
|
||||||
SkASSERT(!bitmap.isNull());
|
SkASSERT(!bitmap.isNull());
|
||||||
|
|
||||||
// create a device & canvas
|
SkAutoTUnref<SkCanvas> canvas(SkNEW_ARGS(SkCanvas, (bitmap)));
|
||||||
SkAutoTUnref<SkBitmapDevice> device(SkNEW_ARGS(SkBitmapDevice, (bitmap)));
|
|
||||||
SkAutoTUnref<SkCanvas> canvas(SkNEW_ARGS(SkCanvas, (device.get())));
|
|
||||||
|
|
||||||
// setup the matrix and clip
|
// setup the matrix and clip
|
||||||
setup_canvas_from_MC_state(layerState.mcState, canvas.get());
|
setup_canvas_from_MC_state(layerState.mcState, canvas.get());
|
||||||
|
|
|
@ -22,13 +22,19 @@ static bool getBitmapInfo(const SkBitmap& bm,
|
||||||
*upscaleTo32 = false;
|
*upscaleTo32 = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (bm.config()) {
|
switch (bm.colorType()) {
|
||||||
case SkBitmap::kRGB_565_Config:
|
case kRGB_565_SkColorType:
|
||||||
|
#if 0
|
||||||
|
// doesn't see quite right. Are they thinking 1555?
|
||||||
|
*bitsPerComponent = 5;
|
||||||
|
*info = kCGBitmapByteOrder16Little | kCGImageAlphaNone;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
if (upscaleTo32) {
|
if (upscaleTo32) {
|
||||||
*upscaleTo32 = true;
|
*upscaleTo32 = true;
|
||||||
}
|
}
|
||||||
// fall through
|
// fall through
|
||||||
case SkBitmap::kARGB_8888_Config:
|
case kPMColor_SkColorType:
|
||||||
*bitsPerComponent = 8;
|
*bitsPerComponent = 8;
|
||||||
#if SK_PMCOLOR_BYTE_ORDER(R,G,B,A)
|
#if SK_PMCOLOR_BYTE_ORDER(R,G,B,A)
|
||||||
*info = kCGBitmapByteOrder32Big;
|
*info = kCGBitmapByteOrder32Big;
|
||||||
|
@ -60,14 +66,7 @@ This will probably not work.
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
#if 0
|
case kARGB_4444_SkColorType:
|
||||||
case SkBitmap::kRGB_565_Config:
|
|
||||||
// doesn't see quite right. Are they thinking 1555?
|
|
||||||
*bitsPerComponent = 5;
|
|
||||||
*info = kCGBitmapByteOrder16Little | kCGImageAlphaNone;
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
case SkBitmap::kARGB_4444_Config:
|
|
||||||
*bitsPerComponent = 4;
|
*bitsPerComponent = 4;
|
||||||
*info = kCGBitmapByteOrder16Little;
|
*info = kCGBitmapByteOrder16Little;
|
||||||
if (bm.isOpaque()) {
|
if (bm.isOpaque()) {
|
||||||
|
|
|
@ -507,7 +507,7 @@ bool SkBitmapView::getBitmap(SkBitmap* bitmap) const
|
||||||
{
|
{
|
||||||
if (bitmap)
|
if (bitmap)
|
||||||
*bitmap = fBitmap;
|
*bitmap = fBitmap;
|
||||||
return fBitmap.getConfig() != SkBitmap::kNo_Config;
|
return fBitmap.colorType() != kUnknown_SkColorType;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkBitmapView::setBitmap(const SkBitmap* bitmap, bool viewOwnsPixels)
|
void SkBitmapView::setBitmap(const SkBitmap* bitmap, bool viewOwnsPixels)
|
||||||
|
@ -534,7 +534,7 @@ bool SkBitmapView::loadBitmapFromFile(const char path[])
|
||||||
|
|
||||||
void SkBitmapView::onDraw(SkCanvas* canvas)
|
void SkBitmapView::onDraw(SkCanvas* canvas)
|
||||||
{
|
{
|
||||||
if (fBitmap.getConfig() != SkBitmap::kNo_Config &&
|
if (fBitmap.colorType() != kUnknown_SkColorType &&
|
||||||
fBitmap.width() && fBitmap.height())
|
fBitmap.width() && fBitmap.height())
|
||||||
{
|
{
|
||||||
SkAutoCanvasRestore restore(canvas, true);
|
SkAutoCanvasRestore restore(canvas, true);
|
||||||
|
|
|
@ -51,9 +51,9 @@ SkWindow::SkWindow() : fFocusView(NULL) {
|
||||||
fWaitingOnInval = false;
|
fWaitingOnInval = false;
|
||||||
|
|
||||||
#ifdef SK_BUILD_FOR_WINCE
|
#ifdef SK_BUILD_FOR_WINCE
|
||||||
fConfig = SkBitmap::kRGB_565_Config;
|
fColorType = kRGB_565_SkColorType;
|
||||||
#else
|
#else
|
||||||
fConfig = SkBitmap::kARGB_8888_Config;
|
fColorType = kPMColor_SkColorType;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
fMatrix.reset();
|
fMatrix.reset();
|
||||||
|
@ -87,18 +87,18 @@ void SkWindow::postConcat(const SkMatrix& matrix) {
|
||||||
this->setMatrix(m);
|
this->setMatrix(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkWindow::setConfig(SkBitmap::Config config) {
|
void SkWindow::setColorType(SkColorType ct) {
|
||||||
this->resize(fBitmap.width(), fBitmap.height(), config);
|
this->resize(fBitmap.width(), fBitmap.height(), ct);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkWindow::resize(int width, int height, SkBitmap::Config config) {
|
void SkWindow::resize(int width, int height, SkColorType ct) {
|
||||||
if (config == SkBitmap::kNo_Config)
|
if (ct == kUnknown_SkColorType)
|
||||||
config = fConfig;
|
ct = fColorType;
|
||||||
|
|
||||||
if (width != fBitmap.width() || height != fBitmap.height() || config != fConfig) {
|
if (width != fBitmap.width() || height != fBitmap.height() || ct != fColorType) {
|
||||||
fConfig = config;
|
fColorType = ct;
|
||||||
fBitmap.setConfig(config, width, height, 0, kOpaque_SkAlphaType);
|
fBitmap.allocPixels(SkImageInfo::Make(width, height,
|
||||||
fBitmap.allocPixels();
|
ct, kPremul_SkAlphaType));
|
||||||
|
|
||||||
this->setSize(SkIntToScalar(width), SkIntToScalar(height));
|
this->setSize(SkIntToScalar(width), SkIntToScalar(height));
|
||||||
this->inval(NULL);
|
this->inval(NULL);
|
||||||
|
|
|
@ -57,7 +57,7 @@ SK_COMPILE_ASSERT(SK_SUPPORT_GPU, not_implemented_for_non_gpu_build);
|
||||||
size = [self convertSizeToBacking:self.frame.size];
|
size = [self convertSizeToBacking:self.frame.size];
|
||||||
#endif
|
#endif
|
||||||
fWind->resize((int) size.width, (int) size.height,
|
fWind->resize((int) size.width, (int) size.height,
|
||||||
SkBitmap::kARGB_8888_Config);
|
kPMColor_SkColorType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче