Add validation check to GrGpu::createTexture & minor SkGpuDevice cleanup
https://codereview.appspot.com/6821055/
git-svn-id: http://skia.googlecode.com/svn/trunk@6213 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
index 542c458..57eb085 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -126,6 +126,10 @@
GrTexture* GrGpu::createTexture(const GrTextureDesc& desc,
const void* srcData, size_t rowBytes) {
+ if (kUnknown_GrPixelConfig == desc.fConfig) {
+ return NULL;
+ }
+
this->handleDirtyContext();
GrTexture* tex = this->onCreateTexture(desc, srcData, rowBytes);
if (NULL != tex &&
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 8f62e28..b0f4ac1 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -204,7 +204,8 @@
SkGpuDevice::SkGpuDevice(GrContext* context,
SkBitmap::Config config,
int width,
- int height)
+ int height,
+ int sampleCount)
: SkDevice(config, width, height, false /*isOpaque*/) {
fDrawProcs = NULL;
@@ -218,14 +219,13 @@
if (config != SkBitmap::kRGB_565_Config) {
config = SkBitmap::kARGB_8888_Config;
}
- SkBitmap bm;
- bm.setConfig(config, width, height);
GrTextureDesc desc;
desc.fFlags = kRenderTarget_GrTextureFlagBit;
desc.fWidth = width;
desc.fHeight = height;
- desc.fConfig = SkBitmapConfig2GrPixelConfig(bm.config());
+ desc.fConfig = SkBitmapConfig2GrPixelConfig(config);
+ desc.fSampleCnt = sampleCount;
SkAutoTUnref<GrTexture> texture(fContext->createUncachedTexture(desc, NULL, 0));