OLD | NEW |
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 "SkBitmapDevice.h" | 8 #include "SkBitmapDevice.h" |
9 #include "SkConfig8888.h" | 9 #include "SkConfig8888.h" |
10 #include "SkDraw.h" | 10 #include "SkDraw.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 return false; | 62 return false; |
63 } | 63 } |
64 | 64 |
65 if (newAlphaType) { | 65 if (newAlphaType) { |
66 *newAlphaType = canonicalAlphaType; | 66 *newAlphaType = canonicalAlphaType; |
67 } | 67 } |
68 return true; | 68 return true; |
69 } | 69 } |
70 | 70 |
71 SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap) | 71 SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap) |
72 : INHERITED(SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType)) | 72 : INHERITED(bitmap.info(), SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_In
itType)) |
73 , fBitmap(bitmap) | 73 , fBitmap(bitmap) |
74 { | 74 { |
75 SkASSERT(valid_for_bitmap_device(bitmap.info(), nullptr)); | 75 SkASSERT(valid_for_bitmap_device(bitmap.info(), nullptr)); |
76 fBitmap.lockPixels(); | 76 fBitmap.lockPixels(); |
77 } | 77 } |
78 | 78 |
79 SkBitmapDevice* SkBitmapDevice::Create(const SkImageInfo& info) { | 79 SkBitmapDevice* SkBitmapDevice::Create(const SkImageInfo& info) { |
80 return Create(info, SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType)
); | 80 return Create(info, SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType)
); |
81 } | 81 } |
82 | 82 |
83 SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap, const SkSurfaceProps& sur
faceProps) | 83 SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap, const SkSurfaceProps& sur
faceProps) |
84 : INHERITED(surfaceProps) | 84 : INHERITED(bitmap.info(), surfaceProps) |
85 , fBitmap(bitmap) | 85 , fBitmap(bitmap) |
86 { | 86 { |
87 SkASSERT(valid_for_bitmap_device(bitmap.info(), nullptr)); | 87 SkASSERT(valid_for_bitmap_device(bitmap.info(), nullptr)); |
88 fBitmap.lockPixels(); | 88 fBitmap.lockPixels(); |
89 } | 89 } |
90 | 90 |
91 SkBitmapDevice* SkBitmapDevice::Create(const SkImageInfo& origInfo, | 91 SkBitmapDevice* SkBitmapDevice::Create(const SkImageInfo& origInfo, |
92 const SkSurfaceProps& surfaceProps) { | 92 const SkSurfaceProps& surfaceProps) { |
93 SkAlphaType newAT = origInfo.alphaType(); | 93 SkAlphaType newAT = origInfo.alphaType(); |
94 if (!valid_for_bitmap_device(origInfo, &newAT)) { | 94 if (!valid_for_bitmap_device(origInfo, &newAT)) { |
(...skipping 18 matching lines...) Expand all Loading... |
113 // We use a ZeroedPRFactory as a faster alloc-then-eraseColor(SK_ColorTR
ANSPARENT). | 113 // We use a ZeroedPRFactory as a faster alloc-then-eraseColor(SK_ColorTR
ANSPARENT). |
114 SkMallocPixelRef::ZeroedPRFactory factory; | 114 SkMallocPixelRef::ZeroedPRFactory factory; |
115 if (!bitmap.tryAllocPixels(info, &factory, nullptr/*color table*/)) { | 115 if (!bitmap.tryAllocPixels(info, &factory, nullptr/*color table*/)) { |
116 return nullptr; | 116 return nullptr; |
117 } | 117 } |
118 } | 118 } |
119 | 119 |
120 return new SkBitmapDevice(bitmap, surfaceProps); | 120 return new SkBitmapDevice(bitmap, surfaceProps); |
121 } | 121 } |
122 | 122 |
123 SkImageInfo SkBitmapDevice::imageInfo() const { | |
124 return fBitmap.info(); | |
125 } | |
126 | |
127 void SkBitmapDevice::setNewSize(const SkISize& size) { | 123 void SkBitmapDevice::setNewSize(const SkISize& size) { |
128 SkASSERT(!fBitmap.pixelRef()); | 124 SkASSERT(!fBitmap.pixelRef()); |
129 fBitmap.setInfo(fBitmap.info().makeWH(size.fWidth, size.fHeight)); | 125 fBitmap.setInfo(fBitmap.info().makeWH(size.fWidth, size.fHeight)); |
| 126 this->privateResize(fBitmap.info().width(), fBitmap.info().height()); |
130 } | 127 } |
131 | 128 |
132 void SkBitmapDevice::replaceBitmapBackendForRasterSurface(const SkBitmap& bm) { | 129 void SkBitmapDevice::replaceBitmapBackendForRasterSurface(const SkBitmap& bm) { |
133 SkASSERT(bm.width() == fBitmap.width()); | 130 SkASSERT(bm.width() == fBitmap.width()); |
134 SkASSERT(bm.height() == fBitmap.height()); | 131 SkASSERT(bm.height() == fBitmap.height()); |
135 fBitmap = bm; // intent is to use bm's pixelRef (and rowbytes/config) | 132 fBitmap = bm; // intent is to use bm's pixelRef (and rowbytes/config) |
136 fBitmap.lockPixels(); | 133 fBitmap.lockPixels(); |
| 134 this->privateResize(fBitmap.info().width(), fBitmap.info().height()); |
137 } | 135 } |
138 | 136 |
139 SkBaseDevice* SkBitmapDevice::onCreateDevice(const CreateInfo& cinfo, const SkPa
int*) { | 137 SkBaseDevice* SkBitmapDevice::onCreateDevice(const CreateInfo& cinfo, const SkPa
int*) { |
140 const SkSurfaceProps surfaceProps(this->surfaceProps().flags(), cinfo.fPixel
Geometry); | 138 const SkSurfaceProps surfaceProps(this->surfaceProps().flags(), cinfo.fPixel
Geometry); |
141 return SkBitmapDevice::Create(cinfo.fInfo, surfaceProps); | 139 return SkBitmapDevice::Create(cinfo.fInfo, surfaceProps); |
142 } | 140 } |
143 | 141 |
144 const SkBitmap& SkBitmapDevice::onAccessBitmap() { | 142 const SkBitmap& SkBitmapDevice::onAccessBitmap() { |
145 return fBitmap; | 143 return fBitmap; |
146 } | 144 } |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 paint.getRasterizer() || | 439 paint.getRasterizer() || |
442 paint.getPathEffect() || | 440 paint.getPathEffect() || |
443 paint.isFakeBoldText() || | 441 paint.isFakeBoldText() || |
444 paint.getStyle() != SkPaint::kFill_Style || | 442 paint.getStyle() != SkPaint::kFill_Style || |
445 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode)) | 443 !SkXfermode::IsMode(paint.getXfermode(), SkXfermode::kSrcOver_Mode)) |
446 { | 444 { |
447 return true; | 445 return true; |
448 } | 446 } |
449 return false; | 447 return false; |
450 } | 448 } |
OLD | NEW |