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

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

Issue 196133014: Implement text rendering with NVPR (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove path drawing from the patch Created 6 years, 9 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
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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 } 181 }
182 182
183 void SkGpuDevice::initFromRenderTarget(GrContext* context, 183 void SkGpuDevice::initFromRenderTarget(GrContext* context,
184 GrRenderTarget* renderTarget, 184 GrRenderTarget* renderTarget,
185 unsigned flags) { 185 unsigned flags) {
186 fDrawProcs = NULL; 186 fDrawProcs = NULL;
187 187
188 fContext = context; 188 fContext = context;
189 fContext->ref(); 189 fContext->ref();
190 190
191 fMainTextContext = SkNEW_ARGS(GrDistanceFieldTextContext, (fContext, fLeakyP roperties));
192 fFallbackTextContext = SkNEW_ARGS(GrBitmapTextContext, (fContext, fLeakyProp erties));
193
194 fRenderTarget = NULL; 191 fRenderTarget = NULL;
195 fNeedClear = flags & kNeedClear_Flag; 192 fNeedClear = flags & kNeedClear_Flag;
196 193
197 SkASSERT(NULL != renderTarget); 194 SkASSERT(NULL != renderTarget);
198 fRenderTarget = renderTarget; 195 fRenderTarget = renderTarget;
199 fRenderTarget->ref(); 196 fRenderTarget->ref();
200 197
201 // Hold onto to the texture in the pixel ref (if there is one) because the t exture holds a ref 198 // Hold onto to the texture in the pixel ref (if there is one) because the t exture holds a ref
202 // on the RT but not vice-versa. 199 // on the RT but not vice-versa.
203 // TODO: Remove this trickery once we figure out how to make SkGrPixelRef do this without 200 // TODO: Remove this trickery once we figure out how to make SkGrPixelRef do this without
204 // busting chrome (for a currently unknown reason). 201 // busting chrome (for a currently unknown reason).
205 GrSurface* surface = fRenderTarget->asTexture(); 202 GrSurface* surface = fRenderTarget->asTexture();
206 if (NULL == surface) { 203 if (NULL == surface) {
207 surface = fRenderTarget; 204 surface = fRenderTarget;
208 } 205 }
209 206
210 SkImageInfo info; 207 SkImageInfo info;
211 surface->asImageInfo(&info); 208 surface->asImageInfo(&info);
212 SkPixelRef* pr = SkNEW_ARGS(SkGrPixelRef, (info, surface, SkToBool(flags & k Cached_Flag))); 209 SkPixelRef* pr = SkNEW_ARGS(SkGrPixelRef, (info, surface, SkToBool(flags & k Cached_Flag)));
213 210
214 this->setPixelRef(pr)->unref(); 211 this->setPixelRef(pr)->unref();
212
213 fMainTextContext = fContext->createTextContext(fRenderTarget, fLeakyProperti es);
214 fFallbackTextContext = SkNEW_ARGS(GrBitmapTextContext, (fContext, fLeakyProp erties));
215 } 215 }
216 216
217 SkGpuDevice* SkGpuDevice::Create(GrContext* context, const SkImageInfo& origInfo , 217 SkGpuDevice* SkGpuDevice::Create(GrContext* context, const SkImageInfo& origInfo ,
218 int sampleCount) { 218 int sampleCount) {
219 if (kUnknown_SkColorType == origInfo.colorType() || 219 if (kUnknown_SkColorType == origInfo.colorType() ||
220 origInfo.width() < 0 || origInfo.height() < 0) { 220 origInfo.width() < 0 || origInfo.height() < 0) {
221 return NULL; 221 return NULL;
222 } 222 }
223 223
224 SkImageInfo info = origInfo; 224 SkImageInfo info = origInfo;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 int width, 261 int width,
262 int height, 262 int height,
263 int sampleCount) 263 int sampleCount)
264 : SkBitmapDevice(make_bitmap(config, width, height)) 264 : SkBitmapDevice(make_bitmap(config, width, height))
265 { 265 {
266 fDrawProcs = NULL; 266 fDrawProcs = NULL;
267 267
268 fContext = context; 268 fContext = context;
269 fContext->ref(); 269 fContext->ref();
270 270
271 fMainTextContext = SkNEW_ARGS(GrDistanceFieldTextContext, (fContext, fLeakyP roperties)); 271 fMainTextContext = fContext->createTextContext(fLeakyProperties);
272 fFallbackTextContext = SkNEW_ARGS(GrBitmapTextContext, (fContext, fLeakyProp erties)); 272 fFallbackTextContext = SkNEW_ARGS(GrBitmapTextContext, (fContext, fLeakyProp erties));
273 273
274 fRenderTarget = NULL; 274 fRenderTarget = NULL;
275 fNeedClear = false; 275 fNeedClear = false;
276 276
277 if (config != SkBitmap::kRGB_565_Config) { 277 if (config != SkBitmap::kRGB_565_Config) {
278 config = SkBitmap::kARGB_8888_Config; 278 config = SkBitmap::kARGB_8888_Config;
279 } 279 }
280 280
281 GrTextureDesc desc; 281 GrTextureDesc desc;
(...skipping 1748 matching lines...) Expand 10 before | Expand all | Expand 10 after
2030 if (NULL == data) { 2030 if (NULL == data) {
2031 return false; 2031 return false;
2032 } 2032 }
2033 2033
2034 #if 0 2034 #if 0
2035 const GPUAccelData *gpuData = static_cast<const GPUAccelData*>(data); 2035 const GPUAccelData *gpuData = static_cast<const GPUAccelData*>(data);
2036 #endif 2036 #endif
2037 2037
2038 return false; 2038 return false;
2039 } 2039 }
OLDNEW
« src/gpu/GrStencilAndCoverTextContext.cpp ('K') | « src/gpu/GrStencilAndCoverTextContext.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698