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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 SkGpuDevice::SkGpuDevice(GrSurface* surface, const SkSurfaceProps& props, unsign
ed 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 SkImageInfo info = surface->surfacePriv().info(); |
154 SkPixelRef* pr = SkNEW_ARGS(SkGrPixelRef, | 155 SkPixelRef* pr = SkNEW_ARGS(SkGrPixelRef, |
155 (surface->info(), surface, SkToBool(flags & kCac
hed_Flag))); | 156 (info, surface, SkToBool(flags & kCached_Flag)))
; |
156 fLegacyBitmap.setInfo(surface->info()); | 157 fLegacyBitmap.setInfo(info); |
157 fLegacyBitmap.setPixelRef(pr)->unref(); | 158 fLegacyBitmap.setPixelRef(pr)->unref(); |
158 | 159 |
159 this->setPixelGeometry(props.pixelGeometry()); | 160 this->setPixelGeometry(props.pixelGeometry()); |
160 | 161 |
161 bool useDFFonts = !!(flags & kDFFonts_Flag); | 162 bool useDFFonts = !!(flags & kDFFonts_Flag); |
162 fMainTextContext = fContext->createTextContext(fRenderTarget, this->getLeaky
Properties(), useDFFonts); | 163 fMainTextContext = fContext->createTextContext(fRenderTarget, this->getLeaky
Properties(), useDFFonts); |
163 fFallbackTextContext = SkNEW_ARGS(GrBitmapTextContext, (fContext, this->getL
eakyProperties())); | 164 fFallbackTextContext = SkNEW_ARGS(GrBitmapTextContext, (fContext, this->getL
eakyProperties())); |
164 } | 165 } |
165 | 166 |
166 SkGpuDevice* SkGpuDevice::Create(GrContext* context, const SkImageInfo& origInfo
, | 167 SkGpuDevice* SkGpuDevice::Create(GrContext* context, const SkImageInfo& origInfo
, |
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 // Draw the mask into maskTexture with the path's top-left at the origin usi
ng tempPaint. | 685 // Draw the mask into maskTexture with the path's top-left at the origin usi
ng tempPaint. |
685 SkMatrix translate; | 686 SkMatrix translate; |
686 translate.setTranslate(-maskRect.fLeft, -maskRect.fTop); | 687 translate.setTranslate(-maskRect.fLeft, -maskRect.fTop); |
687 am.set(context, translate); | 688 am.set(context, translate); |
688 context->drawPath(tempPaint, devPath, strokeInfo); | 689 context->drawPath(tempPaint, devPath, strokeInfo); |
689 return true; | 690 return true; |
690 } | 691 } |
691 | 692 |
692 SkBitmap wrap_texture(GrTexture* texture) { | 693 SkBitmap wrap_texture(GrTexture* texture) { |
693 SkBitmap result; | 694 SkBitmap result; |
694 result.setInfo(texture->info()); | 695 result.setInfo(texture->surfacePriv().info()); |
695 result.setPixelRef(SkNEW_ARGS(SkGrPixelRef, (result.info(), texture)))->unre
f(); | 696 result.setPixelRef(SkNEW_ARGS(SkGrPixelRef, (result.info(), texture)))->unre
f(); |
696 return result; | 697 return result; |
697 } | 698 } |
698 | 699 |
699 }; | 700 }; |
700 | 701 |
701 void SkGpuDevice::drawPath(const SkDraw& draw, const SkPath& origSrcPath, | 702 void SkGpuDevice::drawPath(const SkDraw& draw, const SkPath& origSrcPath, |
702 const SkPaint& paint, const SkMatrix* prePathMatrix, | 703 const SkPaint& paint, const SkMatrix* prePathMatrix, |
703 bool pathIsMutable) { | 704 bool pathIsMutable) { |
704 CHECK_FOR_ANNOTATION(paint); | 705 CHECK_FOR_ANNOTATION(paint); |
(...skipping 1164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1869 GrLayerHoister::UnlockLayers(fContext->getLayerCache(), atlased, nonAtlased)
; | 1870 GrLayerHoister::UnlockLayers(fContext->getLayerCache(), atlased, nonAtlased)
; |
1870 | 1871 |
1871 return true; | 1872 return true; |
1872 } | 1873 } |
1873 | 1874 |
1874 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { | 1875 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { |
1875 // We always return a transient cache, so it is freed after each | 1876 // We always return a transient cache, so it is freed after each |
1876 // filter traversal. | 1877 // filter traversal. |
1877 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); | 1878 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); |
1878 } | 1879 } |
OLD | NEW |