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

Side by Side Diff: src/effects/SkLightingImageFilter.cpp

Issue 1929833004: Revert of Refactor drawContext/RenderTarget creation (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/effects/SkDisplacementMapEffect.cpp ('k') | src/effects/SkMorphologyImageFilter.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 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 "SkLightingImageFilter.h" 8 #include "SkLightingImageFilter.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 SkSpecialIma ge* input, 400 SkSpecialIma ge* input,
401 const SkIRec t& offsetBounds, 401 const SkIRec t& offsetBounds,
402 const SkMatr ix& matrix) const { 402 const SkMatr ix& matrix) const {
403 SkASSERT(source->isTextureBacked()); 403 SkASSERT(source->isTextureBacked());
404 404
405 GrContext* context = source->getContext(); 405 GrContext* context = source->getContext();
406 406
407 sk_sp<GrTexture> inputTexture(input->asTextureRef(context)); 407 sk_sp<GrTexture> inputTexture(input->asTextureRef(context));
408 SkASSERT(inputTexture); 408 SkASSERT(inputTexture);
409 409
410 sk_sp<GrDrawContext> drawContext(context->newDrawContext(GrContext::kLoose_B ackingFit, 410 GrSurfaceDesc desc;
411 offsetBounds.width( ), 411 desc.fFlags = kRenderTarget_GrSurfaceFlag,
412 offsetBounds.height (), 412 desc.fWidth = offsetBounds.width();
413 kRGBA_8888_GrPixelC onfig)); 413 desc.fHeight = offsetBounds.height();
414 desc.fConfig = kRGBA_8888_GrPixelConfig;
415
416 sk_sp<GrTexture> dst(context->textureProvider()->createApproxTexture(desc));
417 if (!dst) {
418 return nullptr;
419 }
420
421 sk_sp<GrDrawContext> drawContext(context->drawContext(sk_ref_sp(dst->asRende rTarget())));
414 if (!drawContext) { 422 if (!drawContext) {
415 return nullptr; 423 return nullptr;
416 } 424 }
417 425
418 SkRect dstRect = SkRect::MakeWH(SkIntToScalar(offsetBounds.width()), 426 SkRect dstRect = SkRect::MakeWH(SkIntToScalar(offsetBounds.width()),
419 SkIntToScalar(offsetBounds.height())); 427 SkIntToScalar(offsetBounds.height()));
420 428
421 // setup new clip 429 // setup new clip
422 GrClip clip(dstRect); 430 GrClip clip(dstRect);
423 431
(...skipping 23 matching lines...) Expand all
447 pSrcBounds, offsetBounds); 455 pSrcBounds, offsetBounds);
448 this->drawRect(drawContext.get(), inputTexture.get(), matrix, clip, bottomLe ft, 456 this->drawRect(drawContext.get(), inputTexture.get(), matrix, clip, bottomLe ft,
449 kBottomLeft_BoundaryMode, pSrcBounds, offsetBounds); 457 kBottomLeft_BoundaryMode, pSrcBounds, offsetBounds);
450 this->drawRect(drawContext.get(), inputTexture.get(), matrix, clip, bottom, 458 this->drawRect(drawContext.get(), inputTexture.get(), matrix, clip, bottom,
451 kBottom_BoundaryMode, pSrcBounds, offsetBounds); 459 kBottom_BoundaryMode, pSrcBounds, offsetBounds);
452 this->drawRect(drawContext.get(), inputTexture.get(), matrix, clip, bottomRi ght, 460 this->drawRect(drawContext.get(), inputTexture.get(), matrix, clip, bottomRi ght,
453 kBottomRight_BoundaryMode, pSrcBounds, offsetBounds); 461 kBottomRight_BoundaryMode, pSrcBounds, offsetBounds);
454 462
455 return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(offsetBounds.width(), off setBounds.height()), 463 return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(offsetBounds.width(), off setBounds.height()),
456 kNeedNewImageUniqueID_SpecialImage, 464 kNeedNewImageUniqueID_SpecialImage,
457 drawContext->asTexture()); 465 std::move(dst));
458 } 466 }
459 #endif 467 #endif
460 468
461 class SkDiffuseLightingImageFilter : public SkLightingImageFilterInternal { 469 class SkDiffuseLightingImageFilter : public SkLightingImageFilterInternal {
462 public: 470 public:
463 static sk_sp<SkImageFilter> Make(sk_sp<SkImageFilterLight> light, 471 static sk_sp<SkImageFilter> Make(sk_sp<SkImageFilterLight> light,
464 SkScalar surfaceScale, 472 SkScalar surfaceScale,
465 SkScalar kd, 473 SkScalar kd,
466 sk_sp<SkImageFilter>, 474 sk_sp<SkImageFilter>,
467 const CropRect*); 475 const CropRect*);
(...skipping 1695 matching lines...) Expand 10 before | Expand all | Expand 10 after
2163 2171
2164 fragBuilder->codeAppendf("%s(%s)", fLightColorFunc.c_str(), surfaceToLight); 2172 fragBuilder->codeAppendf("%s(%s)", fLightColorFunc.c_str(), surfaceToLight);
2165 } 2173 }
2166 2174
2167 #endif 2175 #endif
2168 2176
2169 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingImageFilter) 2177 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingImageFilter)
2170 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDiffuseLightingImageFilter) 2178 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDiffuseLightingImageFilter)
2171 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSpecularLightingImageFilter) 2179 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSpecularLightingImageFilter)
2172 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 2180 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
OLDNEW
« no previous file with comments | « src/effects/SkDisplacementMapEffect.cpp ('k') | src/effects/SkMorphologyImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698