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

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

Issue 105893012: change offset to xy for pixelref subsetting (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « src/gpu/SkGpuDevice.cpp ('k') | src/image/SkImage_Raster.cpp » ('j') | 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 #include "SkGr.h" 8 #include "SkGr.h"
9 #include "SkConfig8888.h" 9 #include "SkConfig8888.h"
10 #include "SkMessageBus.h" 10 #include "SkMessageBus.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 } 58 }
59 } 59 }
60 } 60 }
61 61
62 //////////////////////////////////////////////////////////////////////////////// 62 ////////////////////////////////////////////////////////////////////////////////
63 63
64 static void generate_bitmap_cache_id(const SkBitmap& bitmap, GrCacheID* id) { 64 static void generate_bitmap_cache_id(const SkBitmap& bitmap, GrCacheID* id) {
65 // Our id includes the offset, width, and height so that bitmaps created by extractSubset() 65 // Our id includes the offset, width, and height so that bitmaps created by extractSubset()
66 // are unique. 66 // are unique.
67 uint32_t genID = bitmap.getGenerationID(); 67 uint32_t genID = bitmap.getGenerationID();
68 size_t offset = bitmap.pixelRefOffset(); 68 SkIPoint origin = bitmap.pixelRefOrigin();
69 int16_t width = static_cast<int16_t>(bitmap.width()); 69 int16_t width = SkToS16(bitmap.width());
70 int16_t height = static_cast<int16_t>(bitmap.height()); 70 int16_t height = SkToS16(bitmap.height());
71 71
72 GrCacheID::Key key; 72 GrCacheID::Key key;
73 memcpy(key.fData8, &genID, 4); 73 memcpy(key.fData8 + 0, &genID, 4);
74 memcpy(key.fData8 + 4, &width, 2); 74 memcpy(key.fData8 + 4, &origin.fX, 4);
75 memcpy(key.fData8 + 6, &height, 2); 75 memcpy(key.fData8 + 8, &origin.fY, 4);
76 memcpy(key.fData8 + 8, &offset, sizeof(size_t)); 76 memcpy(key.fData8 + 12, &width, 2);
77 static const size_t kKeyDataSize = 8 + sizeof(size_t); 77 memcpy(key.fData8 + 14, &height, 2);
78 static const size_t kKeyDataSize = 16;
78 memset(key.fData8 + kKeyDataSize, 0, sizeof(key) - kKeyDataSize); 79 memset(key.fData8 + kKeyDataSize, 0, sizeof(key) - kKeyDataSize);
79 GR_STATIC_ASSERT(sizeof(key) >= 8 + sizeof(size_t)); 80 GR_STATIC_ASSERT(sizeof(key) >= kKeyDataSize);
80 static const GrCacheID::Domain gBitmapTextureDomain = GrCacheID::GenerateDom ain(); 81 static const GrCacheID::Domain gBitmapTextureDomain = GrCacheID::GenerateDom ain();
81 id->reset(gBitmapTextureDomain, key); 82 id->reset(gBitmapTextureDomain, key);
82 } 83 }
83 84
84 static void generate_bitmap_texture_desc(const SkBitmap& bitmap, GrTextureDesc* desc) { 85 static void generate_bitmap_texture_desc(const SkBitmap& bitmap, GrTextureDesc* desc) {
85 desc->fFlags = kNone_GrTextureFlags; 86 desc->fFlags = kNone_GrTextureFlags;
86 desc->fWidth = bitmap.width(); 87 desc->fWidth = bitmap.width();
87 desc->fHeight = bitmap.height(); 88 desc->fHeight = bitmap.height();
88 desc->fConfig = SkBitmapConfig2GrPixelConfig(bitmap.config()); 89 desc->fConfig = SkBitmapConfig2GrPixelConfig(bitmap.config());
89 desc->fSampleCnt = 0; 90 desc->fSampleCnt = 0;
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 ct = kBGRA_8888_SkColorType; 282 ct = kBGRA_8888_SkColorType;
282 break; 283 break;
283 default: 284 default:
284 return false; 285 return false;
285 } 286 }
286 if (ctOut) { 287 if (ctOut) {
287 *ctOut = ct; 288 *ctOut = ct;
288 } 289 }
289 return true; 290 return true;
290 } 291 }
OLDNEW
« no previous file with comments | « src/gpu/SkGpuDevice.cpp ('k') | src/image/SkImage_Raster.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698