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

Side by Side Diff: src/image/SkImage_Gpu.cpp

Issue 1249543003: Creating functions for uploading a mipmapped texture. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Fixing merge mistakes Created 5 years, 2 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
« include/gpu/GrContext.h ('K') | « src/gpu/gl/GrGLGpu.cpp ('k') | 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 2012 Google Inc. 2 * Copyright 2012 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 "SkBitmapCache.h" 8 #include "SkBitmapCache.h"
9 #include "SkImage_Gpu.h" 9 #include "SkImage_Gpu.h"
10 #include "GrCaps.h" 10 #include "GrCaps.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 dst->getPixels(), dst->rowBytes())) { 52 dst->getPixels(), dst->rowBytes())) {
53 return false; 53 return false;
54 } 54 }
55 55
56 dst->pixelRef()->setImmutableWithID(this->uniqueID()); 56 dst->pixelRef()->setImmutableWithID(this->uniqueID());
57 SkBitmapCache::Add(this->uniqueID(), *dst); 57 SkBitmapCache::Add(this->uniqueID(), *dst);
58 fAddedRasterVersionToCache.store(true); 58 fAddedRasterVersionToCache.store(true);
59 return true; 59 return true;
60 } 60 }
61 61
62 <<<<<<< HEAD
62 GrTexture* SkImage_Gpu::asTextureRef(GrContext* ctx, SkImageUsageType usage) con st { 63 GrTexture* SkImage_Gpu::asTextureRef(GrContext* ctx, SkImageUsageType usage) con st {
63 const bool is_pow2 = SkIsPow2(this->width()) && SkIsPow2(this->height()); 64 const bool is_pow2 = SkIsPow2(this->width()) && SkIsPow2(this->height());
64 const bool npot_tex_supported = ctx->caps()->npotTextureTileSupport(); 65 const bool npot_tex_supported = ctx->caps()->npotTextureTileSupport();
65 if (!is_pow2 && kUntiled_SkImageUsageType != usage && !npot_tex_supported) { 66 if (!is_pow2 && kUntiled_SkImageUsageType != usage && !npot_tex_supported) {
66 // load as bitmap, since the GPU can support tiling a non-pow2 texture 67 // load as bitmap, since the GPU can support tiling a non-pow2 texture
67 // related to skbug.com/4365 68 // related to skbug.com/4365
68 SkBitmap bitmap; 69 SkBitmap bitmap;
69 if (this->getROPixels(&bitmap)) { 70 if (this->getROPixels(&bitmap)) {
70 return GrRefCachedBitmapTexture(ctx, bitmap, usage); 71 return GrRefCachedBitmapTexture(ctx, bitmap, usage);
71 } else { 72 } else {
72 return nullptr; 73 return nullptr;
73 } 74 }
75 ||||||| merged common ancestors
76 static void make_raw_texture_stretched_key(uint32_t imageID, const SkGrStretch& stretch,
77 GrUniqueKey* stretchedKey) {
78 SkASSERT(SkGrStretch::kNone_Type != stretch.fType);
79
80 uint32_t width = SkToU16(stretch.fWidth);
81 uint32_t height = SkToU16(stretch.fHeight);
82
83 static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain();
84 GrUniqueKey::Builder builder(stretchedKey, kDomain, 3);
85 builder[0] = imageID;
86 builder[1] = stretch.fType;
87 builder[2] = width | (height << 16);
88 builder.finish();
89 }
90
91 class Texture_GrTextureMaker : public GrTextureMaker {
92 public:
93 Texture_GrTextureMaker(const SkImage* image, GrTexture* unstretched)
94 : INHERITED(image->width(), image->height())
95 , fImage(image)
96 , fUnstretched(unstretched)
97 {}
98
99 protected:
100 GrTexture* onRefUnstretchedTexture(GrContext* ctx) override {
101 return SkRef(fUnstretched);
102 }
103
104 bool onMakeStretchedKey(const SkGrStretch& stretch, GrUniqueKey* stretchedKe y) override {
105 make_raw_texture_stretched_key(fImage->uniqueID(), stretch, stretchedKey );
106 return stretchedKey->isValid();
107 }
108
109 void onNotifyStretchCached(const GrUniqueKey& stretchedKey) override {
110 as_IB(fImage)->notifyAddedToCache();
111 }
112
113 bool onGetROBitmap(SkBitmap* bitmap) override {
114 return as_IB(fImage)->getROPixels(bitmap);
115 =======
116 static void make_raw_texture_stretched_key(uint32_t imageID, const SkGrStretch& stretch,
117 GrUniqueKey* stretchedKey) {
118 SkASSERT(SkGrStretch::kNone_Type != stretch.fType);
119
120 uint32_t width = SkToU16(stretch.fWidth);
121 uint32_t height = SkToU16(stretch.fHeight);
122
123 static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain();
124 GrUniqueKey::Builder builder(stretchedKey, kDomain, 3);
125 builder[0] = imageID;
126 builder[1] = stretch.fType;
127 builder[2] = width | (height << 16);
128 builder.finish();
129 }
130
131 class Texture_GrTextureMaker : public GrTextureMaker {
132 public:
133 Texture_GrTextureMaker(const SkImage* image, GrTexture* unstretched)
134 : INHERITED(image->width(), image->height())
135 , fImage(image)
136 , fUnstretched(unstretched)
137 {}
138
139 protected:
140 GrTexture* onRefUnstretchedTexture(GrContext* ctx, const GrTextureParams*) o verride {
141 return SkRef(fUnstretched);
142 }
143
144 bool onMakeStretchedKey(const SkGrStretch& stretch, GrUniqueKey* stretchedKe y) override {
145 make_raw_texture_stretched_key(fImage->uniqueID(), stretch, stretchedKey );
146 return stretchedKey->isValid();
147 }
148
149 void onNotifyStretchCached(const GrUniqueKey& stretchedKey) override {
150 as_IB(fImage)->notifyAddedToCache();
151 }
152
153 bool onGetROBitmap(SkBitmap* bitmap) override {
154 return as_IB(fImage)->getROPixels(bitmap);
155 >>>>>>> Fixing the build.
74 } 156 }
75 157
76 fTexture->ref(); 158 fTexture->ref();
77 return fTexture; 159 return fTexture;
78 } 160 }
79 161
80 bool SkImage_Gpu::isOpaque() const { 162 bool SkImage_Gpu::isOpaque() const {
81 return GrPixelConfigIsOpaque(fTexture->config()) || fAlphaType == kOpaque_Sk AlphaType; 163 return GrPixelConfigIsOpaque(fTexture->config()) || fAlphaType == kOpaque_Sk AlphaType;
82 } 164 }
83 165
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 //////////////////////////////////////////////////////////////////////////////// /////////////////// 363 //////////////////////////////////////////////////////////////////////////////// ///////////////////
282 364
283 GrTexture* GrDeepCopyTexture(GrTexture* src, bool budgeted) { 365 GrTexture* GrDeepCopyTexture(GrTexture* src, bool budgeted) {
284 GrContext* ctx = src->getContext(); 366 GrContext* ctx = src->getContext();
285 367
286 GrSurfaceDesc desc = src->desc(); 368 GrSurfaceDesc desc = src->desc();
287 GrTexture* dst = ctx->textureProvider()->createTexture(desc, budgeted, nullp tr, 0); 369 GrTexture* dst = ctx->textureProvider()->createTexture(desc, budgeted, nullp tr, 0);
288 if (!dst) { 370 if (!dst) {
289 return nullptr; 371 return nullptr;
290 } 372 }
291 373
292 const SkIRect srcR = SkIRect::MakeWH(desc.fWidth, desc.fHeight); 374 const SkIRect srcR = SkIRect::MakeWH(desc.fWidth, desc.fHeight);
293 const SkIPoint dstP = SkIPoint::Make(0, 0); 375 const SkIPoint dstP = SkIPoint::Make(0, 0);
294 ctx->copySurface(dst, src, srcR, dstP, GrContext::kFlushWrites_PixelOp); 376 ctx->copySurface(dst, src, srcR, dstP, GrContext::kFlushWrites_PixelOp);
295 return dst; 377 return dst;
296 } 378 }
297 379
OLDNEW
« include/gpu/GrContext.h ('K') | « src/gpu/gl/GrGLGpu.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698