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

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: address review comments + one changed hunk 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
« no previous file with comments | « src/gpu/GrStencilAndCoverTextContext.cpp ('k') | no next file » | 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 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));
272 fFallbackTextContext = SkNEW_ARGS(GrBitmapTextContext, (fContext, fLeakyProp erties));
273
274 fRenderTarget = NULL; 271 fRenderTarget = NULL;
275 fNeedClear = false; 272 fNeedClear = false;
276 273
277 if (config != SkBitmap::kRGB_565_Config) { 274 if (config != SkBitmap::kRGB_565_Config) {
278 config = SkBitmap::kARGB_8888_Config; 275 config = SkBitmap::kARGB_8888_Config;
279 } 276 }
280 277
281 GrTextureDesc desc; 278 GrTextureDesc desc;
282 desc.fFlags = kRenderTarget_GrTextureFlagBit; 279 desc.fFlags = kRenderTarget_GrTextureFlagBit;
283 desc.fWidth = width; 280 desc.fWidth = width;
(...skipping 18 matching lines...) Expand all
302 SkASSERT(NULL != fRenderTarget); 299 SkASSERT(NULL != fRenderTarget);
303 300
304 // wrap the bitmap with a pixelref to expose our texture 301 // wrap the bitmap with a pixelref to expose our texture
305 SkGrPixelRef* pr = SkNEW_ARGS(SkGrPixelRef, (info, texture)); 302 SkGrPixelRef* pr = SkNEW_ARGS(SkGrPixelRef, (info, texture));
306 this->setPixelRef(pr)->unref(); 303 this->setPixelRef(pr)->unref();
307 } else { 304 } else {
308 GrPrintf("--- failed to create gpu-offscreen [%d %d]\n", 305 GrPrintf("--- failed to create gpu-offscreen [%d %d]\n",
309 width, height); 306 width, height);
310 SkASSERT(false); 307 SkASSERT(false);
311 } 308 }
309
310 fMainTextContext = fContext->createTextContext(fRenderTarget, fLeakyProperti es);
Kimmo Kinnunen 2014/03/25 12:32:48 Jim, this hunk was wrong before. Eg. it wasn't eve
311 fFallbackTextContext = SkNEW_ARGS(GrBitmapTextContext, (fContext, fLeakyProp erties));
312 } 312 }
313 #endif 313 #endif
314 314
315 SkGpuDevice::~SkGpuDevice() { 315 SkGpuDevice::~SkGpuDevice() {
316 if (fDrawProcs) { 316 if (fDrawProcs) {
317 delete fDrawProcs; 317 delete fDrawProcs;
318 } 318 }
319 319
320 delete fMainTextContext; 320 delete fMainTextContext;
321 delete fFallbackTextContext; 321 delete fFallbackTextContext;
(...skipping 1708 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
« no previous file with comments | « src/gpu/GrStencilAndCoverTextContext.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698