NinePatchPeeker.h revision a06d86ab8177ee9e631e0ee4e39688bf42179bde
1/* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17#include "SkImageDecoder.h" 18#include <utils/ResourceTypes.h> 19 20using namespace android; 21 22class NinePatchPeeker : public SkImageDecoder::Peeker { 23 SkImageDecoder* fHost; 24public: 25 NinePatchPeeker(SkImageDecoder* host) { 26 // the host lives longer than we do, so a raw ptr is safe 27 fHost = host; 28 fPatchIsValid = false; 29 } 30 31 ~NinePatchPeeker() { 32 if (fPatchIsValid) { 33 free(fPatch); 34 } 35 } 36 37 bool fPatchIsValid; 38 Res_png_9patch* fPatch; 39 40 virtual bool peek(const char tag[], const void* data, size_t length); 41}; 42 43