| OLD | NEW |
| 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 | 7 |
| 8 #include "SkCanvas.h" | 8 #include "SkCanvas.h" |
| 9 #include "SkImage_Base.h" | 9 #include "SkImage_Base.h" |
| 10 #include "SkSpecialImage.h" | 10 #include "SkSpecialImage.h" |
| 11 #include "SkSpecialSurface.h" | 11 #include "SkSpecialSurface.h" |
| 12 | 12 |
| 13 /////////////////////////////////////////////////////////////////////////////// | 13 /////////////////////////////////////////////////////////////////////////////// |
| 14 class SkSpecialImage_Base : public SkSpecialImage { | 14 class SkSpecialImage_Base : public SkSpecialImage { |
| 15 public: | 15 public: |
| 16 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) |
| 17 : INHERITED(proxy, subset, uniqueID) { | 17 : INHERITED(proxy, subset, uniqueID) { |
| 18 } | 18 } |
| 19 virtual ~SkSpecialImage_Base() { } | 19 virtual ~SkSpecialImage_Base() { } |
| 20 | 20 |
| 21 virtual void onDraw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) const
= 0; | 21 virtual void onDraw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) const
= 0; |
| 22 | 22 |
| 23 virtual bool testingOnlyOnPeekPixels(SkPixmap*) const { return false; } | 23 virtual bool testingOnlyOnPeekPixels(SkPixmap*) const { return false; } |
| 24 | 24 |
| 25 virtual GrTexture* onPeekTexture() const { return nullptr; } | 25 virtual GrTexture* onPeekTexture() const { return nullptr; } |
| 26 | 26 |
| 27 virtual bool testingOnlyOnGetROPixels(SkBitmap*) const = 0; | 27 virtual bool testingOnlyOnGetROPixels(SkBitmap*) const = 0; |
| 28 | 28 |
| 29 // Delete this entry point ASAP (see skbug.com/4965) | 29 // Delete this entry point ASAP (see skbug.com/4965) |
| 30 virtual bool getBitmap(SkBitmap* result) const = 0; | 30 virtual bool getBitmapDeprecated(SkBitmap* result) const = 0; |
| 31 | 31 |
| 32 virtual SkSpecialSurface* onNewSurface(const SkImageInfo& info) const { retu
rn nullptr; } | 32 virtual SkSpecialSurface* onNewSurface(const SkImageInfo& info) const { retu
rn nullptr; } |
| 33 | 33 |
| 34 private: | 34 private: |
| 35 typedef SkSpecialImage INHERITED; | 35 typedef SkSpecialImage INHERITED; |
| 36 }; | 36 }; |
| 37 | 37 |
| 38 /////////////////////////////////////////////////////////////////////////////// | 38 /////////////////////////////////////////////////////////////////////////////// |
| 39 static inline const SkSpecialImage_Base* as_SIB(const SkSpecialImage* image) { | 39 static inline const SkSpecialImage_Base* as_SIB(const SkSpecialImage* image) { |
| 40 return static_cast<const SkSpecialImage_Base*>(image); | 40 return static_cast<const SkSpecialImage_Base*>(image); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 src.getTexture()); | 75 src.getTexture()); |
| 76 } | 76 } |
| 77 | 77 |
| 78 return SkSpecialImage::NewFromRaster(proxy, src.bounds(), src); | 78 return SkSpecialImage::NewFromRaster(proxy, src.bounds(), src); |
| 79 } | 79 } |
| 80 | 80 |
| 81 bool SkSpecialImage::internal_getBM(SkBitmap* result) { | 81 bool SkSpecialImage::internal_getBM(SkBitmap* result) { |
| 82 const SkSpecialImage_Base* ib = as_SIB(this); | 82 const SkSpecialImage_Base* ib = as_SIB(this); |
| 83 | 83 |
| 84 // TODO: need to test offset case! (see skbug.com/4967) | 84 // TODO: need to test offset case! (see skbug.com/4967) |
| 85 return ib->getBitmap(result); | 85 return ib->getBitmapDeprecated(result); |
| 86 } | 86 } |
| 87 | 87 |
| 88 SkImageFilter::Proxy* SkSpecialImage::internal_getProxy() { | 88 SkImageFilter::Proxy* SkSpecialImage::internal_getProxy() { |
| 89 SkASSERT(fProxy); | 89 SkASSERT(fProxy); |
| 90 return fProxy; | 90 return fProxy; |
| 91 } | 91 } |
| 92 | 92 |
| 93 /////////////////////////////////////////////////////////////////////////////// | 93 /////////////////////////////////////////////////////////////////////////////// |
| 94 #include "SkImage.h" | 94 #include "SkImage.h" |
| 95 #if SK_SUPPORT_GPU | 95 #if SK_SUPPORT_GPU |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 canvas->drawImageRect(fImage, this->subset(), | 130 canvas->drawImageRect(fImage, this->subset(), |
| 131 dst, paint, SkCanvas::kStrict_SrcRectConstraint); | 131 dst, paint, SkCanvas::kStrict_SrcRectConstraint); |
| 132 } | 132 } |
| 133 | 133 |
| 134 bool testingOnlyOnPeekPixels(SkPixmap* pixmap) const override { | 134 bool testingOnlyOnPeekPixels(SkPixmap* pixmap) const override { |
| 135 return fImage->peekPixels(pixmap); | 135 return fImage->peekPixels(pixmap); |
| 136 } | 136 } |
| 137 | 137 |
| 138 GrTexture* onPeekTexture() const override { return as_IB(fImage.get())->peek
Texture(); } | 138 GrTexture* onPeekTexture() const override { return as_IB(fImage.get())->peek
Texture(); } |
| 139 | 139 |
| 140 bool getBitmap(SkBitmap* result) const override { | 140 bool getBitmapDeprecated(SkBitmap* result) const override { |
| 141 return false; | 141 return false; |
| 142 } | 142 } |
| 143 | 143 |
| 144 bool testingOnlyOnGetROPixels(SkBitmap* result) const override { | 144 bool testingOnlyOnGetROPixels(SkBitmap* result) const override { |
| 145 return false; | 145 return false; |
| 146 } | 146 } |
| 147 | 147 |
| 148 SkSpecialSurface* onNewSurface(const SkImageInfo& info) const override { | 148 SkSpecialSurface* onNewSurface(const SkImageInfo& info) const override { |
| 149 #if SK_SUPPORT_GPU | 149 #if SK_SUPPORT_GPU |
| 150 GrTexture* texture = as_IB(fImage.get())->peekTexture(); | 150 GrTexture* texture = as_IB(fImage.get())->peekTexture(); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 const void* pixels = fBitmap.getPixels(); | 222 const void* pixels = fBitmap.getPixels(); |
| 223 if (pixels) { | 223 if (pixels) { |
| 224 if (pixmap) { | 224 if (pixmap) { |
| 225 pixmap->reset(info, pixels, fBitmap.rowBytes()); | 225 pixmap->reset(info, pixels, fBitmap.rowBytes()); |
| 226 } | 226 } |
| 227 return true; | 227 return true; |
| 228 } | 228 } |
| 229 return false; | 229 return false; |
| 230 } | 230 } |
| 231 | 231 |
| 232 bool getBitmap(SkBitmap* result) const override { | 232 bool getBitmapDeprecated(SkBitmap* result) const override { |
| 233 *result = fBitmap; | 233 *result = fBitmap; |
| 234 return true; | 234 return true; |
| 235 } | 235 } |
| 236 | 236 |
| 237 bool testingOnlyOnGetROPixels(SkBitmap* result) const override { | 237 bool testingOnlyOnGetROPixels(SkBitmap* result) const override { |
| 238 *result = fBitmap; | 238 *result = fBitmap; |
| 239 return true; | 239 return true; |
| 240 } | 240 } |
| 241 | 241 |
| 242 SkSpecialSurface* onNewSurface(const SkImageInfo& info) const override { | 242 SkSpecialSurface* onNewSurface(const SkImageInfo& info) const override { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 | 286 |
| 287 GrWrapTextureInBitmap(fTexture, | 287 GrWrapTextureInBitmap(fTexture, |
| 288 fTexture->width(), fTexture->height(), this->isOpa
que(), &bm); | 288 fTexture->width(), fTexture->height(), this->isOpa
que(), &bm); |
| 289 | 289 |
| 290 canvas->drawBitmapRect(bm, this->subset(), | 290 canvas->drawBitmapRect(bm, this->subset(), |
| 291 dst, paint, SkCanvas::kStrict_SrcRectConstraint); | 291 dst, paint, SkCanvas::kStrict_SrcRectConstraint); |
| 292 } | 292 } |
| 293 | 293 |
| 294 GrTexture* onPeekTexture() const override { return fTexture; } | 294 GrTexture* onPeekTexture() const override { return fTexture; } |
| 295 | 295 |
| 296 bool getBitmap(SkBitmap* result) const override { | 296 bool getBitmapDeprecated(SkBitmap* result) const override { |
| 297 const SkImageInfo info = GrMakeInfoFromTexture(fTexture, | 297 const SkImageInfo info = GrMakeInfoFromTexture(fTexture, |
| 298 this->width(), this->heig
ht(), | 298 this->width(), this->heig
ht(), |
| 299 this->isOpaque()); | 299 this->isOpaque()); |
| 300 if (!result->setInfo(info)) { | 300 if (!result->setInfo(info)) { |
| 301 return false; | 301 return false; |
| 302 } | 302 } |
| 303 | 303 |
| 304 result->setPixelRef(new SkGrPixelRef(info, fTexture))->unref(); | 304 result->setPixelRef(new SkGrPixelRef(info, fTexture))->unref(); |
| 305 return true; | 305 return true; |
| 306 } | 306 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 | 351 |
| 352 SkSpecialImage* SkSpecialImage::NewFromGpu(SkImageFilter::Proxy* proxy, | 352 SkSpecialImage* SkSpecialImage::NewFromGpu(SkImageFilter::Proxy* proxy, |
| 353 const SkIRect& subset, | 353 const SkIRect& subset, |
| 354 uint32_t uniqueID, | 354 uint32_t uniqueID, |
| 355 GrTexture* tex, | 355 GrTexture* tex, |
| 356 SkAlphaType at) { | 356 SkAlphaType at) { |
| 357 return nullptr; | 357 return nullptr; |
| 358 } | 358 } |
| 359 | 359 |
| 360 #endif | 360 #endif |
| OLD | NEW |