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

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

Issue 2241353002: pin as texture api (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: use refPinnedTexture in GpuDevice Created 4 years, 4 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
OLDNEW
1 /* 1 /*
2 * Copyright 2008 The Android Open Source Project 2 * Copyright 2008 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 "SkBitmapDevice.h" 8 #include "SkBitmapDevice.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkCanvasPriv.h" 10 #include "SkCanvasPriv.h"
(...skipping 2354 matching lines...) Expand 10 before | Expand all | Expand 10 after
2365 // Once we can filter and the filter will return a result larger than itself , we should be 2365 // Once we can filter and the filter will return a result larger than itself , we should be
2366 // able to remove this constraint. 2366 // able to remove this constraint.
2367 // skbug.com/4526 2367 // skbug.com/4526
2368 // 2368 //
2369 SkPoint pt; 2369 SkPoint pt;
2370 ctm.mapXY(x, y, &pt); 2370 ctm.mapXY(x, y, &pt);
2371 SkIRect ir = SkIRect::MakeXYWH(SkScalarRoundToInt(pt.x()), SkScalarRoundToIn t(pt.y()), w, h); 2371 SkIRect ir = SkIRect::MakeXYWH(SkScalarRoundToInt(pt.x()), SkScalarRoundToIn t(pt.y()), w, h);
2372 return ir.contains(fMCRec->fRasterClip.getBounds()); 2372 return ir.contains(fMCRec->fRasterClip.getBounds());
2373 } 2373 }
2374 2374
2375 class TestPinImage {
2376 public:
2377 TestPinImage(SkCanvas* canvas, const SkImage* image) {
2378 if ((fCtx = canvas->getGrContext()) != nullptr) {
2379 fImage = image;
2380 image->pinAsTexture(fCtx);
2381 }
2382 }
2383 ~TestPinImage() {
2384 if (fImage) {
2385 fImage->unpinAsTexture(fCtx);
2386 }
2387 }
2388 GrContext* fCtx;
2389 const SkImage* fImage = nullptr;
2390 };
2391
2375 void SkCanvas::onDrawImage(const SkImage* image, SkScalar x, SkScalar y, const S kPaint* paint) { 2392 void SkCanvas::onDrawImage(const SkImage* image, SkScalar x, SkScalar y, const S kPaint* paint) {
2393 TestPinImage test(this, image);
2394
2376 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawImage()"); 2395 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawImage()");
2377 SkRect bounds = SkRect::MakeXYWH(x, y, 2396 SkRect bounds = SkRect::MakeXYWH(x, y,
2378 SkIntToScalar(image->width()), SkIntToScala r(image->height())); 2397 SkIntToScalar(image->width()), SkIntToScala r(image->height()));
2379 if (nullptr == paint || paint->canComputeFastBounds()) { 2398 if (nullptr == paint || paint->canComputeFastBounds()) {
2380 SkRect tmp = bounds; 2399 SkRect tmp = bounds;
2381 if (paint) { 2400 if (paint) {
2382 paint->computeFastBounds(tmp, &tmp); 2401 paint->computeFastBounds(tmp, &tmp);
2383 } 2402 }
2384 if (this->quickReject(tmp)) { 2403 if (this->quickReject(tmp)) {
2385 return; 2404 return;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
2437 2456
2438 while (iter.next()) { 2457 while (iter.next()) {
2439 iter.fDevice->drawImageLattice(iter, image, lattice, dst, looper.paint() ); 2458 iter.fDevice->drawImageLattice(iter, image, lattice, dst, looper.paint() );
2440 } 2459 }
2441 2460
2442 LOOPER_END 2461 LOOPER_END
2443 } 2462 }
2444 2463
2445 void SkCanvas::onDrawImageRect(const SkImage* image, const SkRect* src, const Sk Rect& dst, 2464 void SkCanvas::onDrawImageRect(const SkImage* image, const SkRect* src, const Sk Rect& dst,
2446 const SkPaint* paint, SrcRectConstraint constrain t) { 2465 const SkPaint* paint, SrcRectConstraint constrain t) {
2466 TestPinImage test(this, image);
2467
2447 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawImageRect()"); 2468 TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawImageRect()");
2448 if (nullptr == paint || paint->canComputeFastBounds()) { 2469 if (nullptr == paint || paint->canComputeFastBounds()) {
2449 SkRect storage = dst; 2470 SkRect storage = dst;
2450 if (paint) { 2471 if (paint) {
2451 paint->computeFastBounds(dst, &storage); 2472 paint->computeFastBounds(dst, &storage);
2452 } 2473 }
2453 if (this->quickReject(storage)) { 2474 if (this->quickReject(storage)) {
2454 return; 2475 return;
2455 } 2476 }
2456 } 2477 }
(...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after
3359 3380
3360 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { 3381 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() {
3361 fCanvas->restoreToCount(fSaveCount); 3382 fCanvas->restoreToCount(fSaveCount);
3362 } 3383 }
3363 3384
3364 #ifdef SK_SUPPORT_LEGACY_NEW_SURFACE_API 3385 #ifdef SK_SUPPORT_LEGACY_NEW_SURFACE_API
3365 SkSurface* SkCanvas::newSurface(const SkImageInfo& info, const SkSurfaceProps* p rops) { 3386 SkSurface* SkCanvas::newSurface(const SkImageInfo& info, const SkSurfaceProps* p rops) {
3366 return this->makeSurface(info, props).release(); 3387 return this->makeSurface(info, props).release();
3367 } 3388 }
3368 #endif 3389 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698