OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 The Android Open Source Project | 2 * Copyright 2012 The Android Open Source Project |
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 "SkMorphologyImageFilter.h" | 8 #include "SkMorphologyImageFilter.h" |
9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 }; | 328 }; |
329 | 329 |
330 /////////////////////////////////////////////////////////////////////////////// | 330 /////////////////////////////////////////////////////////////////////////////// |
331 | 331 |
332 class GrGLMorphologyEffect : public GrGLFragmentProcessor { | 332 class GrGLMorphologyEffect : public GrGLFragmentProcessor { |
333 public: | 333 public: |
334 GrGLMorphologyEffect (const GrBackendProcessorFactory&, const GrProcessor&); | 334 GrGLMorphologyEffect (const GrBackendProcessorFactory&, const GrProcessor&); |
335 | 335 |
336 virtual void emitCode(GrGLFPBuilder*, | 336 virtual void emitCode(GrGLFPBuilder*, |
337 const GrFragmentProcessor&, | 337 const GrFragmentProcessor&, |
338 const GrProcessorKey&, | |
339 const char* outputColor, | 338 const char* outputColor, |
340 const char* inputColor, | 339 const char* inputColor, |
341 const TransformedCoordsArray&, | 340 const TransformedCoordsArray&, |
342 const TextureSamplerArray&) SK_OVERRIDE; | 341 const TextureSamplerArray&) SK_OVERRIDE; |
343 | 342 |
344 static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKe
yBuilder* b); | 343 static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKe
yBuilder* b); |
345 | 344 |
346 virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_O
VERRIDE; | 345 virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_O
VERRIDE; |
347 | 346 |
348 private: | 347 private: |
349 int width() const { return GrMorphologyEffect::WidthFromRadius(fRadius); } | 348 int width() const { return GrMorphologyEffect::WidthFromRadius(fRadius); } |
350 | 349 |
351 int fRadius; | 350 int fRadius; |
352 GrMorphologyEffect::MorphologyType fType; | 351 GrMorphologyEffect::MorphologyType fType; |
353 GrGLProgramDataManager::UniformHandle fImageIncrementUni; | 352 GrGLProgramDataManager::UniformHandle fImageIncrementUni; |
354 | 353 |
355 typedef GrGLFragmentProcessor INHERITED; | 354 typedef GrGLFragmentProcessor INHERITED; |
356 }; | 355 }; |
357 | 356 |
358 GrGLMorphologyEffect::GrGLMorphologyEffect(const GrBackendProcessorFactory& fact
ory, | 357 GrGLMorphologyEffect::GrGLMorphologyEffect(const GrBackendProcessorFactory& fact
ory, |
359 const GrProcessor& proc) | 358 const GrProcessor& proc) |
360 : INHERITED(factory) { | 359 : INHERITED(factory) { |
361 const GrMorphologyEffect& m = proc.cast<GrMorphologyEffect>(); | 360 const GrMorphologyEffect& m = proc.cast<GrMorphologyEffect>(); |
362 fRadius = m.radius(); | 361 fRadius = m.radius(); |
363 fType = m.type(); | 362 fType = m.type(); |
364 } | 363 } |
365 | 364 |
366 void GrGLMorphologyEffect::emitCode(GrGLFPBuilder* builder, | 365 void GrGLMorphologyEffect::emitCode(GrGLFPBuilder* builder, |
367 const GrFragmentProcessor&, | 366 const GrFragmentProcessor&, |
368 const GrProcessorKey& key, | |
369 const char* outputColor, | 367 const char* outputColor, |
370 const char* inputColor, | 368 const char* inputColor, |
371 const TransformedCoordsArray& coords, | 369 const TransformedCoordsArray& coords, |
372 const TextureSamplerArray& samplers) { | 370 const TextureSamplerArray& samplers) { |
373 fImageIncrementUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visib
ility, | 371 fImageIncrementUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visib
ility, |
374 kVec2f_GrSLType, "ImageIncrement"); | 372 kVec2f_GrSLType, "ImageIncrement"); |
375 | 373 |
376 GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); | 374 GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); |
377 SkString coords2D = fsBuilder->ensureFSCoords2D(coords, 0); | 375 SkString coords2D = fsBuilder->ensureFSCoords2D(coords, 0); |
378 const char* func; | 376 const char* func; |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
602 SkBitmap* result, SkIPoint* offset) con
st { | 600 SkBitmap* result, SkIPoint* offset) con
st { |
603 return this->filterImageGPUGeneric(true, proxy, src, ctx, result, offset); | 601 return this->filterImageGPUGeneric(true, proxy, src, ctx, result, offset); |
604 } | 602 } |
605 | 603 |
606 bool SkErodeImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const
Context& ctx, | 604 bool SkErodeImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const
Context& ctx, |
607 SkBitmap* result, SkIPoint* offset) cons
t { | 605 SkBitmap* result, SkIPoint* offset) cons
t { |
608 return this->filterImageGPUGeneric(false, proxy, src, ctx, result, offset); | 606 return this->filterImageGPUGeneric(false, proxy, src, ctx, result, offset); |
609 } | 607 } |
610 | 608 |
611 #endif | 609 #endif |
OLD | NEW |