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

Side by Side Diff: src/core/SkSpecialImage.cpp

Issue 1811973005: Revert of Add SkSpecialImage::makeTextureImage entry point & update filterInput (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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/core/SkSpecialImage.h ('k') | tests/SpecialImageTest.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 2016 Google Inc. 2 * Copyright 2016 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 #include "SkSpecialImage.h"
8
9 #if SK_SUPPORT_GPU
10 #include "GrTexture.h"
11 #include "GrTextureParams.h"
12 #include "SkGr.h"
13 #endif
14 7
15 #include "SkCanvas.h" 8 #include "SkCanvas.h"
16 #include "SkImage_Base.h" 9 #include "SkImage_Base.h"
10 #include "SkSpecialImage.h"
17 #include "SkSpecialSurface.h" 11 #include "SkSpecialSurface.h"
18 12
19 /////////////////////////////////////////////////////////////////////////////// 13 ///////////////////////////////////////////////////////////////////////////////
20 class SkSpecialImage_Base : public SkSpecialImage { 14 class SkSpecialImage_Base : public SkSpecialImage {
21 public: 15 public:
22 SkSpecialImage_Base(SkImageFilter::Proxy* proxy, const SkIRect& subset, uint 32_t uniqueID) 16 SkSpecialImage_Base(SkImageFilter::Proxy* proxy, const SkIRect& subset, uint 32_t uniqueID)
23 : INHERITED(proxy, subset, uniqueID) { 17 : INHERITED(proxy, subset, uniqueID) {
24 } 18 }
25 virtual ~SkSpecialImage_Base() { } 19 virtual ~SkSpecialImage_Base() { }
26 20
(...skipping 14 matching lines...) Expand all
41 35
42 private: 36 private:
43 typedef SkSpecialImage INHERITED; 37 typedef SkSpecialImage INHERITED;
44 }; 38 };
45 39
46 /////////////////////////////////////////////////////////////////////////////// 40 ///////////////////////////////////////////////////////////////////////////////
47 static inline const SkSpecialImage_Base* as_SIB(const SkSpecialImage* image) { 41 static inline const SkSpecialImage_Base* as_SIB(const SkSpecialImage* image) {
48 return static_cast<const SkSpecialImage_Base*>(image); 42 return static_cast<const SkSpecialImage_Base*>(image);
49 } 43 }
50 44
51 sk_sp<SkSpecialImage> SkSpecialImage::makeTextureImage(SkImageFilter::Proxy* pro xy,
52 GrContext* context) {
53 #if SK_SUPPORT_GPU
54 if (!context) {
55 return nullptr;
56 }
57 if (GrTexture* peek = as_SIB(this)->peekTexture()) {
58 return peek->getContext() == context ? sk_sp<SkSpecialImage>(SkRef(this) ) : nullptr;
59 }
60
61 SkBitmap bmp;
62 if (!this->internal_getBM(&bmp)) {
63 return nullptr;
64 }
65
66 SkAutoTUnref<GrTexture> resultTex(
67 GrRefCachedBitmapTexture(context, bmp, GrTextureParams::ClampNoFilter()) );
68 if (!resultTex) {
69 return nullptr;
70 }
71
72 SkAlphaType at = this->isOpaque() ? kOpaque_SkAlphaType : kPremul_SkAlphaTyp e;
73
74 return SkSpecialImage::MakeFromGpu(proxy,
75 SkIRect::MakeWH(resultTex->width(), resul tTex->height()),
76 this->uniqueID(),
77 resultTex, at);
78 #else
79 return nullptr;
80 #endif
81 }
82
83 void SkSpecialImage::draw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPain t* paint) const { 45 void SkSpecialImage::draw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPain t* paint) const {
84 return as_SIB(this)->onDraw(canvas, x, y, paint); 46 return as_SIB(this)->onDraw(canvas, x, y, paint);
85 } 47 }
86 48
87 bool SkSpecialImage::peekPixels(SkPixmap* pixmap) const { 49 bool SkSpecialImage::peekPixels(SkPixmap* pixmap) const {
88 return as_SIB(this)->onPeekPixels(pixmap); 50 return as_SIB(this)->onPeekPixels(pixmap);
89 } 51 }
90 52
91 GrTexture* SkSpecialImage::peekTexture() const { 53 GrTexture* SkSpecialImage::peekTexture() const {
92 return as_SIB(this)->onPeekTexture(); 54 return as_SIB(this)->onPeekTexture();
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 426
465 sk_sp<SkSpecialImage> SkSpecialImage::MakeFromGpu(SkImageFilter::Proxy* proxy, 427 sk_sp<SkSpecialImage> SkSpecialImage::MakeFromGpu(SkImageFilter::Proxy* proxy,
466 const SkIRect& subset, 428 const SkIRect& subset,
467 uint32_t uniqueID, 429 uint32_t uniqueID,
468 GrTexture* tex, 430 GrTexture* tex,
469 SkAlphaType at) { 431 SkAlphaType at) {
470 return nullptr; 432 return nullptr;
471 } 433 }
472 434
473 #endif 435 #endif
OLDNEW
« no previous file with comments | « src/core/SkSpecialImage.h ('k') | tests/SpecialImageTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698