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

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

Issue 461043002: Revert of SkImage_Codec is Lazy (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 4 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
« no previous file with comments | « src/image/SkImage_Codec.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 "SkImage_Base.h" 8 #include "SkImage_Base.h"
9 #include "SkImagePriv.h" 9 #include "SkImagePriv.h"
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
11 #include "SkCanvas.h" 11 #include "SkCanvas.h"
12 #include "SkData.h" 12 #include "SkData.h"
13 #include "SkDecodingImageGenerator.h"
14 #include "SkMallocPixelRef.h" 13 #include "SkMallocPixelRef.h"
15 14
16 class SkImage_Raster : public SkImage_Base { 15 class SkImage_Raster : public SkImage_Base {
17 public: 16 public:
18 static bool ValidArgs(const Info& info, size_t rowBytes) { 17 static bool ValidArgs(const Info& info, size_t rowBytes) {
19 const int maxDimension = SK_MaxS32 >> 2; 18 const int maxDimension = SK_MaxS32 >> 2;
20 const size_t kMaxPixelByteSize = SK_MaxS32; 19 const size_t kMaxPixelByteSize = SK_MaxS32;
21 20
22 if (info.fWidth < 0 || info.fHeight < 0) { 21 if (info.fWidth < 0 || info.fHeight < 0) {
23 return false; 22 return false;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 62
64 // exposed for SkSurface_Raster via SkNewImageFromPixelRef 63 // exposed for SkSurface_Raster via SkNewImageFromPixelRef
65 SkImage_Raster(const SkImageInfo&, SkPixelRef*, size_t rowBytes); 64 SkImage_Raster(const SkImageInfo&, SkPixelRef*, size_t rowBytes);
66 65
67 SkPixelRef* getPixelRef() const { return fBitmap.pixelRef(); } 66 SkPixelRef* getPixelRef() const { return fBitmap.pixelRef(); }
68 67
69 virtual SkShader* onNewShader(SkShader::TileMode, 68 virtual SkShader* onNewShader(SkShader::TileMode,
70 SkShader::TileMode, 69 SkShader::TileMode,
71 const SkMatrix* localMatrix) const SK_OVERRIDE ; 70 const SkMatrix* localMatrix) const SK_OVERRIDE ;
72 71
73 SkImage_Raster(const SkBitmap& bitmap)
74 :INHERITED(bitmap.width(), bitmap.height())
75 , fBitmap(bitmap) { }
76
77 private: 72 private:
78 SkImage_Raster() : INHERITED(0, 0) {} 73 SkImage_Raster() : INHERITED(0, 0) {}
79 74
80 SkBitmap fBitmap; 75 SkBitmap fBitmap;
81 76
82 typedef SkImage_Base INHERITED; 77 typedef SkImage_Base INHERITED;
83 }; 78 };
84 79
85 /////////////////////////////////////////////////////////////////////////////// 80 ///////////////////////////////////////////////////////////////////////////////
86 81
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 } 199 }
205 200
206 SkImage* SkNewImageFromPixelRef(const SkImageInfo& info, SkPixelRef* pr, 201 SkImage* SkNewImageFromPixelRef(const SkImageInfo& info, SkPixelRef* pr,
207 size_t rowBytes) { 202 size_t rowBytes) {
208 return SkNEW_ARGS(SkImage_Raster, (info, pr, rowBytes)); 203 return SkNEW_ARGS(SkImage_Raster, (info, pr, rowBytes));
209 } 204 }
210 205
211 SkPixelRef* SkBitmapImageGetPixelRef(SkImage* image) { 206 SkPixelRef* SkBitmapImageGetPixelRef(SkImage* image) {
212 return ((SkImage_Raster*)image)->getPixelRef(); 207 return ((SkImage_Raster*)image)->getPixelRef();
213 } 208 }
214
215 SkImage* SkImage::NewEncodedData(SkData* data) {
216 if (NULL == data) {
217 return NULL;
218 }
219 SkBitmap bitmap;
220 if (!SkInstallDiscardablePixelRef(
221 SkDecodingImageGenerator::Create(
222 data, SkDecodingImageGenerator::Options()),
223 &bitmap)) {
224 return NULL;
225 }
226 return SkNEW_ARGS(SkImage_Raster, (bitmap));
227 }
OLDNEW
« no previous file with comments | « src/image/SkImage_Codec.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698