Layer.cpp revision 8cd3edfa15cc9cdbffa935d19ab894426b08d174
1/* 2 * Copyright (C) 2012 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 "Layer.h" 18 19#include "renderstate/RenderState.h" 20 21#include <SkColorFilter.h> 22 23namespace android { 24namespace uirenderer { 25 26Layer::Layer(RenderState& renderState, Api api) 27 : GpuMemoryTracker(GpuObjectType::Layer) 28 , mRenderState(renderState) 29 , mApi(api) { 30 // TODO: This is a violation of Android's typical ref counting, but it 31 // preserves the old inc/dec ref locations. This should be changed... 32 incStrong(nullptr); 33 34 renderState.registerLayer(this); 35} 36 37Layer::~Layer() { 38 SkSafeUnref(colorFilter); 39 40 mRenderState.unregisterLayer(this); 41} 42 43void Layer::setColorFilter(SkColorFilter* filter) { 44 SkRefCnt_SafeAssign(colorFilter, filter); 45} 46 47void Layer::postDecStrong() { 48 mRenderState.postDecStrong(this); 49} 50 51}; // namespace uirenderer 52}; // namespace android 53