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

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

Issue 1459433002: Convert SkGpuDevice::drawTextureAdjuster to SkGpuDevice::drawTextureProducer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove redudant virtual decl 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
« no previous file with comments | « src/gpu/SkGpuDevice_drawTexture.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 2010 Google Inc. 2 * Copyright 2010 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 8
9 #include "SkGr.h" 9 #include "SkGr.h"
10 10
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 explicit Invalidator(const GrUniqueKey& key) : fMsg(key) {} 278 explicit Invalidator(const GrUniqueKey& key) : fMsg(key) {}
279 private: 279 private:
280 GrUniqueKeyInvalidatedMessage fMsg; 280 GrUniqueKeyInvalidatedMessage fMsg;
281 281
282 void onChange() override { SkMessageBus<GrUniqueKeyInvalidatedMessage>:: Post(fMsg); } 282 void onChange() override { SkMessageBus<GrUniqueKeyInvalidatedMessage>:: Post(fMsg); }
283 }; 283 };
284 284
285 pixelRef->addGenIDChangeListener(new Invalidator(key)); 285 pixelRef->addGenIDChangeListener(new Invalidator(key));
286 } 286 }
287 287
288 class RasterBitmap_GrTextureMaker : public GrTextureMaker {
289 public:
290 RasterBitmap_GrTextureMaker(const SkBitmap& bitmap)
291 : INHERITED(bitmap.width(), bitmap.height())
292 , fBitmap(bitmap)
293 {
294 SkASSERT(!bitmap.getTexture());
295 if (!bitmap.isVolatile()) {
296 SkIPoint origin = bitmap.pixelRefOrigin();
297 SkIRect subset = SkIRect::MakeXYWH(origin.fX, origin.fY, bitmap.widt h(),
298 bitmap.height());
299 GrMakeKeyFromImageID(&fOriginalKey, bitmap.pixelRef()->getGeneration ID(), subset);
300 }
301 }
302
303 protected:
304 GrTexture* refOriginalTexture(GrContext* ctx) override {
305 GrTexture* tex;
306
307 if (fOriginalKey.isValid()) {
308 tex = ctx->textureProvider()->findAndRefTextureByUniqueKey(fOriginal Key);
309 if (tex) {
310 return tex;
311 }
312 }
313
314 tex = GrUploadBitmapToTexture(ctx, fBitmap);
315 if (tex && fOriginalKey.isValid()) {
316 tex->resourcePriv().setUniqueKey(fOriginalKey);
317 GrInstallBitmapUniqueKeyInvalidator(fOriginalKey, fBitmap.pixelRef() );
318 }
319 return tex;
320 }
321
322 void makeCopyKey(const CopyParams& copyParams, GrUniqueKey* copyKey) overrid e {
323 if (fOriginalKey.isValid()) {
324 MakeCopyKeyFromOrigKey(fOriginalKey, copyParams, copyKey);
325 }
326 }
327
328 void didCacheCopy(const GrUniqueKey& copyKey) override {
329 GrInstallBitmapUniqueKeyInvalidator(copyKey, fBitmap.pixelRef());
330 }
331
332 private:
333 const SkBitmap fBitmap;
334 GrUniqueKey fOriginalKey;
335
336 typedef GrTextureMaker INHERITED;
337 };
338
339 GrTexture* GrRefCachedBitmapTexture(GrContext* ctx, const SkBitmap& bitmap, 288 GrTexture* GrRefCachedBitmapTexture(GrContext* ctx, const SkBitmap& bitmap,
340 const GrTextureParams& params) { 289 const GrTextureParams& params) {
341 if (bitmap.getTexture()) { 290 if (bitmap.getTexture()) {
342 return GrBitmapTextureAdjuster(&bitmap).refTextureSafeForParams(params, nullptr); 291 return GrBitmapTextureAdjuster(&bitmap).refTextureSafeForParams(params, nullptr);
343 } 292 }
344 return RasterBitmap_GrTextureMaker(bitmap).refTextureForParams(ctx, params); 293 return GrBitmapTextureMaker(ctx, bitmap).refTextureForParams(params);
345 } 294 }
346 295
347 /////////////////////////////////////////////////////////////////////////////// 296 ///////////////////////////////////////////////////////////////////////////////
348 297
349 // alphatype is ignore for now, but if GrPixelConfig is expanded to encompass 298 // alphatype is ignore for now, but if GrPixelConfig is expanded to encompass
350 // alpha info, that will be considered. 299 // alpha info, that will be considered.
351 GrPixelConfig SkImageInfo2GrPixelConfig(SkColorType ct, SkAlphaType, SkColorProf ileType pt) { 300 GrPixelConfig SkImageInfo2GrPixelConfig(SkColorType ct, SkAlphaType, SkColorProf ileType pt) {
352 switch (ct) { 301 switch (ct) {
353 case kUnknown_SkColorType: 302 case kUnknown_SkColorType:
354 return kUnknown_GrPixelConfig; 303 return kUnknown_GrPixelConfig;
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 SkErrorInternals::SetError( kInvalidPaint_SkError, 604 SkErrorInternals::SetError( kInvalidPaint_SkError,
656 "Sorry, I don't understand the filtering " 605 "Sorry, I don't understand the filtering "
657 "mode you asked for. Falling back to " 606 "mode you asked for. Falling back to "
658 "MIPMaps."); 607 "MIPMaps.");
659 textureFilterMode = GrTextureParams::kMipMap_FilterMode; 608 textureFilterMode = GrTextureParams::kMipMap_FilterMode;
660 break; 609 break;
661 610
662 } 611 }
663 return textureFilterMode; 612 return textureFilterMode;
664 } 613 }
OLDNEW
« no previous file with comments | « src/gpu/SkGpuDevice_drawTexture.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698