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

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

Issue 583773004: Revert of introduce Props to surface (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 2 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/SkSurface_Gpu.cpp ('k') | src/pdf/SkPDFDevice.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 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 "SkSurface_Base.h" 8 #include "SkSurface_Base.h"
9 #include "SkImagePriv.h" 9 #include "SkImagePriv.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
11 #include "SkDevice.h" 11 #include "SkDevice.h"
12 #include "SkMallocPixelRef.h" 12 #include "SkMallocPixelRef.h"
13 13
14 static const size_t kIgnoreRowBytesValue = (size_t)~0; 14 static const size_t kIgnoreRowBytesValue = (size_t)~0;
15 15
16 class SkSurface_Raster : public SkSurface_Base { 16 class SkSurface_Raster : public SkSurface_Base {
17 public: 17 public:
18 static bool Valid(const SkImageInfo&, size_t rb = kIgnoreRowBytesValue); 18 static bool Valid(const SkImageInfo&, size_t rb = kIgnoreRowBytesValue);
19 19
20 SkSurface_Raster(const SkImageInfo&, void*, size_t rb, 20 SkSurface_Raster(const SkImageInfo&, void*, size_t rb,
21 void (*releaseProc)(void* pixels, void* context), void* con text, 21 void (*releaseProc)(void* pixels, void* context), void* con text);
22 const SkSurfaceProps*); 22 SkSurface_Raster(SkPixelRef*);
23 SkSurface_Raster(SkPixelRef*, const SkSurfaceProps*);
24 23
25 virtual SkCanvas* onNewCanvas() SK_OVERRIDE; 24 virtual SkCanvas* onNewCanvas() SK_OVERRIDE;
26 virtual SkSurface* onNewSurface(const SkImageInfo&) SK_OVERRIDE; 25 virtual SkSurface* onNewSurface(const SkImageInfo&) SK_OVERRIDE;
27 virtual SkImage* onNewImageSnapshot() SK_OVERRIDE; 26 virtual SkImage* onNewImageSnapshot() SK_OVERRIDE;
28 virtual void onDraw(SkCanvas*, SkScalar x, SkScalar y, 27 virtual void onDraw(SkCanvas*, SkScalar x, SkScalar y,
29 const SkPaint*) SK_OVERRIDE; 28 const SkPaint*) SK_OVERRIDE;
30 virtual void onCopyOnWrite(ContentChangeMode) SK_OVERRIDE; 29 virtual void onCopyOnWrite(ContentChangeMode) SK_OVERRIDE;
31 30
32 private: 31 private:
33 SkBitmap fBitmap; 32 SkBitmap fBitmap;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 71
73 uint64_t size = sk_64_mul(info.height(), rowBytes); 72 uint64_t size = sk_64_mul(info.height(), rowBytes);
74 if (size > kMaxTotalSize) { 73 if (size > kMaxTotalSize) {
75 return false; 74 return false;
76 } 75 }
77 76
78 return true; 77 return true;
79 } 78 }
80 79
81 SkSurface_Raster::SkSurface_Raster(const SkImageInfo& info, void* pixels, size_t rb, 80 SkSurface_Raster::SkSurface_Raster(const SkImageInfo& info, void* pixels, size_t rb,
82 void (*releaseProc)(void* pixels, void* conte xt), void* context, 81 void (*releaseProc)(void* pixels, void* conte xt), void* context)
83 const SkSurfaceProps* props) 82 : INHERITED(info)
84 : INHERITED(info, props)
85 { 83 {
86 fBitmap.installPixels(info, pixels, rb, NULL, releaseProc, context); 84 fBitmap.installPixels(info, pixels, rb, NULL, releaseProc, context);
87 fWeOwnThePixels = false; // We are "Direct" 85 fWeOwnThePixels = false; // We are "Direct"
88 } 86 }
89 87
90 SkSurface_Raster::SkSurface_Raster(SkPixelRef* pr, const SkSurfaceProps* props) 88 SkSurface_Raster::SkSurface_Raster(SkPixelRef* pr)
91 : INHERITED(pr->info().width(), pr->info().height(), props) 89 : INHERITED(pr->info().width(), pr->info().height())
92 { 90 {
93 const SkImageInfo& info = pr->info(); 91 const SkImageInfo& info = pr->info();
94 92
95 fBitmap.setInfo(info, info.minRowBytes()); 93 fBitmap.setInfo(info, info.minRowBytes());
96 fBitmap.setPixelRef(pr); 94 fBitmap.setPixelRef(pr);
97 fWeOwnThePixels = true; 95 fWeOwnThePixels = true;
98 96
99 if (!info.isOpaque()) { 97 if (!info.isOpaque()) {
100 fBitmap.eraseColor(SK_ColorTRANSPARENT); 98 fBitmap.eraseColor(SK_ColorTRANSPARENT);
101 } 99 }
102 } 100 }
103 101
104 SkCanvas* SkSurface_Raster::onNewCanvas() { 102 SkCanvas* SkSurface_Raster::onNewCanvas() {
105 return SkNEW_ARGS(SkCanvas, (fBitmap, this->props())); 103 return SkNEW_ARGS(SkCanvas, (fBitmap));
106 } 104 }
107 105
108 SkSurface* SkSurface_Raster::onNewSurface(const SkImageInfo& info) { 106 SkSurface* SkSurface_Raster::onNewSurface(const SkImageInfo& info) {
109 return SkSurface::NewRaster(info); 107 return SkSurface::NewRaster(info);
110 } 108 }
111 109
112 void SkSurface_Raster::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, 110 void SkSurface_Raster::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y,
113 const SkPaint* paint) { 111 const SkPaint* paint) {
114 canvas->drawBitmap(fBitmap, x, y, paint); 112 canvas->drawBitmap(fBitmap, x, y, paint);
115 } 113 }
(...skipping 19 matching lines...) Expand all
135 // this as its backend, so we can't modify the image's pixels anymore. 133 // this as its backend, so we can't modify the image's pixels anymore.
136 SkASSERT(this->getCachedCanvas()); 134 SkASSERT(this->getCachedCanvas());
137 this->getCachedCanvas()->getDevice()->replaceBitmapBackendForRasterSurfa ce(fBitmap); 135 this->getCachedCanvas()->getDevice()->replaceBitmapBackendForRasterSurfa ce(fBitmap);
138 } 136 }
139 } 137 }
140 138
141 /////////////////////////////////////////////////////////////////////////////// 139 ///////////////////////////////////////////////////////////////////////////////
142 140
143 SkSurface* SkSurface::NewRasterDirectReleaseProc(const SkImageInfo& info, void* pixels, size_t rb, 141 SkSurface* SkSurface::NewRasterDirectReleaseProc(const SkImageInfo& info, void* pixels, size_t rb,
144 void (*releaseProc)(void* pixel s, void* context), 142 void (*releaseProc)(void* pixel s, void* context),
145 void* context, const SkSurfaceP rops* props) { 143 void* context) {
146 if (NULL == releaseProc) { 144 if (NULL == releaseProc) {
147 context = NULL; 145 context = NULL;
148 } 146 }
149 if (!SkSurface_Raster::Valid(info, rb)) { 147 if (!SkSurface_Raster::Valid(info, rb)) {
150 return NULL; 148 return NULL;
151 } 149 }
152 if (NULL == pixels) { 150 if (NULL == pixels) {
153 return NULL; 151 return NULL;
154 } 152 }
155 153
156 return SkNEW_ARGS(SkSurface_Raster, (info, pixels, rb, releaseProc, context, props)); 154 return SkNEW_ARGS(SkSurface_Raster, (info, pixels, rb, releaseProc, context) );
157 } 155 }
158 156
159 SkSurface* SkSurface::NewRasterDirect(const SkImageInfo& info, void* pixels, siz e_t rowBytes, 157 SkSurface* SkSurface::NewRasterDirect(const SkImageInfo& info, void* pixels, siz e_t rowBytes) {
160 const SkSurfaceProps* props) { 158 return NewRasterDirectReleaseProc(info, pixels, rowBytes, NULL, NULL);
161 return NewRasterDirectReleaseProc(info, pixels, rowBytes, NULL, NULL, props) ;
162 } 159 }
163 160
164 SkSurface* SkSurface::NewRaster(const SkImageInfo& info, const SkSurfaceProps* p rops) { 161 SkSurface* SkSurface::NewRaster(const SkImageInfo& info) {
165 if (!SkSurface_Raster::Valid(info)) { 162 if (!SkSurface_Raster::Valid(info)) {
166 return NULL; 163 return NULL;
167 } 164 }
168 165
169 SkAutoTUnref<SkPixelRef> pr(SkMallocPixelRef::NewAllocate(info, 0, NULL)); 166 SkAutoTUnref<SkPixelRef> pr(SkMallocPixelRef::NewAllocate(info, 0, NULL));
170 if (NULL == pr.get()) { 167 if (NULL == pr.get()) {
171 return NULL; 168 return NULL;
172 } 169 }
173 return SkNEW_ARGS(SkSurface_Raster, (pr, props)); 170 return SkNEW_ARGS(SkSurface_Raster, (pr));
174 } 171 }
OLDNEW
« no previous file with comments | « src/image/SkSurface_Gpu.cpp ('k') | src/pdf/SkPDFDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698