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

Side by Side Diff: src/gpu/SkGpuDevice.cpp

Issue 551463004: introduce Props to surface (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add new file Created 6 years, 3 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 unified diff | Download patch
« no previous file with comments | « src/gpu/SkGpuDevice.h ('k') | src/image/SkSurface.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 126
127 struct GrSkDrawProcs : public SkDrawProcs { 127 struct GrSkDrawProcs : public SkDrawProcs {
128 public: 128 public:
129 GrContext* fContext; 129 GrContext* fContext;
130 GrTextContext* fTextContext; 130 GrTextContext* fTextContext;
131 GrFontScaler* fFontScaler; // cached in the skia glyphcache 131 GrFontScaler* fFontScaler; // cached in the skia glyphcache
132 }; 132 };
133 133
134 /////////////////////////////////////////////////////////////////////////////// 134 ///////////////////////////////////////////////////////////////////////////////
135 135
136 SkGpuDevice* SkGpuDevice::Create(GrSurface* surface, unsigned flags) { 136 SkGpuDevice* SkGpuDevice::Create(GrSurface* surface, const SkSurfaceProps& props , unsigned flags) {
137 SkASSERT(surface); 137 SkASSERT(surface);
138 if (NULL == surface->asRenderTarget() || surface->wasDestroyed()) { 138 if (NULL == surface->asRenderTarget() || surface->wasDestroyed()) {
139 return NULL; 139 return NULL;
140 } 140 }
141 return SkNEW_ARGS(SkGpuDevice, (surface, flags)); 141 return SkNEW_ARGS(SkGpuDevice, (surface, props, flags));
142 } 142 }
143 143
144 SkGpuDevice::SkGpuDevice(GrSurface* surface, unsigned flags) { 144 SkGpuDevice::SkGpuDevice(GrSurface* surface, const SkSurfaceProps& props, unsign ed flags) {
145 145
146 fDrawProcs = NULL; 146 fDrawProcs = NULL;
147 147
148 fContext = SkRef(surface->getContext()); 148 fContext = SkRef(surface->getContext());
149 149
150 fNeedClear = flags & kNeedClear_Flag; 150 fNeedClear = flags & kNeedClear_Flag;
151 151
152 fRenderTarget = SkRef(surface->asRenderTarget()); 152 fRenderTarget = SkRef(surface->asRenderTarget());
153 153
154 SkPixelRef* pr = SkNEW_ARGS(SkGrPixelRef, 154 SkPixelRef* pr = SkNEW_ARGS(SkGrPixelRef,
155 (surface->info(), surface, SkToBool(flags & kCac hed_Flag))); 155 (surface->info(), surface, SkToBool(flags & kCac hed_Flag)));
156 fLegacyBitmap.setInfo(surface->info()); 156 fLegacyBitmap.setInfo(surface->info());
157 fLegacyBitmap.setPixelRef(pr)->unref(); 157 fLegacyBitmap.setPixelRef(pr)->unref();
158 158
159 this->setPixelGeometry(props.pixelGeometry());
160
159 bool useDFFonts = !!(flags & kDFFonts_Flag); 161 bool useDFFonts = !!(flags & kDFFonts_Flag);
160 fMainTextContext = fContext->createTextContext(fRenderTarget, this->getLeaky Properties(), useDFFonts); 162 fMainTextContext = fContext->createTextContext(fRenderTarget, this->getLeaky Properties(), useDFFonts);
161 fFallbackTextContext = SkNEW_ARGS(GrBitmapTextContext, (fContext, this->getL eakyProperties())); 163 fFallbackTextContext = SkNEW_ARGS(GrBitmapTextContext, (fContext, this->getL eakyProperties()));
162 } 164 }
163 165
164 SkGpuDevice* SkGpuDevice::Create(GrContext* context, const SkImageInfo& origInfo , 166 SkGpuDevice* SkGpuDevice::Create(GrContext* context, const SkImageInfo& origInfo ,
165 int sampleCount) { 167 const SkSurfaceProps& props, int sampleCount) {
166 if (kUnknown_SkColorType == origInfo.colorType() || 168 if (kUnknown_SkColorType == origInfo.colorType() ||
167 origInfo.width() < 0 || origInfo.height() < 0) { 169 origInfo.width() < 0 || origInfo.height() < 0) {
168 return NULL; 170 return NULL;
169 } 171 }
170 172
171 SkColorType ct = origInfo.colorType(); 173 SkColorType ct = origInfo.colorType();
172 SkAlphaType at = origInfo.alphaType(); 174 SkAlphaType at = origInfo.alphaType();
173 // TODO: perhaps we can loosen this check now that colortype is more detaile d 175 // 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? 176 // e.g. can we support both RGBA and BGRA here?
175 if (kRGB_565_SkColorType == ct) { 177 if (kRGB_565_SkColorType == ct) {
(...skipping 11 matching lines...) Expand all
187 desc.fWidth = info.width(); 189 desc.fWidth = info.width();
188 desc.fHeight = info.height(); 190 desc.fHeight = info.height();
189 desc.fConfig = SkImageInfo2GrPixelConfig(info); 191 desc.fConfig = SkImageInfo2GrPixelConfig(info);
190 desc.fSampleCnt = sampleCount; 192 desc.fSampleCnt = sampleCount;
191 193
192 SkAutoTUnref<GrTexture> texture(context->createUncachedTexture(desc, NULL, 0 )); 194 SkAutoTUnref<GrTexture> texture(context->createUncachedTexture(desc, NULL, 0 ));
193 if (!texture.get()) { 195 if (!texture.get()) {
194 return NULL; 196 return NULL;
195 } 197 }
196 198
197 return SkNEW_ARGS(SkGpuDevice, (texture.get())); 199 return SkNEW_ARGS(SkGpuDevice, (texture.get(), props));
198 } 200 }
199 201
200 SkGpuDevice::~SkGpuDevice() { 202 SkGpuDevice::~SkGpuDevice() {
201 if (fDrawProcs) { 203 if (fDrawProcs) {
202 delete fDrawProcs; 204 delete fDrawProcs;
203 } 205 }
204 206
205 delete fMainTextContext; 207 delete fMainTextContext;
206 delete fFallbackTextContext; 208 delete fFallbackTextContext;
207 209
(...skipping 1590 matching lines...) Expand 10 before | Expand all | Expand 10 after
1798 // match and ignore any padding. 1800 // match and ignore any padding.
1799 flags |= kCached_Flag; 1801 flags |= kCached_Flag;
1800 const GrContext::ScratchTexMatch match = (kSaveLayer_Usage == usage) ? 1802 const GrContext::ScratchTexMatch match = (kSaveLayer_Usage == usage) ?
1801 GrContext::kApprox_ScratchTexMat ch : 1803 GrContext::kApprox_ScratchTexMat ch :
1802 GrContext::kExact_ScratchTexMatc h; 1804 GrContext::kExact_ScratchTexMatc h;
1803 texture.reset(fContext->lockAndRefScratchTexture(desc, match)); 1805 texture.reset(fContext->lockAndRefScratchTexture(desc, match));
1804 #else 1806 #else
1805 texture.reset(fContext->createUncachedTexture(desc, NULL, 0)); 1807 texture.reset(fContext->createUncachedTexture(desc, NULL, 0));
1806 #endif 1808 #endif
1807 if (texture.get()) { 1809 if (texture.get()) {
1808 return SkGpuDevice::Create(texture, flags); 1810 return SkGpuDevice::Create(texture, SkSurfaceProps(SkSurfaceProps::kLega cyFontHost_InitType), flags);
1809 } else { 1811 } else {
1810 GrPrintf("---- failed to create compatible device texture [%d %d]\n", 1812 GrPrintf("---- failed to create compatible device texture [%d %d]\n",
1811 info.width(), info.height()); 1813 info.width(), info.height());
1812 return NULL; 1814 return NULL;
1813 } 1815 }
1814 } 1816 }
1815 1817
1816 SkSurface* SkGpuDevice::newSurface(const SkImageInfo& info) { 1818 SkSurface* SkGpuDevice::newSurface(const SkImageInfo& info, const SkSurfaceProps & props) {
1817 return SkSurface::NewRenderTarget(fContext, info, fRenderTarget->numSamples( )); 1819 return SkSurface::NewRenderTarget(fContext, info, fRenderTarget->numSamples( ), &props);
1818 } 1820 }
1819 1821
1820 void SkGpuDevice::EXPERIMENTAL_optimize(const SkPicture* picture) { 1822 void SkGpuDevice::EXPERIMENTAL_optimize(const SkPicture* picture) {
1821 fContext->getLayerCache()->processDeletedPictures(); 1823 fContext->getLayerCache()->processDeletedPictures();
1822 1824
1823 if (picture->fData.get() && !picture->fData->suitableForLayerOptimization()) { 1825 if (picture->fData.get() && !picture->fData->suitableForLayerOptimization()) {
1824 return; 1826 return;
1825 } 1827 }
1826 1828
1827 SkPicture::AccelData::Key key = GrAccelData::ComputeAccelDataKey(); 1829 SkPicture::AccelData::Key key = GrAccelData::ComputeAccelDataKey();
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1879 GrLayerHoister::UnlockLayers(fContext->getLayerCache(), picture); 1881 GrLayerHoister::UnlockLayers(fContext->getLayerCache(), picture);
1880 1882
1881 return true; 1883 return true;
1882 } 1884 }
1883 1885
1884 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { 1886 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() {
1885 // We always return a transient cache, so it is freed after each 1887 // We always return a transient cache, so it is freed after each
1886 // filter traversal. 1888 // filter traversal.
1887 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); 1889 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize);
1888 } 1890 }
OLDNEW
« no previous file with comments | « src/gpu/SkGpuDevice.h ('k') | src/image/SkSurface.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698