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 #include "SkSpecialImage.h" | 7 #include "SkSpecialImage.h" |
8 | 8 |
9 #if SK_SUPPORT_GPU | 9 #if SK_SUPPORT_GPU |
10 #include "GrTexture.h" | 10 #include "GrTexture.h" |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 bool isOpaque() const override { | 466 bool isOpaque() const override { |
467 return GrPixelConfigIsOpaque(fTexture->config()) || fAlphaType == kOpaqu
e_SkAlphaType; | 467 return GrPixelConfigIsOpaque(fTexture->config()) || fAlphaType == kOpaqu
e_SkAlphaType; |
468 } | 468 } |
469 | 469 |
470 size_t getSize() const override { return fTexture->gpuMemorySize(); } | 470 size_t getSize() const override { return fTexture->gpuMemorySize(); } |
471 | 471 |
472 void onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPaint* paint)
const override { | 472 void onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPaint* paint)
const override { |
473 SkRect dst = SkRect::MakeXYWH(x, y, | 473 SkRect dst = SkRect::MakeXYWH(x, y, |
474 this->subset().width(), this->subset().hei
ght()); | 474 this->subset().width(), this->subset().hei
ght()); |
475 | 475 |
476 SkBitmap bm; | 476 auto img = sk_sp<SkImage>(new SkImage_Gpu(fTexture->width(), fTexture->h
eight(), |
| 477 this->uniqueID(), fAlphaType,
fTexture.get(), |
| 478 SkBudgeted::kNo)); |
477 | 479 |
478 GrWrapTextureInBitmap(fTexture.get(), | 480 canvas->drawImageRect(img, this->subset(), |
479 fTexture->width(), fTexture->height(), this->isOpa
que(), &bm); | |
480 | |
481 canvas->drawBitmapRect(bm, this->subset(), | |
482 dst, paint, SkCanvas::kStrict_SrcRectConstraint); | 481 dst, paint, SkCanvas::kStrict_SrcRectConstraint); |
483 } | 482 } |
484 | 483 |
485 GrTexture* onPeekTexture() const override { return fTexture.get(); } | 484 GrTexture* onPeekTexture() const override { return fTexture.get(); } |
486 | 485 |
487 sk_sp<GrTexture> onAsTextureRef(GrContext*) const override { return fTexture
; } | 486 sk_sp<GrTexture> onAsTextureRef(GrContext*) const override { return fTexture
; } |
488 | 487 |
489 bool onGetROPixels(SkBitmap* dst) const override { | 488 bool onGetROPixels(SkBitmap* dst) const override { |
490 if (SkBitmapCache::Find(this->uniqueID(), dst)) { | 489 if (SkBitmapCache::Find(this->uniqueID(), dst)) { |
491 SkASSERT(dst->getGenerationID() == this->uniqueID()); | 490 SkASSERT(dst->getGenerationID() == this->uniqueID()); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 sk_sp<SkSpecialImage> SkSpecialImage::MakeFromGpu(const SkIRect& subset, | 586 sk_sp<SkSpecialImage> SkSpecialImage::MakeFromGpu(const SkIRect& subset, |
588 uint32_t uniqueID, | 587 uint32_t uniqueID, |
589 sk_sp<GrTexture> tex, | 588 sk_sp<GrTexture> tex, |
590 const SkSurfaceProps* props, | 589 const SkSurfaceProps* props, |
591 SkAlphaType at) { | 590 SkAlphaType at) { |
592 SkASSERT(rect_fits(subset, tex->width(), tex->height())); | 591 SkASSERT(rect_fits(subset, tex->width(), tex->height())); |
593 return sk_make_sp<SkSpecialImage_Gpu>(subset, uniqueID, std::move(tex), at,
props); | 592 return sk_make_sp<SkSpecialImage_Gpu>(subset, uniqueID, std::move(tex), at,
props); |
594 } | 593 } |
595 | 594 |
596 #endif | 595 #endif |
OLD | NEW |