| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013, Google Inc. All rights reserved. | 2 * Copyright (c) 2013, Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 namespace blink { | 36 namespace blink { |
| 37 | 37 |
| 38 bool ensureTextureBackedSkBitmap(GrContext* gr, SkBitmap& bitmap, const IntSize&
size, GrSurfaceOrigin origin, GrPixelConfig config) | 38 bool ensureTextureBackedSkBitmap(GrContext* gr, SkBitmap& bitmap, const IntSize&
size, GrSurfaceOrigin origin, GrPixelConfig config) |
| 39 { | 39 { |
| 40 if (!bitmap.getTexture() || bitmap.width() != size.width() || bitmap.height(
) != size.height()) { | 40 if (!bitmap.getTexture() || bitmap.width() != size.width() || bitmap.height(
) != size.height()) { |
| 41 if (!gr) | 41 if (!gr) |
| 42 return false; | 42 return false; |
| 43 GrTextureDesc desc; | 43 GrTextureDesc desc; |
| 44 desc.fConfig = config; | 44 desc.fConfig = config; |
| 45 desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagB
it; | 45 desc.fFlags = kRenderTarget_GrSurfaceFlag; |
| 46 desc.fSampleCnt = 0; | 46 desc.fSampleCnt = 0; |
| 47 desc.fOrigin = origin; | 47 desc.fOrigin = origin; |
| 48 desc.fWidth = size.width(); | 48 desc.fWidth = size.width(); |
| 49 desc.fHeight = size.height(); | 49 desc.fHeight = size.height(); |
| 50 SkAutoTUnref<GrTexture> texture(gr->createUncachedTexture(desc, 0, 0)); | 50 SkAutoTUnref<GrTexture> texture(gr->textureProvider()->createTexture(des
c, false, 0, 0)); |
| 51 if (!texture.get()) | 51 if (!texture.get()) |
| 52 return false; | 52 return false; |
| 53 | 53 |
| 54 SkImageInfo info = SkImageInfo::MakeN32Premul(desc.fWidth, desc.fHeight)
; | 54 SkImageInfo info = SkImageInfo::MakeN32Premul(desc.fWidth, desc.fHeight)
; |
| 55 SkGrPixelRef* pixelRef = SkNEW_ARGS(SkGrPixelRef, (info, texture.get()))
; | 55 SkGrPixelRef* pixelRef = SkNEW_ARGS(SkGrPixelRef, (info, texture.get()))
; |
| 56 if (!pixelRef) | 56 if (!pixelRef) |
| 57 return false; | 57 return false; |
| 58 bitmap.setInfo(info); | 58 bitmap.setInfo(info); |
| 59 bitmap.setPixelRef(pixelRef)->unref(); | 59 bitmap.setPixelRef(pixelRef)->unref(); |
| 60 } | 60 } |
| 61 | 61 |
| 62 return true; | 62 return true; |
| 63 } | 63 } |
| 64 | 64 |
| 65 } // namespace blink | 65 } // namespace blink |
| OLD | NEW |