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

Side by Side Diff: src/core/SkMipMap.cpp

Issue 1249543003: Creating functions for uploading a mipmapped texture. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Refactoring the mipmap level count out. Cleaning includes. Created 4 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
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 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 "SkMipMap.h" 8 #include "SkMipMap.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 344
345 if (level > fCount) { 345 if (level > fCount) {
346 level = fCount; 346 level = fCount;
347 } 347 }
348 if (levelPtr) { 348 if (levelPtr) {
349 *levelPtr = fLevels[level - 1]; 349 *levelPtr = fLevels[level - 1];
350 } 350 }
351 return true; 351 return true;
352 } 352 }
353 353
354 // Helper which extacts a pixmap from the src bitmap 354 // Helper which extracts a pixmap from the src bitmap
355 // 355 //
356 SkMipMap* SkMipMap::Build(const SkBitmap& src, SkDiscardableFactoryProc fact) { 356 SkMipMap* SkMipMap::Build(const SkBitmap& src, SkDiscardableFactoryProc fact) {
357 SkAutoPixmapUnlock srcUnlocker; 357 SkAutoPixmapUnlock srcUnlocker;
358 if (!src.requestLock(&srcUnlocker)) { 358 if (!src.requestLock(&srcUnlocker)) {
359 return nullptr; 359 return nullptr;
360 } 360 }
361 const SkPixmap& srcPixmap = srcUnlocker.pixmap(); 361 const SkPixmap& srcPixmap = srcUnlocker.pixmap();
362 // Try to catch where we might have returned nullptr for src crbug.com/49281 8 362 // Try to catch where we might have returned nullptr for src crbug.com/49281 8
363 if (nullptr == srcPixmap.addr()) { 363 if (nullptr == srcPixmap.addr()) {
364 sk_throw(); 364 sk_throw();
365 } 365 }
366 return Build(srcPixmap, fact); 366 return Build(srcPixmap, fact);
367 } 367 }
368 368
369 int SkMipMap::getLevelsCount() const {
370 return fCount;
371 }
372
373 bool SkMipMap::getLevel(int levelIndex, Level* levelPtr) const {
374 if (NULL == fLevels) {
375 return false;
376 }
377 if (levelIndex <= 0) {
378 return false;
379 }
380 if (levelIndex > fCount) {
381 return false;
382 }
383 if (levelPtr) {
384 *levelPtr = fLevels[levelIndex - 1];
385 }
386 return true;
387 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698