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

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

Issue 1993403002: GrSWMaskHelper and GrSoftwarePathRenderer only need the textureProvider (not GrContext) (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 7 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/GrSWMaskHelper.h ('k') | src/gpu/GrSoftwarePathRenderer.h » ('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 2012 Google Inc. 2 * Copyright 2012 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 "GrSWMaskHelper.h" 8 #include "GrSWMaskHelper.h"
9 9
10 #include "GrCaps.h" 10 #include "GrCaps.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 97
98 /** 98 /**
99 * Get a texture (from the texture cache) of the correct size & format. 99 * Get a texture (from the texture cache) of the correct size & format.
100 */ 100 */
101 GrTexture* GrSWMaskHelper::createTexture() { 101 GrTexture* GrSWMaskHelper::createTexture() {
102 GrSurfaceDesc desc; 102 GrSurfaceDesc desc;
103 desc.fWidth = fPixels.width(); 103 desc.fWidth = fPixels.width();
104 desc.fHeight = fPixels.height(); 104 desc.fHeight = fPixels.height();
105 desc.fConfig = kAlpha_8_GrPixelConfig; 105 desc.fConfig = kAlpha_8_GrPixelConfig;
106 106
107 return fContext->textureProvider()->createApproxTexture(desc); 107 return fTexProvider->createApproxTexture(desc);
108 } 108 }
109 109
110 /** 110 /**
111 * Move the result of the software mask generation back to the gpu 111 * Move the result of the software mask generation back to the gpu
112 */ 112 */
113 void GrSWMaskHelper::toTexture(GrTexture *texture) { 113 void GrSWMaskHelper::toTexture(GrTexture *texture) {
114 // Since we're uploading to it, and it's compressed, 'texture' shouldn't 114 // Since we're uploading to it, and it's compressed, 'texture' shouldn't
115 // have a render target. 115 // have a render target.
116 SkASSERT(!texture->asRenderTarget()); 116 SkASSERT(!texture->asRenderTarget());
117 117
118 texture->writePixels(0, 0, fPixels.width(), fPixels.height(), texture->confi g(), 118 texture->writePixels(0, 0, fPixels.width(), fPixels.height(), texture->confi g(),
119 fPixels.addr(), fPixels.rowBytes()); 119 fPixels.addr(), fPixels.rowBytes());
120 120
121 } 121 }
122 122
123 /** 123 /**
124 * Convert mask generation results to a signed distance field 124 * Convert mask generation results to a signed distance field
125 */ 125 */
126 void GrSWMaskHelper::toSDF(unsigned char* sdf) { 126 void GrSWMaskHelper::toSDF(unsigned char* sdf) {
127 SkGenerateDistanceFieldFromA8Image(sdf, (const unsigned char*)fPixels.addr() , 127 SkGenerateDistanceFieldFromA8Image(sdf, (const unsigned char*)fPixels.addr() ,
128 fPixels.width(), fPixels.height(), fPixel s.rowBytes()); 128 fPixels.width(), fPixels.height(), fPixel s.rowBytes());
129 } 129 }
130 130
131 //////////////////////////////////////////////////////////////////////////////// 131 ////////////////////////////////////////////////////////////////////////////////
132 /** 132 /**
133 * Software rasterizes path to A8 mask (possibly using the context's matrix) 133 * Software rasterizes path to A8 mask (possibly using the context's matrix)
134 * and uploads the result to a scratch texture. Returns the resulting 134 * and uploads the result to a scratch texture. Returns the resulting
135 * texture on success; nullptr on failure. 135 * texture on success; nullptr on failure.
136 */ 136 */
137 GrTexture* GrSWMaskHelper::DrawPathMaskToTexture(GrContext* context, 137 GrTexture* GrSWMaskHelper::DrawPathMaskToTexture(GrTextureProvider* texProvider,
138 const SkPath& path, 138 const SkPath& path,
139 const GrStyle& style, 139 const GrStyle& style,
140 const SkIRect& resultBounds, 140 const SkIRect& resultBounds,
141 bool antiAlias, 141 bool antiAlias,
142 const SkMatrix* matrix) { 142 const SkMatrix* matrix) {
143 GrSWMaskHelper helper(context); 143 GrSWMaskHelper helper(texProvider);
144 144
145 if (!helper.init(resultBounds, matrix)) { 145 if (!helper.init(resultBounds, matrix)) {
146 return nullptr; 146 return nullptr;
147 } 147 }
148 148
149 helper.drawPath(path, style, SkRegion::kReplace_Op, antiAlias, 0xFF); 149 helper.drawPath(path, style, SkRegion::kReplace_Op, antiAlias, 0xFF);
150 150
151 GrTexture* texture(helper.createTexture()); 151 GrTexture* texture(helper.createTexture());
152 if (!texture) { 152 if (!texture) {
153 return nullptr; 153 return nullptr;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 pipelineBuilder->addCoverageFragmentProcessor( 186 pipelineBuilder->addCoverageFragmentProcessor(
187 GrSimpleTextureEffect::Create(texture, 187 GrSimpleTextureEffect::Create(texture,
188 maskMatrix, 188 maskMatrix,
189 GrTextureParams::kNone_Fi lterMode, 189 GrTextureParams::kNone_Fi lterMode,
190 kDevice_GrCoordSet))->unr ef(); 190 kDevice_GrCoordSet))->unr ef();
191 191
192 SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateNonAAFill(color, S kMatrix::I(), 192 SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateNonAAFill(color, S kMatrix::I(),
193 dstRect, nullptr, &invert)); 193 dstRect, nullptr, &invert));
194 target->drawBatch(*pipelineBuilder, clip, batch); 194 target->drawBatch(*pipelineBuilder, clip, batch);
195 } 195 }
OLDNEW
« no previous file with comments | « src/gpu/GrSWMaskHelper.h ('k') | src/gpu/GrSoftwarePathRenderer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698