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

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

Issue 2261003003: store info in basedevice, change getter to non-virtual const& (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 4 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 sk_sp<GrDrawContext> drawContext(MakeDrawContext(context, budgeted, info, 115 sk_sp<GrDrawContext> drawContext(MakeDrawContext(context, budgeted, info,
116 sampleCount, origin, props) ); 116 sampleCount, origin, props) );
117 if (!drawContext) { 117 if (!drawContext) {
118 return nullptr; 118 return nullptr;
119 } 119 }
120 120
121 return sk_sp<SkGpuDevice>(new SkGpuDevice(std::move(drawContext), 121 return sk_sp<SkGpuDevice>(new SkGpuDevice(std::move(drawContext),
122 info.width(), info.height(), flags )); 122 info.width(), info.height(), flags ));
123 } 123 }
124 124
125 SkGpuDevice::SkGpuDevice(sk_sp<GrDrawContext> drawContext, int width, int height , unsigned flags) 125 static SkImageInfo make_info(GrDrawContext* context, int w, int h, bool opaque) {
126 : INHERITED(drawContext->surfaceProps()) 126 SkColorType colorType;
127 if (!GrPixelConfigToColorType(context->config(), &colorType)) {
128 colorType = kUnknown_SkColorType;
129 }
130 return SkImageInfo::Make(w, h, colorType,
131 opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType,
132 sk_ref_sp(context->getColorSpace()));
133 }
134
135 SkGpuDevice::SkGpuDevice(sk_sp<GrDrawContext> drawContext, int width, int height , unsigned flags)
136 : INHERITED(make_info(drawContext.get(), width, height, SkToBool(flags & kIs Opaque_Flag)),
137 drawContext->surfaceProps())
127 , fContext(SkRef(drawContext->accessRenderTarget()->getContext())) 138 , fContext(SkRef(drawContext->accessRenderTarget()->getContext()))
128 , fDrawContext(std::move(drawContext)) { 139 , fDrawContext(std::move(drawContext))
140 {
129 fSize.set(width, height); 141 fSize.set(width, height);
130 fOpaque = SkToBool(flags & kIsOpaque_Flag); 142 fOpaque = SkToBool(flags & kIsOpaque_Flag);
131 143
132 if (flags & kNeedClear_Flag) { 144 if (flags & kNeedClear_Flag) {
133 this->clearAll(); 145 this->clearAll();
134 } 146 }
135 } 147 }
136 148
137 sk_sp<GrDrawContext> SkGpuDevice::MakeDrawContext(GrContext* context, 149 sk_sp<GrDrawContext> SkGpuDevice::MakeDrawContext(GrContext* context,
138 SkBudgeted budgeted, 150 SkBudgeted budgeted,
(...skipping 1637 matching lines...) Expand 10 before | Expand all | Expand 10 after
1776 } 1788 }
1777 1789
1778 SkImageFilterCache* SkGpuDevice::getImageFilterCache() { 1790 SkImageFilterCache* SkGpuDevice::getImageFilterCache() {
1779 ASSERT_SINGLE_OWNER 1791 ASSERT_SINGLE_OWNER
1780 // We always return a transient cache, so it is freed after each 1792 // We always return a transient cache, so it is freed after each
1781 // filter traversal. 1793 // filter traversal.
1782 return SkImageFilterCache::Create(kDefaultImageFilterCacheSize); 1794 return SkImageFilterCache::Create(kDefaultImageFilterCacheSize);
1783 } 1795 }
1784 1796
1785 #endif 1797 #endif
OLDNEW
« include/core/SkDevice.h ('K') | « src/gpu/SkGpuDevice.h ('k') | src/pdf/SkPDFDevice.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698