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

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: 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
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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 default: // If it is unpremul or unknown don't try to render 120 default: // If it is unpremul or unknown don't try to render
121 return false; 121 return false;
122 } 122 }
123 } 123 }
124 if (kClear_InitContents == init) { 124 if (kClear_InitContents == init) {
125 *flags |= kNeedClear_Flag; 125 *flags |= kNeedClear_Flag;
126 } 126 }
127 return true; 127 return true;
128 } 128 }
129 129
130 sk_sp<SkGpuDevice> SkGpuDevice::Make(sk_sp<GrRenderTarget> rt, const SkSurfacePr ops* props, 130 sk_sp<SkGpuDevice> SkGpuDevice::Make(sk_sp<GrRenderTarget> rt, sk_sp<SkColorSpac e> colorSpace,
131 InitContents init) { 131 const SkSurfaceProps* props, InitContents i nit) {
132 if (!rt || rt->wasDestroyed() || !rt->getContext()) { 132 if (!rt || rt->wasDestroyed() || !rt->getContext()) {
133 return nullptr; 133 return nullptr;
134 } 134 }
135 unsigned flags; 135 unsigned flags;
136 if (!CheckAlphaTypeAndGetFlags(nullptr, init, &flags)) { 136 if (!CheckAlphaTypeAndGetFlags(nullptr, init, &flags)) {
137 return nullptr; 137 return nullptr;
138 } 138 }
139 139
140 const int width = rt->width(); 140 const int width = rt->width();
141 const int height = rt->height(); 141 const int height = rt->height();
142 142
143 GrContext* context = rt->getContext(); 143 GrContext* context = rt->getContext();
144 144
145 sk_sp<GrDrawContext> drawContext(context->drawContext(std::move(rt), props)) ; 145 sk_sp<GrDrawContext> drawContext(context->drawContext(std::move(rt), std::mo ve(colorSpace),
146 props));
146 return sk_sp<SkGpuDevice>(new SkGpuDevice(std::move(drawContext), width, hei ght, flags)); 147 return sk_sp<SkGpuDevice>(new SkGpuDevice(std::move(drawContext), width, hei ght, flags));
147 } 148 }
148 149
149 sk_sp<SkBaseDevice> SkGpuDevice::Make(sk_sp<GrDrawContext> drawContext, 150 sk_sp<SkBaseDevice> SkGpuDevice::Make(sk_sp<GrDrawContext> drawContext,
150 int width, int height, 151 int width, int height,
151 InitContents init) { 152 InitContents init) {
152 if (!drawContext || drawContext->wasAbandoned()) { 153 if (!drawContext || drawContext->wasAbandoned()) {
153 return nullptr; 154 return nullptr;
154 } 155 }
155 unsigned flags; 156 unsigned flags;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 GrPixelConfig origConfig = SkImageInfo2GrPixelConfig(ct, at, cs, *context->c aps()); 223 GrPixelConfig origConfig = SkImageInfo2GrPixelConfig(ct, at, cs, *context->c aps());
223 if (!context->caps()->isConfigRenderable(origConfig, sampleCount > 0)) { 224 if (!context->caps()->isConfigRenderable(origConfig, sampleCount > 0)) {
224 // Fall back from whatever ct was to default of kRGBA or kBGRA which is aliased as kN32 225 // Fall back from whatever ct was to default of kRGBA or kBGRA which is aliased as kN32
225 ct = kN32_SkColorType; 226 ct = kN32_SkColorType;
226 } 227 }
227 228
228 GrPixelConfig config = SkImageInfo2GrPixelConfig(ct, at, cs, *context->caps( )); 229 GrPixelConfig config = SkImageInfo2GrPixelConfig(ct, at, cs, *context->caps( ));
229 230
230 return context->newDrawContext(SkBackingFit::kExact, // Why ex act? 231 return context->newDrawContext(SkBackingFit::kExact, // Why ex act?
231 origInfo.width(), origInfo.height(), 232 origInfo.width(), origInfo.height(),
232 config, sampleCount, 233 config, sk_ref_sp(cs), sampleCount,
233 kDefault_GrSurfaceOrigin, surfaceProps, budge ted); 234 kDefault_GrSurfaceOrigin, surfaceProps, budge ted);
234 } 235 }
235 236
236 sk_sp<SkSpecialImage> SkGpuDevice::filterTexture(const SkDraw& draw, 237 sk_sp<SkSpecialImage> SkGpuDevice::filterTexture(const SkDraw& draw,
237 SkSpecialImage* srcImg, 238 SkSpecialImage* srcImg,
238 int left, int top, 239 int left, int top,
239 SkIPoint* offset, 240 SkIPoint* offset,
240 const SkImageFilter* filter) { 241 const SkImageFilter* filter) {
241 SkASSERT(srcImg->isTextureBacked()); 242 SkASSERT(srcImg->isTextureBacked());
242 SkASSERT(filter); 243 SkASSERT(filter);
(...skipping 1618 matching lines...) Expand 10 before | Expand all | Expand 10 after
1861 SkSurfaceProps props(this->surfaceProps().flags(), cinfo.fPixelGeometry); 1862 SkSurfaceProps props(this->surfaceProps().flags(), cinfo.fPixelGeometry);
1862 1863
1863 // layers are never drawn in repeat modes, so we can request an approx 1864 // layers are never drawn in repeat modes, so we can request an approx
1864 // match and ignore any padding. 1865 // match and ignore any padding.
1865 SkBackingFit fit = kNever_TileUsage == cinfo.fTileUsage ? SkBackingFit::kApp rox 1866 SkBackingFit fit = kNever_TileUsage == cinfo.fTileUsage ? SkBackingFit::kApp rox
1866 : SkBackingFit::kExa ct; 1867 : SkBackingFit::kExa ct;
1867 1868
1868 sk_sp<GrDrawContext> dc(fContext->newDrawContext(fit, 1869 sk_sp<GrDrawContext> dc(fContext->newDrawContext(fit,
1869 cinfo.fInfo.width(), cinfo. fInfo.height(), 1870 cinfo.fInfo.width(), cinfo. fInfo.height(),
1870 fDrawContext->config(), 1871 fDrawContext->config(),
1872 sk_ref_sp(fDrawContext->get ColorSpace()),
1871 fDrawContext->desc().fSampl eCnt, 1873 fDrawContext->desc().fSampl eCnt,
1872 kDefault_GrSurfaceOrigin, 1874 kDefault_GrSurfaceOrigin,
1873 &props)); 1875 &props));
1874 if (!dc) { 1876 if (!dc) {
1875 SkErrorInternals::SetError( kInternalError_SkError, 1877 SkErrorInternals::SetError( kInternalError_SkError,
1876 "---- failed to create gpu device texture [% d %d]\n", 1878 "---- failed to create gpu device texture [% d %d]\n",
1877 cinfo.fInfo.width(), cinfo.fInfo.height()); 1879 cinfo.fInfo.width(), cinfo.fInfo.height());
1878 return nullptr; 1880 return nullptr;
1879 } 1881 }
1880 1882
(...skipping 14 matching lines...) Expand all
1895 } 1897 }
1896 1898
1897 SkImageFilterCache* SkGpuDevice::getImageFilterCache() { 1899 SkImageFilterCache* SkGpuDevice::getImageFilterCache() {
1898 ASSERT_SINGLE_OWNER 1900 ASSERT_SINGLE_OWNER
1899 // We always return a transient cache, so it is freed after each 1901 // We always return a transient cache, so it is freed after each
1900 // filter traversal. 1902 // filter traversal.
1901 return SkImageFilterCache::Create(kDefaultImageFilterCacheSize); 1903 return SkImageFilterCache::Create(kDefaultImageFilterCacheSize);
1902 } 1904 }
1903 1905
1904 #endif 1906 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698