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

Side by Side Diff: src/gpu/GrImageIDTextureAdjuster.cpp

Issue 1459433002: Convert SkGpuDevice::drawTextureAdjuster to SkGpuDevice::drawTextureProducer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: move domain opt Created 5 years, 1 month 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 2015 Google Inc. 2 * Copyright 2015 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 "GrImageIDTextureAdjuster.h" 8 #include "GrImageIDTextureAdjuster.h"
9 9
10 #include "GrContext.h"
11 #include "GrGpuResourcePriv.h"
10 #include "SkBitmap.h" 12 #include "SkBitmap.h"
11 #include "SkGrPriv.h" 13 #include "SkGrPriv.h"
12 #include "SkImage_Base.h" 14 #include "SkImage_Base.h"
13 15 #include "SkPixelRef.h"
14 16
15 GrBitmapTextureAdjuster::GrBitmapTextureAdjuster(const SkBitmap* bmp) 17 GrBitmapTextureAdjuster::GrBitmapTextureAdjuster(const SkBitmap* bmp)
16 : INHERITED(bmp->getTexture(), SkIRect::MakeWH(bmp->width(), bmp->height())) 18 : INHERITED(bmp->getTexture(), SkIRect::MakeWH(bmp->width(), bmp->height()))
17 , fBmp(bmp) {} 19 , fBmp(bmp) {}
18 20
19 void GrBitmapTextureAdjuster::makeCopyKey(const CopyParams& params, GrUniqueKey* copyKey) { 21 void GrBitmapTextureAdjuster::makeCopyKey(const CopyParams& params, GrUniqueKey* copyKey) {
20 if (fBmp->isVolatile()) { 22 if (fBmp->isVolatile()) {
21 return; 23 return;
22 } 24 }
23 // The content area must represent the whole bitmap. Texture-backed bitmaps don't support 25 // The content area must represent the whole bitmap. Texture-backed bitmaps don't support
(...skipping 21 matching lines...) Expand all
45 // image's width and height for the key's rectangle. 47 // image's width and height for the key's rectangle.
46 GrUniqueKey baseKey; 48 GrUniqueKey baseKey;
47 GrMakeKeyFromImageID(&baseKey, fImageBase->uniqueID(), 49 GrMakeKeyFromImageID(&baseKey, fImageBase->uniqueID(),
48 SkIRect::MakeWH(fImageBase->width(), fImageBase->height ())); 50 SkIRect::MakeWH(fImageBase->width(), fImageBase->height ()));
49 MakeCopyKeyFromOrigKey(baseKey, params, copyKey); 51 MakeCopyKeyFromOrigKey(baseKey, params, copyKey);
50 } 52 }
51 53
52 void GrImageTextureAdjuster::didCacheCopy(const GrUniqueKey& copyKey) { 54 void GrImageTextureAdjuster::didCacheCopy(const GrUniqueKey& copyKey) {
53 // We don't currently have a mechanism for notifications on Images! 55 // We don't currently have a mechanism for notifications on Images!
54 } 56 }
57
58 //////////////////////////////////////////////////////////////////////////////
59
60 GrBitmapTextureMaker::GrBitmapTextureMaker(GrContext* context, const SkBitmap& b itmap)
61 : INHERITED(context, bitmap.width(), bitmap.height())
62 , fBitmap(bitmap)
robertphillips 2015/11/18 13:58:35 prev line for the '{' ?
bsalomon 2015/11/18 18:05:37 Done.
63 {
64 SkASSERT(!bitmap.getTexture());
65 if (!bitmap.isVolatile()) {
66 SkIPoint origin = bitmap.pixelRefOrigin();
67 SkIRect subset = SkIRect::MakeXYWH(origin.fX, origin.fY, bitmap.width(),
68 bitmap.height());
69 GrMakeKeyFromImageID(&fOriginalKey, bitmap.pixelRef()->getGenerationID() , subset);
70 }
71 }
72
73 GrTexture* GrBitmapTextureMaker::refOriginalTexture() {
74 GrTexture* tex;
75
76 if (fOriginalKey.isValid()) {
77 tex = this->context()->textureProvider()->findAndRefTextureByUniqueKey(f OriginalKey);
78 if (tex) {
79 return tex;
80 }
81 }
82
83 tex = GrUploadBitmapToTexture(this->context(), fBitmap);
84 if (tex && fOriginalKey.isValid()) {
85 tex->resourcePriv().setUniqueKey(fOriginalKey);
86 GrInstallBitmapUniqueKeyInvalidator(fOriginalKey, fBitmap.pixelRef());
87 }
88 return tex;
89 }
90
91 void GrBitmapTextureMaker::makeCopyKey(const CopyParams& copyParams, GrUniqueKey * copyKey) {
92 if (fOriginalKey.isValid()) {
93 MakeCopyKeyFromOrigKey(fOriginalKey, copyParams, copyKey);
94 }
95 }
96
97 void GrBitmapTextureMaker::didCacheCopy(const GrUniqueKey& copyKey) {
98 GrInstallBitmapUniqueKeyInvalidator(copyKey, fBitmap.pixelRef());
99 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698