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

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

Issue 1196683003: remove SkDeviceProperties (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Clean up Created 5 years, 6 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 "GrBlurUtils.h" 10 #include "GrBlurUtils.h"
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 } 127 }
128 128
129 SkGpuDevice* SkGpuDevice::Create(GrRenderTarget* rt, int width, int height, 129 SkGpuDevice* SkGpuDevice::Create(GrRenderTarget* rt, int width, int height,
130 const SkSurfaceProps* props, unsigned flags) { 130 const SkSurfaceProps* props, unsigned flags) {
131 if (!rt || rt->wasDestroyed()) { 131 if (!rt || rt->wasDestroyed()) {
132 return NULL; 132 return NULL;
133 } 133 }
134 return SkNEW_ARGS(SkGpuDevice, (rt, width, height, props, flags)); 134 return SkNEW_ARGS(SkGpuDevice, (rt, width, height, props, flags));
135 } 135 }
136 136
137 static SkDeviceProperties surfaceprops_to_deviceprops(const SkSurfaceProps* prop s) {
138 if (props) {
139 return SkDeviceProperties(props->pixelGeometry(), props->isUseDistanceFi eldFonts());
140 } else {
141 return SkDeviceProperties();
142 }
143 }
144
145 static SkSurfaceProps copy_or_default_props(const SkSurfaceProps* props) {
146 if (props) {
147 return SkSurfaceProps(*props);
148 } else {
149 return SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType);
150 }
151 }
152
153 SkGpuDevice::SkGpuDevice(GrRenderTarget* rt, int width, int height, 137 SkGpuDevice::SkGpuDevice(GrRenderTarget* rt, int width, int height,
154 const SkSurfaceProps* props, unsigned flags) 138 const SkSurfaceProps* props, unsigned flags)
155 : INHERITED(surfaceprops_to_deviceprops(props)) 139 : INHERITED(SkSurfacePropsCopyOrDefault(props))
156 , fSurfaceProps(copy_or_default_props(props))
157 { 140 {
158 fDrawProcs = NULL; 141 fDrawProcs = NULL;
159 142
160 fContext = SkRef(rt->getContext()); 143 fContext = SkRef(rt->getContext());
161 fNeedClear = flags & kNeedClear_Flag; 144 fNeedClear = flags & kNeedClear_Flag;
162 145
163 fRenderTarget = SkRef(rt); 146 fRenderTarget = SkRef(rt);
164 147
165 SkImageInfo info = rt->surfacePriv().info().makeWH(width, height); 148 SkImageInfo info = rt->surfacePriv().info().makeWH(width, height);
166 SkPixelRef* pr = SkNEW_ARGS(SkGrPixelRef, (info, rt)); 149 SkPixelRef* pr = SkNEW_ARGS(SkGrPixelRef, (info, rt));
(...skipping 1527 matching lines...) Expand 10 before | Expand all | Expand 10 after
1694 unsigned flags = cinfo.fInfo.isOpaque() ? 0 : kNeedClear_Flag; 1677 unsigned flags = cinfo.fInfo.isOpaque() ? 0 : kNeedClear_Flag;
1695 1678
1696 // layers are never draw in repeat modes, so we can request an approx 1679 // layers are never draw in repeat modes, so we can request an approx
1697 // match and ignore any padding. 1680 // match and ignore any padding.
1698 const GrTextureProvider::ScratchTexMatch match = (kNever_TileUsage == cinfo. fTileUsage) ? 1681 const GrTextureProvider::ScratchTexMatch match = (kNever_TileUsage == cinfo. fTileUsage) ?
1699 GrTextureProvider::kApprox_Scr atchTexMatch : 1682 GrTextureProvider::kApprox_Scr atchTexMatch :
1700 GrTextureProvider::kExact_Scra tchTexMatch; 1683 GrTextureProvider::kExact_Scra tchTexMatch;
1701 texture.reset(fContext->textureProvider()->refScratchTexture(desc, match)); 1684 texture.reset(fContext->textureProvider()->refScratchTexture(desc, match));
1702 1685
1703 if (texture) { 1686 if (texture) {
1704 SkSurfaceProps props(fSurfaceProps.flags(), cinfo.fPixelGeometry); 1687 SkSurfaceProps props(this->getLeakyProperties().flags(), cinfo.fPixelGeo metry);
1705 return SkGpuDevice::Create( 1688 return SkGpuDevice::Create(
1706 texture->asRenderTarget(), cinfo.fInfo.width(), cinfo.fInfo.height() , &props, flags); 1689 texture->asRenderTarget(), cinfo.fInfo.width(), cinfo.fInfo.height() , &props, flags);
1707 } else { 1690 } else {
1708 SkErrorInternals::SetError( kInternalError_SkError, 1691 SkErrorInternals::SetError( kInternalError_SkError,
1709 "---- failed to create gpu device texture [% d %d]\n", 1692 "---- failed to create gpu device texture [% d %d]\n",
1710 cinfo.fInfo.width(), cinfo.fInfo.height()); 1693 cinfo.fInfo.width(), cinfo.fInfo.height());
1711 return NULL; 1694 return NULL;
1712 } 1695 }
1713 } 1696 }
1714 1697
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1786 #endif 1769 #endif
1787 } 1770 }
1788 1771
1789 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { 1772 SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() {
1790 // We always return a transient cache, so it is freed after each 1773 // We always return a transient cache, so it is freed after each
1791 // filter traversal. 1774 // filter traversal.
1792 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); 1775 return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize);
1793 } 1776 }
1794 1777
1795 #endif 1778 #endif
OLDNEW
« src/gpu/SkGpuDevice.h ('K') | « src/gpu/SkGpuDevice.h ('k') | src/image/SkSurface_Gpu.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698