OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkGpuDevice.h" | 8 #include "SkGpuDevice.h" |
9 | 9 |
10 #include "effects/GrBicubicEffect.h" | 10 #include "effects/GrBicubicEffect.h" |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 | 163 |
164 SkGpuDevice* SkGpuDevice::Create(GrContext* context, const SkImageInfo& origInfo
, | 164 SkGpuDevice* SkGpuDevice::Create(GrContext* context, const SkImageInfo& origInfo
, |
165 int sampleCount) { | 165 int sampleCount) { |
166 if (kUnknown_SkColorType == origInfo.colorType() || | 166 if (kUnknown_SkColorType == origInfo.colorType() || |
167 origInfo.width() < 0 || origInfo.height() < 0) { | 167 origInfo.width() < 0 || origInfo.height() < 0) { |
168 return NULL; | 168 return NULL; |
169 } | 169 } |
170 | 170 |
171 SkColorType ct = origInfo.colorType(); | 171 SkColorType ct = origInfo.colorType(); |
172 SkAlphaType at = origInfo.alphaType(); | 172 SkAlphaType at = origInfo.alphaType(); |
173 // TODO: perhas we can loosen this check now that colortype is more detailed | 173 // TODO: perhaps we can loosen this check now that colortype is more detaile
d |
174 // e.g. can we support both RGBA and BGRA here? | 174 // e.g. can we support both RGBA and BGRA here? |
175 if (kRGB_565_SkColorType == ct) { | 175 if (kRGB_565_SkColorType == ct) { |
176 at = kOpaque_SkAlphaType; // force this setting | 176 at = kOpaque_SkAlphaType; // force this setting |
177 } else { | 177 } else { |
178 ct = kN32_SkColorType; | 178 ct = kN32_SkColorType; |
179 if (kOpaque_SkAlphaType != at) { | 179 if (kOpaque_SkAlphaType != at) { |
180 at = kPremul_SkAlphaType; // force this setting | 180 at = kPremul_SkAlphaType; // force this setting |
181 } | 181 } |
182 } | 182 } |
183 const SkImageInfo info = SkImageInfo::Make(origInfo.width(), origInfo.height
(), ct, at); | 183 const SkImageInfo info = SkImageInfo::Make(origInfo.width(), origInfo.height
(), ct, at); |
(...skipping 1669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1853 | 1853 |
1854 SkBitmap bm; | 1854 SkBitmap bm; |
1855 wrap_texture(layers[i]->texture(), | 1855 wrap_texture(layers[i]->texture(), |
1856 !layers[i]->isAtlased() ? layers[i]->rect().width() | 1856 !layers[i]->isAtlased() ? layers[i]->rect().width() |
1857 : layers[i]->texture()->width(), | 1857 : layers[i]->texture()->width(), |
1858 !layers[i]->isAtlased() ? layers[i]->rect().height() | 1858 !layers[i]->isAtlased() ? layers[i]->rect().height() |
1859 : layers[i]->texture()->height(), | 1859 : layers[i]->texture()->height(), |
1860 &bm); | 1860 &bm); |
1861 layerInfo->fImage = SkImage::NewTexture(bm); | 1861 layerInfo->fImage = SkImage::NewTexture(bm); |
1862 | 1862 |
1863 // TODO: copy this? | 1863 layerInfo->fPaint = layers[i]->paint() ? SkNEW_ARGS(SkPaint, (*layers[i]
->paint())) : NULL; |
1864 layerInfo->fPaint = layers[i]->paint(); | |
1865 | 1864 |
1866 layerInfo->fSrcRect = SkIRect::MakeXYWH(layers[i]->rect().fLeft, | 1865 layerInfo->fSrcRect = SkIRect::MakeXYWH(layers[i]->rect().fLeft, |
1867 layers[i]->rect().fTop, | 1866 layers[i]->rect().fTop, |
1868 layers[i]->rect().width(), | 1867 layers[i]->rect().width(), |
1869 layers[i]->rect().height()); | 1868 layers[i]->rect().height()); |
1870 } | 1869 } |
1871 } | 1870 } |
1872 | 1871 |
1873 bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* mainCanvas, const SkPicture
* picture, | 1872 bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* mainCanvas, const SkPicture
* picture, |
1874 const SkMatrix* matrix, const SkPaint
* paint) { | 1873 const SkMatrix* matrix, const SkPaint
* paint) { |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1954 GrLayerHoister::UnlockLayers(fContext->getLayerCache(), picture); | 1953 GrLayerHoister::UnlockLayers(fContext->getLayerCache(), picture); |
1955 | 1954 |
1956 return true; | 1955 return true; |
1957 } | 1956 } |
1958 | 1957 |
1959 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { | 1958 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { |
1960 // We always return a transient cache, so it is freed after each | 1959 // We always return a transient cache, so it is freed after each |
1961 // filter traversal. | 1960 // filter traversal. |
1962 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); | 1961 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); |
1963 } | 1962 } |
OLD | NEW |