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

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

Issue 2147023002: use gpu-image instead of wrapping in a bitmap for specialimage (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 5 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 | « no previous file | no next file » | 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" 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
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698