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

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

Issue 2164363002: Add SkColorSpace to GrDrawContext (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Remove ':' from comment Created 4 years, 5 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/gpu/effects/GrConfigConversionEffect.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 "GrBlurUtils.h" 10 #include "GrBlurUtils.h"
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 default: // If it is unpremul or unknown don't try to render 119 default: // If it is unpremul or unknown don't try to render
120 return false; 120 return false;
121 } 121 }
122 } 122 }
123 if (kClear_InitContents == init) { 123 if (kClear_InitContents == init) {
124 *flags |= kNeedClear_Flag; 124 *flags |= kNeedClear_Flag;
125 } 125 }
126 return true; 126 return true;
127 } 127 }
128 128
129 sk_sp<SkGpuDevice> SkGpuDevice::Make(sk_sp<GrRenderTarget> rt, const SkSurfacePr ops* props, 129 sk_sp<SkGpuDevice> SkGpuDevice::Make(sk_sp<GrRenderTarget> rt, sk_sp<SkColorSpac e> colorSpace,
130 InitContents init) { 130 const SkSurfaceProps* props, InitContents i nit) {
131 if (!rt || rt->wasDestroyed() || !rt->getContext()) { 131 if (!rt || rt->wasDestroyed() || !rt->getContext()) {
132 return nullptr; 132 return nullptr;
133 } 133 }
134 unsigned flags; 134 unsigned flags;
135 if (!CheckAlphaTypeAndGetFlags(nullptr, init, &flags)) { 135 if (!CheckAlphaTypeAndGetFlags(nullptr, init, &flags)) {
136 return nullptr; 136 return nullptr;
137 } 137 }
138 138
139 const int width = rt->width(); 139 const int width = rt->width();
140 const int height = rt->height(); 140 const int height = rt->height();
141 141
142 GrContext* context = rt->getContext(); 142 GrContext* context = rt->getContext();
143 143
144 sk_sp<GrDrawContext> drawContext(context->drawContext(std::move(rt), props)) ; 144 sk_sp<GrDrawContext> drawContext(context->drawContext(std::move(rt), std::mo ve(colorSpace),
145 props));
145 return sk_sp<SkGpuDevice>(new SkGpuDevice(std::move(drawContext), width, hei ght, flags)); 146 return sk_sp<SkGpuDevice>(new SkGpuDevice(std::move(drawContext), width, hei ght, flags));
146 } 147 }
147 148
148 sk_sp<SkBaseDevice> SkGpuDevice::Make(sk_sp<GrDrawContext> drawContext, 149 sk_sp<SkBaseDevice> SkGpuDevice::Make(sk_sp<GrDrawContext> drawContext,
149 int width, int height, 150 int width, int height,
150 InitContents init) { 151 InitContents init) {
151 if (!drawContext || drawContext->wasAbandoned()) { 152 if (!drawContext || drawContext->wasAbandoned()) {
152 return nullptr; 153 return nullptr;
153 } 154 }
154 unsigned flags; 155 unsigned flags;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 GrPixelConfig origConfig = SkImageInfo2GrPixelConfig(ct, at, cs, *context->c aps()); 217 GrPixelConfig origConfig = SkImageInfo2GrPixelConfig(ct, at, cs, *context->c aps());
217 if (!context->caps()->isConfigRenderable(origConfig, sampleCount > 0)) { 218 if (!context->caps()->isConfigRenderable(origConfig, sampleCount > 0)) {
218 // Fall back from whatever ct was to default of kRGBA or kBGRA which is aliased as kN32 219 // Fall back from whatever ct was to default of kRGBA or kBGRA which is aliased as kN32
219 ct = kN32_SkColorType; 220 ct = kN32_SkColorType;
220 } 221 }
221 222
222 GrPixelConfig config = SkImageInfo2GrPixelConfig(ct, at, cs, *context->caps( )); 223 GrPixelConfig config = SkImageInfo2GrPixelConfig(ct, at, cs, *context->caps( ));
223 224
224 return context->newDrawContext(SkBackingFit::kExact, // Why ex act? 225 return context->newDrawContext(SkBackingFit::kExact, // Why ex act?
225 origInfo.width(), origInfo.height(), 226 origInfo.width(), origInfo.height(),
226 config, sampleCount, 227 config, sk_ref_sp(cs), sampleCount,
227 kDefault_GrSurfaceOrigin, surfaceProps, budge ted); 228 kDefault_GrSurfaceOrigin, surfaceProps, budge ted);
228 } 229 }
229 230
230 sk_sp<SkSpecialImage> SkGpuDevice::filterTexture(const SkDraw& draw, 231 sk_sp<SkSpecialImage> SkGpuDevice::filterTexture(const SkDraw& draw,
231 SkSpecialImage* srcImg, 232 SkSpecialImage* srcImg,
232 int left, int top, 233 int left, int top,
233 SkIPoint* offset, 234 SkIPoint* offset,
234 const SkImageFilter* filter) { 235 const SkImageFilter* filter) {
235 SkASSERT(srcImg->isTextureBacked()); 236 SkASSERT(srcImg->isTextureBacked());
236 SkASSERT(filter); 237 SkASSERT(filter);
(...skipping 1598 matching lines...) Expand 10 before | Expand all | Expand 10 after
1835 SkSurfaceProps props(this->surfaceProps().flags(), cinfo.fPixelGeometry); 1836 SkSurfaceProps props(this->surfaceProps().flags(), cinfo.fPixelGeometry);
1836 1837
1837 // layers are never drawn in repeat modes, so we can request an approx 1838 // layers are never drawn in repeat modes, so we can request an approx
1838 // match and ignore any padding. 1839 // match and ignore any padding.
1839 SkBackingFit fit = kNever_TileUsage == cinfo.fTileUsage ? SkBackingFit::kApp rox 1840 SkBackingFit fit = kNever_TileUsage == cinfo.fTileUsage ? SkBackingFit::kApp rox
1840 : SkBackingFit::kExa ct; 1841 : SkBackingFit::kExa ct;
1841 1842
1842 sk_sp<GrDrawContext> dc(fContext->newDrawContext(fit, 1843 sk_sp<GrDrawContext> dc(fContext->newDrawContext(fit,
1843 cinfo.fInfo.width(), cinfo. fInfo.height(), 1844 cinfo.fInfo.width(), cinfo. fInfo.height(),
1844 fDrawContext->config(), 1845 fDrawContext->config(),
1846 sk_ref_sp(fDrawContext->get ColorSpace()),
1845 fDrawContext->desc().fSampl eCnt, 1847 fDrawContext->desc().fSampl eCnt,
1846 kDefault_GrSurfaceOrigin, 1848 kDefault_GrSurfaceOrigin,
1847 &props)); 1849 &props));
1848 if (!dc) { 1850 if (!dc) {
1849 SkErrorInternals::SetError( kInternalError_SkError, 1851 SkErrorInternals::SetError( kInternalError_SkError,
1850 "---- failed to create gpu device texture [% d %d]\n", 1852 "---- failed to create gpu device texture [% d %d]\n",
1851 cinfo.fInfo.width(), cinfo.fInfo.height()); 1853 cinfo.fInfo.width(), cinfo.fInfo.height());
1852 return nullptr; 1854 return nullptr;
1853 } 1855 }
1854 1856
(...skipping 14 matching lines...) Expand all
1869 } 1871 }
1870 1872
1871 SkImageFilterCache* SkGpuDevice::getImageFilterCache() { 1873 SkImageFilterCache* SkGpuDevice::getImageFilterCache() {
1872 ASSERT_SINGLE_OWNER 1874 ASSERT_SINGLE_OWNER
1873 // We always return a transient cache, so it is freed after each 1875 // We always return a transient cache, so it is freed after each
1874 // filter traversal. 1876 // filter traversal.
1875 return SkImageFilterCache::Create(kDefaultImageFilterCacheSize); 1877 return SkImageFilterCache::Create(kDefaultImageFilterCacheSize);
1876 } 1878 }
1877 1879
1878 #endif 1880 #endif
OLDNEW
« no previous file with comments | « src/gpu/SkGpuDevice.h ('k') | src/gpu/effects/GrConfigConversionEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698